### Author Topic: Move with angle o degree or ....  (Read 4974 times)

#### equinox

• Mc. Print
• Posts: 19
##### Move with angle o degree or ....
« 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.

#### Billamu

• Mc. Print
• Posts: 27
##### Re: Move with angle o degree or ....
« Reply #1 on: 2008-Sep-11 »
x=sin(angle)*scale
y=cos(angle)*scale

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

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10695
• here on my island the sea says 'hello'
##### Re: Move with angle o degree or ....
« Reply #2 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

#### equinox

• Mc. Print
• Posts: 19
##### Re: Move with angle o degree or ....
« Reply #3 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

« Last Edit: 2008-Sep-11 by equinox »

#### Moru

• Prof. Inline
• Posts: 1774
##### Re: Move with angle o degree or ....
« Reply #4 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.

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10695
• here on my island the sea says 'hello'
##### Re: Move with angle o degree or ....
« Reply #5 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.

« Last Edit: 2008-Sep-12 by Kitty Hello »

#### equinox

• Mc. Print
• Posts: 19
##### Re: Move with angle o degree or ....
« Reply #6 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.
« Last Edit: 2008-Sep-12 by equinox »

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10695
• here on my island the sea says 'hello'
##### Re: Move with angle o degree or ....
« Reply #7 on: 2008-Sep-12 »
are you rendering in 3D?
Then x,y,z is world coordinates, and you must set the camera correctly.

#### equinox

• Mc. Print
• Posts: 19
##### Re: Move with angle o degree or ....
« Reply #8 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.