-
Notifications
You must be signed in to change notification settings - Fork 3
/
Level1Maze.java
89 lines (78 loc) · 2.35 KB
/
Level1Maze.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import greenfoot.*;
/**
* Write a description of class MyWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Level1Maze extends World
{
static GreenfootSound music4 = new GreenfootSound("level1.mp3");
/*the shape of tha map:
b:box,f:food,s:shuriken,n:naruto*/
String[] textMap = {
"bbbbbbbbbbbbbbbbbbbbbb",
"btbfs ffb",
"bdbb bb b bbbb f fb",
"b b fb b bf fbbbb",
"bf fb b b b fb",
"bbbbbbb bfb b bbb b",
"bfbfbfbffbbbfbf bfb b",
"b b b bbbb bbbbb b b b",
"bs b bfb",
"b b bbbbbbbbbbbb b bbb",
"b bfbf fb b n",
"b bbbf fbbbf fb bbb",
"b bfbbbbbfbbbb bbb bfb",
"bfs b",
"bbbbbbbbbbbbbbbbbbbbbb"
};
/**
* Constructor for objects of class MyWorld
*
*/
public Level1Maze()
{
super(22, 15, 40);
drawMap();
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void drawMap(){
for(int i=0;i < textMap.length;i++)
{
String mapLine =textMap[i];
for(int j=0;j<mapLine.length();j++)
{
char mapChar =mapLine.charAt(j);
int y=i;
int x=j;
switch(mapChar)
{
case 'b':
addObject(new MazeBlock(), x, y);
break;
case 'f':
addObject(new Food(), x, y);
break;
case 's':
addObject(new ShurikenWeapon(), x, y);
break;
case 'n':
addObject(new NarutoPlayer(), x, y);
break;
case 't':
addObject(new BoxTarget(), x, y);
break;
case 'd':
addObject(new Door(), x, y);
break;
default:
break;
}
}
}
}
}