-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevel2.java
51 lines (40 loc) · 1.21 KB
/
Level2.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
import greenfoot.*;
/**
* Write a description of class Level2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Level2 extends Levels
{
private Counter score;
public Level2(Boy player)
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
addObject(new Grass(), 310, 575);
addObject(player, 50, 60);
score = player.getMyScore();
addObject( score, 535, 34 );
addObject(new Platform2(), 25, getHeight()/2);
addObject(new Platform2(), 575, getHeight()/2);
addObject(new Platform2(), 200, 153);
addObject(new Platform2(), 400, 153);
addObject(new Platform2(), 200, 430);
addObject(new Platform2(), 400, 430);
addObject(new HorPlatform(), getWidth()/2, getHeight()/2);
super.addMoney();
addObject(new Tree(), 550, 525);
addObject(new Rock(), getWidth()/2, 0);
}
public void act()
{
addRocks();
super.act();
}
public void addRocks()
{
if(Greenfoot.getRandomNumber(1000)<5) {
addObject(new Rock(), Greenfoot.getRandomNumber(getWidth()), 0);
}
}
}