Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / the whirl

Author
Message
glint
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: the Synth
Posted: 10th Feb 2004 05:04
Is there a way to make a sprite move in 360 directions (or 40, or 90, or whatever, depending on how much you increment or decrement the direction each time you press a key)?
I think I've already figured out how to make a sprite that has a full 360 degree animation. This could be done with a sprite with 40 frames, where x equals direction out of 360. X would be decreased and increased with arrow keys, and the sprite frame number would be updated to x/9 (to make for 40 possible directions).
However, I have no idea how to make the sprite actually move in 360 directions. Can someone help me?
Thanks
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 10th Feb 2004 05:19
you mean 360 degrees? if so im tryin to figgure out the same thing as im experimenting with the rotate sprite command

The search continues.
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 10th Feb 2004 08:34
http://www.thegamecreators.com/?m=forum_view&t=25629&b=4

RGT may be gone but the best DBP forum is still alive and kicking, check it out.
http://www.dannywartnaby.co.uk/rgt/
glint
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: the Synth
Posted: 11th Feb 2004 06:42
TO ALL CONCERNED : I HAVE FIGURED THIS OUT.

You all know that to update a sprite you simply decrement or increment its x and y values . . .

Let's say for example that in every step event you want your character to move 20 steps, no matter what the direction. To do this, you must find the horizontal and vertical components of the velocity. You must know the angle you are travelling at. (You could save the number of degrees you had rotated your sprite, perhaps).

To find the vertical component, as in the number of units you must add to the sprite's y position, in the step event, use this equation:

ycomponent = 20[cosin(angle)]
(look in the book for the cosin function)

To find the horizontal component (the horizontal movement), use this equation:

xcomponent = 20[sin(angle)]
(look in the book for the sin function)

Once you have both components, you can make a step event like:

sprite x = sprite x + xcomponent
sprite y = sprite y + ycomponent
(I'm not sure how to define the location of a sprite, but it's something like that.)

The "20" in the first two equations could be anything, depending on how fast you want your sprite to move.
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 11th Feb 2004 22:14
sprite 1,x,y,imagenum

maybe something like that to define the location

The search continues.

Login to post a reply

Server time is: 2024-05-13 21:26:31
Your offset time is: 2024-05-13 21:26:31