Ive been stuck here for a bit. I bet this is just an easy fix but I cant figure it out.
Thanks!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Shark2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Shark2 extends Animal
{
private GreenfootImage image1;
private GreenfootImage image2;
/**
* Act - do whatever the Shark wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public Shark2()
{
image1 = new GreenfootImage("Shark1.png");
image2 = new GreenfootImage("Shark2.png");
}
public void act()
{
change();
keyPress();
win();
diee();
}
public void change()
{
if (Greenfoot.isKeyDown("b"))
{
setImage(image2);
}
else
{
setImage(image1);
}
}
public void keyPress()
{
if (Greenfoot.isKeyDown("up"))
{
move(5);
}
if (Greenfoot.isKeyDown("right"))
{
turn(5);
}
if (Greenfoot.isKeyDown("down"))
{
move(-5);
}
if (Greenfoot.isKeyDown("left"))
{
turn(-5);
}
}
public void win()
{
if(isTouching(Checkpoint.class))
{
Greenfoot.playSound("fanfare.wav");
Greenfoot.stop();
}
}
public void diee()
{
if(isTouching(Block.class))
{
Greenfoot.stop();
//were I want the score to go up
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
public class Counter extends Actor
{
public static int score = 0;
public void act()
{
setImage(new GreenfootImage("Score : " + score,18, Color.GREEN,Color.BLACK));
}
}
//counter
