danpost wrote...
Lavenger wrote...
line 52 should be before which line?import greenfoot.*; public class MyWorld extends World { // fields usually (by convention) go first GifImage gifImg = new GifImage("Umaru.gif"); private Actor TimeDisplay = new SimpleActor(); private Actor Cooldown = new SimpleActor(); private int frames; private int Cframes = (3+Greenfoot.getRandomNumber(4))*3300; public float AYen; //precise public int DYen; //rounded public Yen YenDisplay = new Yen(); public int getHeight = 552 ; public int getWidth = 1200 ; // class constructors usually (by convention) go next public void gifAnimation() { for (Object obj : gifImg.getImages()) ((GreenfootImage)obj).scale(getWidth(), getHeight()); setBackground(gifImg.getCurrentImage()); } public MyWorld() { //For building the world window size super(1400, 675, 1); //For updating the Yen Display adjustYen(0); // to initialize image prepare(); addObject(YenDisplay, 1265, 50); // wherever //For updating the time display updateTimeDisplay(); addObject(TimeDisplay, 1265, 20); //For triggering the minigame updateCoolDownDisplay(); addObject(Cooldown, 1265, 35); } // methods (by convention) go last //For GIF background public void act() { gifAnimation(); if ((++frames)%55 == 0) updateTimeDisplay(); if ((--Cframes)%55 == 0) updateCoolDownDisplay(); if (Cframes == 0) { Minigame(); Cframes += (3+Greenfoot.getRandomNumber(5)); //chooses a cooldown time between 3-7 minutes randomly } } //For Yen Display stuff public int getAccumulatedYen() { return DYen; } public void adjustYen(float adjustment) { AYen += adjustment; DYen = (int) AYen; YenDisplay.setImage(new GreenfootImage("Yen: "+DYen+"¥", 20, Color.BLACK, new Color(0, 0, 0, 0))); } //For Time Display stuff private void updateTimeDisplay() { int Time = frames/55; // total seconds int TotalMinutes = Time/60; // total minutes String hours = "0"+(TotalMinutes/60); // string total hours String minutes = "0"+(TotalMinutes%60); // string remaining minutes String seconds = "0"+(Time%60); // string remaining seconds String hrs = hours.substring(hours.length()-2); // hour output string String mins = minutes.substring(minutes.length()-2); // minutes output string String secs = seconds.substring(seconds.length()-2); // seconds output string String TimeFormat = "Time: "+hrs+"hrs "+mins+"mins "+secs+"secs"; //Preview: Time: 12345hrs 12mins 12secs TimeDisplay.setImage(new GreenfootImage(TimeFormat, 20, Color.BLACK, new Color(0, 0, 0, 0))); } //For Choosing the Minigame and timing the appearance of the Minigame private void updateCoolDownDisplay() { int Time = Cframes/55; String minutes = "0"+(Time/60); // string remaining minutes String seconds = "0"+(Time%60); // string remaining seconds String mins = minutes.substring(minutes.length()-2); // minutes output string String secs = seconds.substring(seconds.length()-2); // seconds output string String TimeFormat = "Minigame countdown: "+mins+"mins "+secs+"secs"; //Preview: Time: 12345hrs 12mins 12secs Cooldown.setImage(new GreenfootImage(TimeFormat, 20, Color.BLACK, new Color(0, 0, 0, 0))); } private void Minigame() { switch(Greenfoot.getRandomNumber(5)) { case 1:if (!getObjects(Taihei.class).isEmpty()) {Minigame1();} //Chases Kirie because Umaru placed Taihei's money in Kirie's pocket in secret and plans to get it later on break; case 2:if (!getObjects(Sylphynford.class).isEmpty()) {Minigame2();} //Plays a 2 player minigame to beat Sylphynord's new score as a challenge break; case 3:if (!getObjects(Ebina.class).isEmpty()) {Minigame3();} //Introduces Umaru to a fashion modeling job break; case 4:if (!getObjects(Kirie.class).isEmpty()) {Minigame4();} //Animal crossing minigame break; case 5:if (!getObjects(Taihei.class).isEmpty()) {Minigame5();} // break; } } private void Minigame1() { //to be implemented } private void Minigame2() { //to be implemented } private void Minigame3() { //to be implemented } private void Minigame4() { //to be implemented } private void Minigame5() { //to be implemented } //For placing actors into the world private void prepare() { addObject(new Umaru(), 700, 338); } }