Greenfoot programming assignment answer -- bomberfield, 3 player version
Find other posts in the same category: | | |

Long description

Here is the answer for the assignment.

Under Animal2, add a new sub-class called bomber. Here is the code for bomber.

import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

* Write a description of class Bomber here.
* @author (your name)
* @version (a version number or a date)
public class Bomber extends Animal2
int BOMBEN = 20;
public void act()
if (Greenfoot.mouseMoved(null)) {
MouseInfo mouse = Greenfoot.getMouseInfo();
setLocation (mouse.getX(), mouse.getY());
if (Greenfoot.isKeyDown("1")& BOMBEN <= 0) {
getWorld().addObject(new Bombe(), getX(), getY());
BOMBEN = 20;

Previous page

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