-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEarthquake.java
More file actions
executable file
·42 lines (36 loc) · 1.06 KB
/
Earthquake.java
File metadata and controls
executable file
·42 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Earthquake Class
*
* @author Jimmy, Adrian, Daniel
* @version April 24, 2024
*/
public class Earthquake extends Event {
private GreenfootSound rumble = new GreenfootSound("rumble.wav");
private MainWorld mw;
private int actsLeft;
Label earthquakeText = new Label("", 40);
/** Constructor for Earthquake */
public Earthquake() {
changeIndex(-1, -3, -4);
actsLeft = 700;
setImage("CrackedStoneWallpaper.jpg");
}
public void act() {
// Add your action code here.
actsLeft--;
if (actsLeft == 0) {
rumble.stop();
getWorld().removeObject(this.earthquakeText);
getWorld().removeObject(this);
}
}
/**
* Adds label to the left side of the screen when an instance of Earthquake is added to the world
*/
public void addedToWorld(World MainWorld) {
rumble.play();
earthquakeText.setValue("An Earthquake approaches..." + "\nSI -1" + "\nEPR -3" + "\nCWI -4");
MainWorld.addObject(earthquakeText, 230, 360);
}
}