i've been working on this scenario... where the actor moves toward the mouse. And when you press space, the actor moves faster. I've decided to make the speed boost limited. I want it to have an energy bar and when you press space, the energy should decrease. And when you stand on an energy zone, they should increase the energy meter.
Heres my codeShould I edit it and create a new class for the meter? or should JUST create the new class for meter?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo etc) public class Sample extends Actor { public void act() { move(5); MouseInfo pointer = Greenfoot.getMouseInfo(); if(pointer != null) { int mouseX = pointer.getX(); int mouseY = pointer.getY(); turnTowards(mouseX, mouseY); int button = pointer.getButton(); } if(Greenfoot.isKeyDown("space")) { move(10); } } }