Hi Everybody,
I am bussy with a gam: Quest and try to move picturebox1. But the output is very strange.
I am using 4 buttons to move the player.
Here is the project.
THX!!
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
FroglegPosted Feb 8, 2012, 2:35 AM
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 albertPosted Feb 8, 2012, 2:43 AM
albert albertPosted Feb 7, 2012, 2:06 PM
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]
FroglegPosted Feb 7, 2012, 1:51 PM
albert albertPosted Feb 7, 2012, 11:40 AM
FroglegPosted Feb 7, 2012, 11:24 AM
In class mover.move, you are not supplying an intial point to add to moveInterval
The movement of the player is way too complicated