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

2011/5/6

[ASK] How to handle the error movement of an actor between two wallss?

Zhirayuki Zhirayuki

2011/5/6

#
hi all, i want to ask how to handle movement of an actor (its a tank like tank 1990 nitendo's game ) how to handle the movement of the tank when there is so much wall so it doesnt get stuck when moving between 2 walls or some movement around the wall. I use getOneIntersectingObject but it alwys stuck on the walls. Then i use getWorld().getObjectsAt, it works but still have problem when the tank entering a cell where at right and left is wall. it stuck there... anyone can help me?
davmac davmac

2011/5/9

#
Put your code up somewhere so we can have a look! In other words: upload your scenario to the gallery with source code, and tell us the URL.
Zhirayuki Zhirayuki

2011/5/17

#
for devmac : its in http://greenfootgallery.org/scenarios/2931... its movement within the wall still bugged, and the infantry cause lag to whole game . more the infantry spawn the game slowing down.. i dont have idea for why that happen. The cannon for tank still bugged too. i know what to do, but forget to change it. :D... thanks. can u help me out?
davmac davmac

2011/5/18

#
The scenario isn't there. Did you delete it (or get the URL wrong)?
Zhirayuki Zhirayuki

2011/5/18

#
ups sory miss one number : http://greenfootgallery.org/scenarios/2932
davmac davmac

2011/5/27

#
I think it's your "moveWhileStuck" method that causes the problem, eg:
                if (checkObstacle(x, y+13))
                {
                    setLocation(x/25 * 25 + 13, y + moveAmount);
                    setDirection(SOUTH);
                }
What is is that you're trying to do with this code exactly?
You need to login to post a reply.