-
Movement based off rotation.
Hi i'm trying to make a 2d game where i need the player's x and y positions to update based on the angle of rotation when they move. It's been a good few years since i even thought of programming and have forgotten the math.
Any help would be much appreciated!
-
You could have two Variables one called xPos and yPos. It seems to be a very common way to get to set the players position.
-
Yes, but i want to move forward the way the sprite is facing rather than straight 4 directional movement.
I think it has something to do with storing the x and y positions and calculating the sin and cos of the angles but i'm jiggered if i can remember how it goes together.
-
Got it now
-
step = amount the player moves each step
x += sin(angle)*step
y += cos(angle)*step
I might have flip-flop the sin and cos. If the rotation seems backwards, just swap them.
Similar Threads
-
By goelankur1982 in forum VB Classic
Replies: 2
Last Post: 09-11-2007, 12:42 AM
-
Replies: 1
Last Post: 11-03-2005, 05:17 PM
-
By pithhelmet in forum VB Classic
Replies: 2
Last Post: 04-26-2005, 09:02 AM
-
By Eugene in forum VB Classic
Replies: 4
Last Post: 12-19-2000, 12:52 PM
-
By Eugene in forum VB Classic
Replies: 0
Last Post: 12-19-2000, 11:13 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|