-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCar.java
39 lines (39 loc) · 993 Bytes
/
Car.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Car here.
*
* @Pyrozen (your name)
* @version (a version number or a date)
*/
public class Car extends Actor
{
public int i=0;
public int state = 0;
public int score = 0;
public ZebraCross zc;
GreenfootSound Hijau = new GreenfootSound("Green Light Effect.mp3");
GreenfootSound Merah = new GreenfootSound("Red Light Effect 2.mp3");
public void act()
{
zc = (ZebraCross)getOneObjectAtOffset(0,0, ZebraCross.class);
getWorld().showText("Score : "+score, 50, 15);
if(zc != null)
{
state = zc.getState();
}
else if (zc == null)
{
if(state == 2)
{
score++;
Hijau.play();
state = 0;
}
}
}
public int getScore()
{
return score;
}
}