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

Report as inappropriate.

programmer
programmer presents ...

2008/12/23

Bombfield -- 3 player game, homework assignment

This game is an example of how to make a 3-player game in Greenfoot. It uses 3 actors.


blue -- arrow keys
green -- asdw
orange(bomber) -- mouse
1 to drop bomb
If you are the bomber, try to wipe out the blue and green populations.
If you are blue or green, get away from the bombers bombs.

Notes:
This was a Greenfoot assignment for a 10-year-old.
The assignment was to take bomber2, by computers.fun, which is a 2-player game, and turn it into a 3-player game.
bomber2 is made from MultiplayerBomber, by patrik.

The 10-year-old, completed the assignment in about 30 minutes, and made many other changes based on his own ideas.

The assignment given to the 10-year-old was to add a third player.
He decided to use the mouse for the third player. He gave the 3rd player the ability to drop bombs, and took that ability away from the first 2 players.
He had to search around to find the code to add, but the code to use is provided on kidslike.info.

Here is the link for the assignment
http://www.kidslike.info/greenfoot_programming_assignment_take_a_2_player_game_and_turn_it_into_a_3_player_game
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"

Here is the link for the answer
http://www.kidslike.info/greenfoot_programming_assignment_answer_bomberfield_3_player_version

11153 views / 21 in the last 7 days

2 votes | 0 in the last 7 days

Tags: game demo with-source example basic made-by-kid

open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Tue Dec 23 19:45:39 UTC 2008
programmerprogrammer

2008/12/23

Greenfoot programmers. in Patrik's code, there is this line. What does it do? It seems to act like a comment. Removing it has no effect that I can see. BOMBEN--;
mjrb4mjrb4

2008/12/24

I would guess that BOMBEN is an int variable - the -- at the end of it is equivalent to doing BOMBEN = BOMBEN-1; It's certainly not a comment! It takes one from the value of BOMBEN and it's just a shorthand way of writing the above. Incidentally, you can do the same thing with ++ to add 1. Similarly, you could also do things like BOMBEN += 2; or BOMBEN -= 2; which would add and take 2 from the value of BOMBEN respectively.
programmerprogrammer

2008/12/24

mjrb4, thank you for explaining! that was it.
PatrikPatrik

2009/1/5

I used it in my programm code as a counter, to use it this way make you plant only one or two bombs before you can plant another one ((ger.) BOMBEN = (engl.) BOMBS). For explainig the "--" command you can use the describtion of mjrb4.

Want to leave a comment? You must first log in.

Who likes this?

Advenging computers.fun