View Single Post
Old 6th June 2003, 13:24   #113
Tuggummi
Bin King
 
Tuggummi's Avatar
 
Join Date: Mar 2001
Location: Finland
Posts: 2,173
shift per pixel

A simple trick for advanced avsers.

To shift a scope by pixel.

X-axis
xt=xt+(#/w)*2

Y-axis
yt=yt+(#/h)*2

#=ammount of pixels skipped. 1=none , 0=no movement

Example:

per frame
xt=xt+(2/w)*2 ;

per pixel
y=i*2-1 ;
x=if(above(xt,1),-1,xt)


This will shift your scope by skipping every other line.

code:

|-|-|-|-




Notice that if you want to skip 2 pixels, you don't use 2 you use 3. A way of "remembering" it is to write it like this:

xt=xt+(#/w)*2+2/w

2/w adds the extra pixel, so that what ever number you use in # it will skip that ammount of pixels. Of course it's better to use straight up higher number, but it's just for convenience.

example:

xt=xt+(3/w)*2+2/w

Will move the scope like this:

code:

|---|---|---|---|---





Notice also that shifting per pixel won't work with sin&cos, only when you apply it directly to the scope movement it will work, you can use the if functions to limit the movement of the scope or to make it warp to the otherside once it reaches the end.

Texer Resources

Im retarded... err i mean retired!
Probably both...
Tuggummi is offline   Reply With Quote