I am making a game like that of in snake.class
and notice line. it adds a score, but when it gets value`33` it should stop and show text "Congrats"
but the point is:What should we write for "getValue()"???
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo etc) public class Snake extends Actor { public void act() { MouseInfo pointer = Greenfoot.getMouseInfo(); if(pointer != null) { int mouseX = pointer.getX(); int mouseY = pointer.getY(); turnTowards(mouseX, mouseY); } move(5); if(isTouching(Food.class)) { removeTouching(Food.class); PryHabitat.counter.add(1); } } }
PryHabitat.counter.add(1);