- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForestMap2.java
More file actions
Latest commit
73 lines (70 loc) · 2.06 KB
/
Copy pathForestMap2.java
File metadata and controls
73 lines (70 loc) · 2.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
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
importgreenfoot.*;
/**
* Write a description of class ForestMap2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
publicclassForestMap2extendsWorld
{
privateCharacterplayer;
privatejava.util.Randomgen;
privateGreenfootSoundbgm;
privateGreenfootImagebackground = newGreenfootImage("images/map/scene2.png");
/**
* Constructor for objects of class ForestMap2.
*
*/
publicForestMap2()
{
// Create a new world with 12x8 cells with a cell size of 50x50 pixels.
super(12, 8, 50);
background.scale(678, 432);
player = newCharacter(11, 7);
addObject(player, 0, 0);
Greenfoot.delay(15);
gen = newjava.util.Random();
bgm = newGreenfootSound("BGM/Mansion1.mp3");
bgm.playLoop();
setBackground(background);
}
publicForestMap2(Characterc)
{
// Create a new world with 12x8 cells with a cell size of 50x50 pixels.
super(12, 8, 50);
background.scale(678, 432);
player = c;
player.setMovable(true);
player.exploreReady();
addObject(player, 0,0);
gen = newjava.util.Random();
bgm = newGreenfootSound("BGM/Mansion1.mp3");
bgm.playLoop();
setBackground(background);
}
publicvoidact()
{
if (player.hasMoved() && player.getY() == 7)
{
Greenfoot.delay(7);
Greenfoot.setWorld(newForestMap1(newCharacter(player.getX(), 0)));
bgm.stop();
}
elseif (player.hasMoved() && gen.nextFloat() <= 0.20)
{
Greenfoot.delay(7);
Greenfoot.setWorld(newMansionBattle(player, Greenfoot.getRandomNumber(4)));
bgm.stop();
}
if (Greenfoot.isKeyDown("enter"))
{
Greenfoot.setWorld(newMansionBattle(player, 3));
bgm.stop();
}
elseif (Greenfoot.isKeyDown("escape"))
{
Greenfoot.setWorld(newMainMenu());
bgm.stop();
}
}
}