-
Notifications
You must be signed in to change notification settings - Fork 0
/
Playfield.java
69 lines (60 loc) · 1.91 KB
/
Playfield.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
/**
* Write a description of class Playfield here.
*
* @Pyrozen (your name)
* @version (a version number or a date)
*/
public class Playfield extends World
{
static GreenfootSound backgroundMusic = new GreenfootSound("InGame.mp3");
public long startTime = 0;
public Playfield()
{
super(350, 585, 1,false);
backgroundMusic.setVolume(30);
backgroundMusic.playLoop();
setPaintOrder(Back.class,RedHearts.class,YellowHearts.class,TopScreen.class,BottomScreen.class,Car.class,ZebraCross.class,Road.class);
prepare();
}
private TrafficLight TrafficLight;
public void prepare()
{
startTime = System.currentTimeMillis();
//Screen UI
TopScreen Atas = new TopScreen();
addObject(Atas,getWidth()/2,getHeight()-569);
BottomScreen Bawah = new BottomScreen();
addObject(Bawah,getWidth()/2,getHeight()-45);
//Hearts Red
HatiBeta Hati = new HatiBeta();
addObject(Hati,getWidth()/2,510);
//Hearts Yellow
HatiYellowBeta HatiYel = new HatiYellowBeta();
addObject(HatiYel,235,563);
//Car
Car mobil = new Car();
addObject(mobil,getWidth()/2,getHeight()-150);
//Moving Object
int y = getHeight()/2;
Road jalan = new Road();
addObject(jalan,getWidth()/2,y);
y = y - jalan.getImage().getHeight();
Road jalan2 = new Road();
addObject(jalan2, getWidth()/2,y);
GenerateLamp lamp = new GenerateLamp();
addObject(lamp, getWidth()/2,0-getHeight());
//Button
Back bck = new Back();
addObject(bck,300,15);
}
public long getStartTime()
{
return startTime;
}
public TrafficLight getCounter()
{
return TrafficLight;
}
}