KrystalLo wrote...
Sorry, i'm not understanding anything. ...
Theirs a error with new gameOver, counter and go.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Pirate here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Pirate extends Actor
{
int moveBy = 3;
int iCounter =0;
int iHurt =1;
Counter myCounter;
private String direction = "right";
public Pirate(Counter myCounter){
setImage("pirate"+direction+iHurt+".png");
}
/**
* Act - do whatever the Pirate wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
//sounds & music gotten from http://freesound.org/
checkKeys();
setImage("pirate"+direction+iHurt+".png");
if (isTouching(Bomb.class)){
removeTouching(Bomb.class);
iHurt++;
Greenfoot.playSound("explode.wav");
setImage("pirate"+direction+iHurt+".png");
if(iHurt>3){
gameOver g = new gameOver();
g.addObject(myCounter, g.getWidth()/2, 80);
Greenfoot.setWorld(g);
}
}
if (isTouching(Coin.class))
{
Coin coin = (Coin)getOneIntersectingObject(Coin.class);
((Counter)getWorld().getObjects(Counter.class).get(0)).add(coin.getPoints());
getWorld().removeObject(coin);
Greenfoot.playSound("coins.wav");
}
}
private void checkKeys(){
if(Greenfoot.isKeyDown("right")){
direction = "right";
this.setLocation(getX()+moveBy,getY());
}
if (Greenfoot.isKeyDown("left")){
direction = "left";
this.setLocation(getX()-moveBy,getY());
}
}
}
public Pirate() {public Gameover()
{
super(659, 483, 1);
addObject(new Gameover1(), 350, 219);
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Pirate here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Pirate extends Actor
{
int moveBy = 3;
int iCounter =0;
int iHurt =1;
private String direction = "right";
(Actor)getWorld().getObjects(Counter.class).get(0)
public Pirate(){
new Pirate();
setImage("pirate"+direction+iHurt+".png");
}
/**
* Act - do whatever the Pirate wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
//sounds & music gotten from http://freesound.org/
checkKeys();
setImage("pirate"+direction+iHurt+".png");
if (isTouching(Bomb.class)){
removeTouching(Bomb.class);
iHurt++;
Greenfoot.playSound("explode.wav");
setImage("pirate"+direction+iHurt+".png");
if(iHurt>3){
gameOver g = new gameOver();
g.addObject(myCounter, g.getWidth()/2, 80);
Greenfoot.setWorld(g);
}
}
if (isTouching(Coin.class))
{
Coin coin = (Coin)getOneIntersectingObject(Coin.class);
((Counter)getWorld().getObjects(Counter.class).get(0)).add(coin.getPoints());
getWorld().removeObject(coin);
Greenfoot.playSound("coins.wav");
}
}
private void checkKeys(){
if(Greenfoot.isKeyDown("right")){
direction = "right";
this.setLocation(getX()+moveBy,getY());
}
if (Greenfoot.isKeyDown("left")){
direction = "left";
this.setLocation(getX()-moveBy,getY());
}
}
}