-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMyWorld.java
141 lines (133 loc) · 4.11 KB
/
MyWorld.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class MyWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MyWorld extends World
{
public static messageBoard mb1;
public static soundPlayer spr;
public static Friends frnd1;
public static Wall wall;
Wall[] wallarrsub = new Wall[11];
Wall[] wallarrright = new Wall[10];
Wall[] wallarrleft = new Wall[10];
int posx = 1140;
int posy = 786;
int rposx = 1200;
int rposy = 800;
int lposx = 0;
int lposy = 800;
public static Character character;
/**
* Constructor for objects of class MyWorld.
*
*/
public MyWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1200, 800, 1);
setBackground("images/class_wall.jpg");
setWalls("sub");
setWalls("right");
setWalls("left");
Wall topLWall = new Wall();
Wall topRWall = new Wall();
addObject(topLWall, 0, 361 );
addObject(topRWall, 1200, 361 );
topLWall.setRotation(-90);
topRWall.setRotation(-90);
mb1 = new messageBoard();
addObject(mb1, 600, 70);
//endboss eb = new endboss();
//addObject(eb, 53, 482);
enemy nolde = new enemy();
addObject(nolde, 72, 500);
nolde.name="nolde";
nolde.setImg();
spr = new soundPlayer();
addObject(spr, 1140, 24);
frnd1 = new Friends();
addObject(frnd1, 100, 600);
//walls -----------------------------------------------
table table1 = new table();
addObject(table1, 500, 400);
chair chair1 = new chair();
addObject(chair1, 390, 400);
table table2 = new table();
addObject(table2, 500, 600);
chair chair2 = new chair();
addObject(chair2, 390, 600);
character = new Character("X");
addObject(character, 1130, 705);
}
public void setWalls(String x){
if(x == "sub"){
for(int i =0; i < 10; i++){
trumpMethodsub();
addObject(wallarrsub[i], posx, posy);
posx = posx - 120;
}
}
else if(x == "right"){
for(int i =0; i < 4; i++){
trumpMethodRight();
addObject(wallarrright[i], rposx, rposy);
wallarrright[i].setRotation(-90);
rposy = rposy - 120;
}
}
else if(x == "left"){
for(int i =0; i < 4; i++){
trumpMethodLeft();
addObject(wallarrleft[i], lposx, lposy);
wallarrleft[i].setRotation(-90);
lposy = lposy - 120;
}
}
}
public void trumpMethodsub(){
Wall wall = new Wall();
Wall wall1 = new Wall();
Wall wall2 = new Wall();
Wall wall3 = new Wall();
Wall wall4 = new Wall();
Wall wall5 = new Wall();
Wall wall6 = new Wall();
Wall wall7 = new Wall();
Wall wall8 = new Wall();
Wall wall9 = new Wall();
wallarrsub[0] = wall;
wallarrsub[1] = wall1;
wallarrsub[2] = wall2;
wallarrsub[3] = wall3;
wallarrsub[4] = wall4;
wallarrsub[5] = wall5;
wallarrsub[6] = wall6;
wallarrsub[7] = wall7;
wallarrsub[8] = wall8;
wallarrsub[9] = wall9;
}
public void trumpMethodRight(){
Wall wall10 = new Wall();
Wall wall11 = new Wall();
Wall wall12 = new Wall();
Wall wall13 = new Wall();
wallarrright[0] = wall10;
wallarrright[1] = wall11;
wallarrright[2] = wall12;
wallarrright[3] = wall13;
}
public void trumpMethodLeft(){
Wall wall14 = new Wall();
Wall wall15 = new Wall();
Wall wall16 = new Wall();
Wall wall17 = new Wall();
wallarrleft[0] = wall14;
wallarrleft[1] = wall15;
wallarrleft[2] = wall16;
wallarrleft[3] = wall17;
}
}