Greenfoot programming assignment -- bomberfield -- take a 2 player game and turn it into a 3 player game
Find other posts in the same category: | | |

Long description

Here is a Greenfoot assignment.

Go to the bomberfighter2 game.
http://greenfootgallery.org/scenarios/516

Download the code.

1) Change the code so that you have 3 players. The third player will be a person who is controlled through the mouse.

The Greenfoot code for making an object go wherever the mouse goes is

if (Greenfoot.mouseMoved(null)) {
MouseInfo mouse = Greenfoot.getMouseInfo();
setLocation (mouse.getX(), mouse.getY());
}

2) Now add some code so that the third player can drop a bomb by hitting the number key "1"
The code for dropping a bomb is this

if (Greenfoot.isKeyDown("q")& BOMBEN <= 0) {
getWorld().addObject(new Bombe(), getX(), getY());
BOMBEN = 20;
}


Next page

To see articles on the same topic, click the links below the name of the author at the top of this page.