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

2011/11/16

adding walls

ardwennem2 ardwennem2

2011/11/16

#
Hi, what I currently have is a square moving around 10 spaces per time you press left right up or down, and until it has taken those 10 steps, it won't follow input again... could anyone tell me how I can add walls in my program? What I've tried so far is: private boolean checkWallUp() { if (getY() + 10 == wall.getY()) { return false; } else return true; } (basicly, if I can get the return false/true working, I know how to handle the rest myself... it's just this small (I hope...) part I don't know
danpost danpost

2011/11/18

#
use 'if (getOneObjectAtOffset(0, 10, Wall.class) != null) { return true; } else { return false; }' or just 'return (getOneObjectAtOffset(0, 10, Wall.class) != null);' BTW, walls usually have an X offset, not a Y offset. But if your walls are below your Actor, the above code should work. If they are actually walls located to the right (or left) of the Actor, along the x-coordinate, just adjust the code above.
You need to login to post a reply.