Frogleg
posted
808 posts
since
Aug 13, 2010
from
Australia
|
|
Re: trying to move the player
|
|
|
|
|
|
|
|
|
|
|
The player is moving - to point (0,0) In class mover.move, you are not supplying an intial point to add to moveInterval The movement of the player is way too complicated
|
|
|
|
|
|
albert albert
posted
119 posts
since
Dec 02, 2008
from
|
|
Re: trying to move the player
|
|
|
|
|
|
|
|
|
|
|
But I if u put a breakpoint on the move method u see that the line will be reached. What u suggest than?
|
|
|
|
|
|
Frogleg
posted
808 posts
since
Aug 13, 2010
from
Australia
|
|
Re: trying to move the player
|
|
|
|
|
|
|
|
|
|
|
How do you want the player to move ? 5 pixels at a time ?
|
|
|
|
|
|
albert albert
posted
119 posts
since
Dec 02, 2008
from
|
|
Re: trying to move the player
|
|
|
|
|
|
|
|
|
|
|
yes, or 10. But My intention is to move the player and then to move the annemies
but this method seems logical:
[code] public Point Move(Direction direction, Rectangle boundaries) { Point newLocation = location; switch (direction) { case Player.Direction.right: newLocation.X += MoveInterval; // if (newLocation.X + MoveInterval <= boundaries.Right) // newLocation.X += MoveInterval; break; case Player.Direction.left: if(newLocation.X - MoveInterval >= boundaries.Left) newLocation.X -= MoveInterval; break; case Player.Direction.up: if (newLocation.Y - MoveInterval >= boundaries.Top) newLocation.Y -= MoveInterval; break; case Player.Direction.down: if (newLocation.Y + MoveInterval <= boundaries.Bottom) newLocation.Y += MoveInterval; break; default:break; } return newLocation; [/code]
I did a small test for the down button(I pressed several times on the button) and it seems the player doesnt move, output:
[output] {X=278,Y=132} {X=278,Y=132} {X=278,Y=132} {X=278,Y=132} {X=278,Y=132} {X=278,Y=132} [/output]
|
|
|
|
|
|
Frogleg
posted
808 posts
since
Aug 13, 2010
from
Australia
|
|
Re: trying to move the player
|
|
|
|
|
|
|
|
|
|
|
It may be logical -but it's not practical I removed mover class - mainly because it was easier for me to get the player moving Put it back in, but make sure that the move method gets player current position and the player gets the movement info back
|
|
|
|
|
|
albert albert
posted
119 posts
since
Dec 02, 2008
from
|
|
Re: trying to move the player
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|