- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForestMap1.java
More file actions
Latest commit
74 lines (70 loc) · 2.06 KB
/
Copy pathForestMap1.java
File metadata and controls
74 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
74
importgreenfoot.*;
/**
* Write a description of class ForestMap1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
publicclassForestMap1extendsWorld
{
privateCharacterplayer;
privatejava.util.Randomgen;
privateGreenfootSoundbgm;
privateGreenfootImagebackground = newGreenfootImage("images/map/scene1.png");
/**
* Constructor for objects of class ForestMap1.
*
*/
publicForestMap1()
{
// 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, 11, 7);
Greenfoot.delay(15);
gen = newjava.util.Random();
bgm = newGreenfootSound("BGM/Forest1.mp3");
bgm.playLoop();
setBackground(background);
}
publicForestMap1(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, 300, 200);
gen = newjava.util.Random();
bgm = newGreenfootSound("BGM/Forest1.mp3");
bgm.playLoop();
setBackground(background);
}
publicvoidact()
{
if (player.hasMoved() && player.getY() == 0)
{
Greenfoot.delay(7);
Greenfoot.setWorld(newForestMap2(newCharacter(player.getX(), 7)));
bgm.stop();
}
elseif (player.hasMoved() && gen.nextFloat() <= 0.13)
{
Greenfoot.delay(7);
Greenfoot.setWorld(newForestBattle(player, Greenfoot.getRandomNumber(4)));
bgm.stop();
}
if (Greenfoot.isKeyDown("enter"))
{
Greenfoot.setWorld(newForestBattle(player, 3));
bgm.stop();
}
elseif (Greenfoot.isKeyDown("escape"))
{
Greenfoot.setWorld(newMainMenu());
bgm.stop();
}
}
}