This site requires JavaScript, please enable it in your browser!
Greenfoot back
LawsonCJ
LawsonCJ wrote ...

2017/1/13

Have an Actor point towards direction (left, right, up, down)

LawsonCJ LawsonCJ

2017/1/13

#
I am trying to create a pacman game for a class project and right now I am using booleans to ensure pacman can only move in one direction and that while one key is down, the rest cant be activated until no keys are pressed. I just realized that pacman never stops moving so I had the idea to keep him in constant movement and just have him turn. As much as I want to use rotation, it would be difficult. Having pacman face one direction, and then having him rotate the same amount everytime would not work if he was facing down moving and you pressed the up key, he would need to rotate 180. Left to down would just be 90. Its different and would be hard to detect. If There was a way to just have him face upwards if the up key was pressed, and face accordingly for each key, it would make it easier and make animating a lot easier. Please help me DANPOST!
Super_Hippo Super_Hippo

2017/1/13

#
Try to use 'setRotation' instead of 'turn'.
danpost danpost

2017/1/13

#
LawsonCJ wrote...
As much as I want to use rotation, it would be difficult.
It should not be difficult, and the booleans should not be necessary. The amount to turn can be obtained by the difference between the current rotation and the direction directed by the keys.
LawsonCJ LawsonCJ

2017/1/19

#
Thanks Danpost! I just want you to know Danpost, that within our class room, you are our hero. Sincerely, Mr.Swaine's Grade 11 Intro to Computer science Class
You need to login to post a reply.