..............
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
..............
Last edited by pajfilms; May 4th, 2012 at 01:18 PM.
You need to debug your code to see what is happening.sometimes it moves two tiles in the grid even though I'm not holding down an arrow key.
Add some printlns to show the values of the variables as they are changed and as they are used to move the image.
..............
Last edited by pajfilms; May 4th, 2012 at 01:18 PM.
Look at your logic to see if the image's next movement will go past the bounds of the grid and stop its moving at that point. For example if it is at 31 and moves by 2 it will skip over 32.it sometimes doesn't hit zero,
So before the move test if the change of position will move the image past its stopping point.
..............
Last edited by pajfilms; May 4th, 2012 at 01:18 PM.
Look at the logic where you change the x,y values for a move.
Check if the new position will cross a boundary and if the movement should stop.
If it should stop, set the new location to be on the boundary and signal a stop.
pajfilms (August 27th, 2011)
..............
Last edited by pajfilms; May 4th, 2012 at 01:18 PM.
How else would you change the movement into the next postion if it was past where you want it to stop?It snaps into place
I did not say to continue using the % 32 logic. Perhaps that is not the way to recognize where the boundaries are.
pajfilms (August 27th, 2011)
..............
Last edited by pajfilms; May 4th, 2012 at 01:18 PM.
There are usually more than one way to solve a problem.
Simpler is often better.