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

2016/12/1

how to do not walk through the wall!

Roselina Roselina

2016/12/1

#
I have designed a maze and the only mistake with it that my "character" is going through the walls ... i mean when u direct it to a wall it does not stop rather it goes through it and keep walking This is a school project and I am not a professional programmer!
Super_Hippo Super_Hippo

2016/12/1

#
Move, check for a wall - like 'if (isTouching(Wall.class))' - and move back if a Wall is found.
rkr rkr

2016/12/4

#
Here is a code the returns a boolean if what ever you want is at the edge of you world
 public boolean atWorldEdge(){
       
 if(getX() < 10 || getX() > getWorld().getWidth() - 10)
            return true;
        if(getY() < 10 || getY() > getWorld().getHeight() - 10)
            return true;
        else
            return false;
    }
Nosson1459 Nosson1459

2016/12/4

#
rkr wrote...
Here is a code the returns a boolean if what ever you want is at the edge of you world<Code Omitted>
That is for the World edge, what I think Roselina wants is checking for a wall collision of her maze walls. (
Roselina wrote...
I have designed a maze ... when u direct it to a wall it does not stop rather it goes through it and keep walking
)
rkr rkr

2016/12/4

#
true i didnt see the "maze" part lol
Nosson1459 Nosson1459

2016/12/4

#
rkr wrote...
true i didnt see the "maze" part lol
This discussion is from 2 days ago anyway.
You need to login to post a reply.