GLBasic forum

Main forum => Tutorials => Topic started by: equinox on 2008-Sep-11

Title: Move with angle o degree or ....
Post by: equinox on 2008-Sep-11
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.

Title: Re: Move with angle o degree or ....
Post by: Billamu on 2008-Sep-11
x=sin(angle)*scale
y=cos(angle)*scale

I think...
Title: Re: Move with angle o degree or ....
Post by: Kitty Hello on 2008-Sep-11
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
Title: Re: Move with angle o degree or ....
Post by: equinox on 2008-Sep-11
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

Title: Re: Move with angle o degree or ....
Post by: Moru on 2008-Sep-11
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.
Title: Re: Move with angle o degree or ....
Post by: Kitty Hello on 2008-Sep-12
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.






Title: Re: Move with angle o degree or ....
Post by: equinox on 2008-Sep-12
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.
Title: Re: Move with angle o degree or ....
Post by: Kitty Hello on 2008-Sep-12
are you rendering in 3D?
Then x,y,z is world coordinates, and you must set the camera correctly.
Title: Re: Move with angle o degree or ....
Post by: equinox on 2008-Sep-12
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.