I'm trying to make a counter and watch this video https://www.youtube.com/watch?v=WIifij-961o and try to do the same
please help I need to finish this game before next week
here is my code
import greenfoot.*;
/**
* Write a description of class PinkCloud here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class PinkCloud extends Actor
{
private int points =0;
private Counter counter;
public PinkCloud(Counter pointCounter)
{
counter = pointCounter;
}
public void act()
{
move();
EatPinkMob();
}
void move()
{
if (Greenfoot.isKeyDown("w"))
{
setLocation(getX(),getY()-4);
}
if (Greenfoot.isKeyDown("s"))
{
setLocation(getX(),getY()+4);
}
if (Greenfoot.isKeyDown("a"))
{
setLocation(getX()-4,getY());
}
if (Greenfoot.isKeyDown("d"))
{
setLocation(getX()+4,getY());
}
}
void EatPinkMob()
{
if (isTouching(PinkMob.class))
{
removeTouching(PinkMob.class);
}
}
public void try2Eat()
{
if (canSee(PinkMob.class))
{
eat(PinkMob.class);
counter.add(1);
Greenfoot.playSound("slurp.wav");
}
}
}
