
-----------------------------------
Latagore
Wed Oct 17, 2007 9:40 pm

Relative Movement
-----------------------------------
How might I do relative movement (Where you use left and right to turn the character and up and down to move relative to facing direction) for a character that the user controls? I've tried using an angle, but it seems kind of hard to do since objects are oriented with x and y coordinates.

-----------------------------------
Nick
Thu Oct 18, 2007 7:00 am

RE:Relative Movement
-----------------------------------
first of all how many directions do u want to be able to move and second what will ur character look like (for many directions it will be hard to create ur own graphics as u will ne to create a new one for each direction)

-----------------------------------
cpu_hacker4.0
Thu Oct 18, 2007 10:53 am

Re: Relative Movement
-----------------------------------
Yeah...just make a procedure for each different direction that draws what the character will look like, and call the corresponding procedure when you push the key that moves the character in that direction.

-----------------------------------
Latagore
Thu Oct 18, 2007 11:00 am

Re: Relative Movement
-----------------------------------
I know how to turn it, just not how to turn it back and forth. I want to be able to turn 36 different directions, at least.

EDIT: And since it is from top down, I can just rotate the picture in a picture editing program or simply use the shapes provided in Turing.

-----------------------------------
Nick
Thu Oct 18, 2007 12:09 pm

RE:Relative Movement
-----------------------------------
ok just make a procedure that activates if the user hits left or right and make it change a varible that tells the computer which direction the user walks and use the Pic.Rotate to change the direction the picture is facing... that should work

-----------------------------------
Saad
Thu Oct 18, 2007 1:14 pm

RE:Relative Movement
-----------------------------------
You should be using trig to get which angle the player is facing and rotate the picture based on the angle. Also you should use reals for the x,y coordinates and round the coordinates for the pixel locations

-----------------------------------
Mazer
Thu Oct 18, 2007 1:49 pm

Re: Relative Movement
-----------------------------------
I know how to turn it, just not how to turn it back and forth. I want to be able to turn 36 different directions, at least.

EDIT: And since it is from top down, I can just rotate the picture in a picture editing program or simply use the shapes provided in Turing.
If you're going ahead with using external images, why not just use Pic.Rotate to generate images for the other angles?

1) Start the game and load the picture
2) Make copies of the picture using Pic.Rotate for each angle you want in an array
3) Store x,y, and angle for your player (preferrably in some structure)
4) Input: left/right will add/subtract X degrees from the angle, up/down will add SPEED * cos(angle) to x, SPEED * sin(angle) to y
5) Draw picture(angle) at x, y.

EDIT: And there's a bit more to it, that was just the general idea. You want 36 directions? That's reasonable, but make the array of pictures 0..35 and the angle in the range of 0 