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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
FroglegRank #1,020 · 1.9K reputationPosted Feb 7, 2012, 9:35 PM EST
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
FroglegRank #1,020 · 1.9K reputationPosted Feb 7, 2012, 6:24 AM EST
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 albertRank #2,683 · 519 reputationPosted Feb 7, 2012, 6:40 AM EST
FroglegRank #1,020 · 1.9K reputationPosted Feb 7, 2012, 8:51 AM EST
albert albertRank #2,683 · 519 reputationPosted Feb 7, 2012, 9:06 AM EST
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]
albert albertRank #2,683 · 519 reputationPosted Feb 7, 2012, 9:43 PM EST