Hi Greenfoot-Community :)
Before you read, I'm a Java-Noob :D
I'm currently working on a game similiar to the game ''Simon''. I currently have a world called ''Simon'', and 4 actors: ''RedButton'',''YellowButton'',''GreenButton'' and ''Blue Button''.
Now I'm facing the problem, that I don't know how I can make the ''AI''/program light up the button, so I can follow.
Any help would be apreciated :)
(The same for the other buttons)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import greenfoot.*; import java.util.ArrayList; public class Simon extends World { public Simon() { super ( 600 , 600 , 1 ); addObject( new RedButton(), 420 , 179 ); addObject( new GreenButton(), 179 , 179 ); addObject( new YellowButton(), 179 , 420 ); addObject( new BlueButton(), 420 , 420 ); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.Date; public class RedButton extends Actor { int timer = 0 ; public void act() { if (Greenfoot.mouseClicked( this ) ) { Greenfoot.playSound( "PressButtonSound.mp3" ); setImage( "redpressed.png" ); Greenfoot.delay( 20 ); setImage( "red.png" ); } } } |