-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHatiBeta.java
99 lines (96 loc) · 2.94 KB
/
HatiBeta.java
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class HatiBeta here.
*
* @Pyrozen (your name)
* @version (a version number or a date)
*/
public class HatiBeta extends RedHearts
{
public ZebraCross zc;
public HatiYellowBeta yh;
public int state = 3;
public int Hearts = 3;
public int cek = 0;
public int temp = 0;
GreenfootSound Hijau = new GreenfootSound("Green Light Effect.mp3");
GreenfootSound Merah = new GreenfootSound("Red Light Effect 2.mp3");
GreenfootSound Failed = new GreenfootSound("Game Audio.mp3");
public void act()
{
MyWorld.backgroundMusic.stop();
Failed.setVolume(30);
zc = (ZebraCross)getOneObjectAtOffset(0,-75, ZebraCross.class);
yh = (HatiYellowBeta)getOneObjectAtOffset(60,53, HatiYellowBeta.class);
if(zc != null)
{
state = zc.getState();
if(state == 1)
{
if(yh.getHearts() < 1)
{
state = 0;
}
}
}
else if (zc == null)
{
if(state == 0)
{
if(cek ==0 )
{
Hearts--;
Merah.play();
cek++;
}
if(Hearts == 2 )
{
if(cek == 1)
{
setImage("Hearts ++-.png");
cek--;
}
}
}
else if(Hearts == 1 )
{
if(cek == 1)
{
setImage("Hearts +--.png");
cek--;
}
}
else if(Hearts == 0 )
{
Playfield.backgroundMusic.stop();
if(cek == 1)
{
setImage("Hearts ---.png");
int count = 11;
int counter = 600;
int dly = 1;
for(int i = 0; i < 660;i++)
{
if(i % 60 == 0)
{
count--;
}
getWorld().showText("Back to Main Menu in "+ count + " second(s)", getWorld().getWidth()/2, getWorld().getHeight()/2);
Greenfoot.delay(dly);
if(i == 2)
Failed.playLoop();
if(i == 658)
Failed.stop();
if(i == 659)
{
Greenfoot.setWorld(new MyWorld());
}
}
cek--;
}
}
state = 3;
}
}
}