JOSE The Robot.

JOSE the robot


w1win w23

This game is one that I made for my computer programming class I decided to go with a game that didn’t have very many rules but would be addicting due to the fact that you get sent back to the beginning every time you hit the red parts of the maze.

Play it

I recommend playing the game before you go on reading as it will help you to understand what i am talking about.

JOSE The Robot

Moving object

I started out by coding the “moving object” class witch controls most of the players movement and would have controlled other enemies if I had the it to put them in. in this class I used java color to stop the player if it touches the black sections, this turned out to be allot easier that making defined walls. i also used java color to send the player back to the beginning when it hit the red.

GreenfootImage v = getWorld().getBackground();
                Color d = v.getColorAt(getX(),getY());
                if(d.getRed() == 255 && d.getGreen() == 1 && d.getBlue() == 1)//sends the player back to the 
                //begining if it touches the red
                     Greenfoot.setWorld(new w1());

the player

The player class has the bulk of my code in it because it has most of  the gate and portal code in it witch together consist of about 56 if is a sample of what all the if statements look like.


Gate g = (Gate)getOneIntersectingObject(Gate.class); 
       GateVert v = (GateVert)getOneIntersectingObject(GateVert.class); 
       //this code send the player to the world that corrispond to the correct gate
       if(g != null) {
            if(g.warpLocation == 2)//if the gate is number 2 it sends it to world 2
               Greenfoot.setWorld(new w2(getX(),getY())); 

Creating the worlds

Creating the worlds was an easy and a hard task at the same time. having the color codes made it really easy to design the wolds because all I had to do was draw the pictures using java color. However making the gates line up with each other was a bit harder because each gate needed a specific if statement for it i had to draw out a map.


Also made little world cards to keep track of the gate numbers and portal numbers.


I had some problems with things along the way with the worlds color and just about everything else. When I started doing the color it took me a while to figure it out and I had to do a lot of research to find out how one of the things was the fact that I could not stop at the beginning of the black but after a few class periods i finally got it. another problem that I had was when I tried to change worlds I had to spawn my player on the other side of the corresponding gate but instead it would spawn me in one location so I had to somehow pass information from one class to another with this code.

public int warpLocation;
    public Gate(int n)
       warpLocation = n; 

And this code

public w1(int startX, int startY)

After all I had was a few minor things that I knocked out in a couple classes.


If you didnt play the game here is the link

Feel free to comment on this blog.

Leave a Reply

Your email address will not be published. Required fields are marked *