Move with angle o degree or ....

Previous topic - Next topic

equinox

Hi at all,

Instead of to use for the motion, like itself pou' to do to use the motion in angles? 

for example: X = X + ang(0.5467) or if wanted to do motive in diagonal

We say to 45.54567° ? 

Tnk1000.


Billamu

x=sin(angle)*scale
y=cos(angle)*scale

I think...
I'm an Aries. I have lots of Ram.

Kitty Hello

depends on where you define 0°
in GLBasic (rotosprite) 0° is pointing to the right side, 90° up.

Then:
x = x + COS(phi)*scale
y = y - SIN(phi) * scale

equinox

#3
http://www.webalice.it/equinox1/back1.jpg

Thanks boys for the reply. 

I do not understand what it is ---> phi)*scale

i agree to be able to move in these directions, and the sprite remains of the same dimension: is possible? 

same dimension ---> http://www.webalice.it/equinox1/800x600.jpg


Moru

phi is the angle in degrees that you want to move in, scale is the distance you want to move in pixels.

I usually use "dir" and "speed", that's more clear what they do.

Kitty Hello

#5
ah.
In your case it's easier!

Let's define x,y as in your image:


   Z
\Y |  /X
\ | /
  \|/



Then, the screen pixels are:
Code (glbasic) Select

px = px0 + x*bw - y*bw
py = py0 -y*bw +x*bw - z*bh

with:
px0, py0: pixel coodinated for point 0,0,0 in world coordinates
bw: width of "half" a block in pixels.
bh: height of block in pixels

   ^
  / \
/   \
/     \  _
\     /|
\   / | bh
  \ /  | _
\  |  /
\ | /
  \|/
       |
   +bw-+


Not tested, but it should work.







equinox

#6
FIRST: Thanks still to all for the help that you are giving me. 

....px0, py0: pixel coodinated for point 0,0,0 in world coordinates


I should use this function,KH ?

X_SCREEN2WORLD sx#, sy#, sz#, wx##, wy##, wz##
Maps the 2D screen coordinates sx#, sy#, sz# into the 3D world coordinates wx##, wy##, wz##.

px = px0 + x*bw - y*bw
py = py0 -y*bw +x*bw - z*bh....This code serves to move the cube and not to make it become small while goes towards the fund of the room? 


Tnk1000.

Kitty Hello

are you rendering in 3D?
Then x,y,z is world coordinates, and you must set the camera correctly.

equinox

Hi KH,

If I put my code line on, you could look at the to see where mistake?




...I am having difficulty to systemize it. ..ma not there I succeed alone.