-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameFactory.java
214 lines (189 loc) · 8.31 KB
/
GameFactory.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package bomberman;
import bomberman.Entities.Bomber;
import bomberman.items.Bomb;
import bomberman.items.ItemType;
import com.almasb.fxgl.app.FXGL;
import com.almasb.fxgl.entity.*;
import com.almasb.fxgl.entity.components.CollidableComponent;
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.HitBox;
import javafx.util.Duration;
import static com.almasb.fxgl.app.DSLKt.texture;
public class GameFactory implements TextEntityFactory {
// LOAD PLAYER
@Spawns("Player")
public Entity newPlayer(SpawnData data) {
return Entities.builder()
.from(data)
.type(GameObject.PLAYER)
.bbox(new HitBox(BoundingShape.box(GameProperties.SIZE_TILES, GameProperties.SIZE_TILES)))
.with(new CollidableComponent(true))
.with(Bomber.getBomber())
.build();
}
// LOAD INIT WALL COMPONENT
@SpawnSymbol('#')
public Entity wall(SpawnData data) {
return Entities.builder()
.type(GameObject.WALL)
.from(data)
.renderLayer(RenderLayer.BACKGROUND)
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("wall.png", GameProperties.SIZE_TILES , GameProperties.SIZE_TILES ))
.build();
}
// LOAD INIT BRICK COMPONENT
@SpawnSymbol('*')
public Entity brick(SpawnData data) {
return Entities.builder()
.type(GameObject.BRICK)
.from(data)
.renderLayer(RenderLayer.BACKGROUND)
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("brick.png", GameProperties.SIZE_TILES , GameProperties.SIZE_TILES ))
.build();
}
// LOAD INIT GRASS COMPONENT
@SpawnSymbol(' ')
public Entity grass(SpawnData data) {
return Entities.builder()
.type(GameObject.GRASS)
.from(data)
.renderLayer(RenderLayer.BACKGROUND)
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("grass.png", GameProperties.SIZE_TILES , GameProperties.SIZE_TILES ))
.build();
}
@SpawnSymbol('p')
public Entity grassPlayer(SpawnData data) {
return Entities.builder()
.type(GameObject.GRASS)
.from(data)
.renderLayer(RenderLayer.BACKGROUND)
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("grass.jpg", GameProperties.SIZE_TILES , GameProperties.SIZE_TILES ))
.build();
}
// LOAD PORTAL COMPONENT
@SpawnSymbol('x')
public Entity portal(SpawnData data) {
return Entities.builder()
.type(GameObject.PORTAL)
.from(data)
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("portal.png", GameProperties.SIZE_TILES , GameProperties.SIZE_TILES ))
.with(new CollidableComponent(true))
.build();
}
// LOAD ITEM POWER UP
@SpawnSymbol('f')
public Entity newPowerUpBomb(SpawnData data) {
return Entities.builder()
.type(ItemType.POWERUPBOMB)
.from(data)
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("powerup_bombs.png", GameProperties.SIZE_TILES , GameProperties.SIZE_TILES ))
.with(new CollidableComponent(true))
.build();
}
// LOAD BOMB ITEM
@Spawns("Bomb")
public Entity newBomb(SpawnData data) {
return Entities.builder()
.type(GameObject.BOMB)
.from(data)
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("bomb.png", GameProperties.SIZE_TILES , GameProperties.SIZE_TILES ))
.with(new Bomb())
.build();
}
/*
@SpawnSymbol('1')
public Entity grass1(SpawnData data) {
return Entities.builder()
.type(BombermanType.ENEMY)
.from(data)
.bbox(new HitBox(BoundingShape.box(Game.SIZE_TILES, Game.SIZE_TILES)))
.with(new CollidableComponent(true))
.with(new EnemyBFS())
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("water1.png", Game.SIZE_TILES , Game.SIZE_TILES ))
.build();
} */
/*
@Spawns("Grass")
public Entity newGrass(SpawnData data) {
return Entities.builder()
.type(BombermanType.GRASS)
.from(data)
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("grass.jpg", Game.SIZE_TILES , Game.SIZE_TILES ))
.renderLayer(RenderLayer.BOTTOM)
.build();
} */
/*
@SpawnSymbol('2')
public Entity newEnemy(SpawnData data){
return Entities.builder()
.from(data)
.type(BombermanType.ENEMY)
.bbox(new HitBox(BoundingShape.box(Game.SIZE_TILES, Game.SIZE_TILES)))
.viewFromNodeWithBBox(FXGL.getAssetLoader().loadTexture("baloon1.png", Game.SIZE_TILES , Game.SIZE_TILES ))
.with(new CollidableComponent(true))
.with(new EnemyRandom())
.build();
} */
@Spawns("centerExplode")
public Entity newCenterExploe(SpawnData data){
return Entities.builder()
.type(GameObject.EXPLODE)
.from (data)
.bbox(new HitBox(BoundingShape.box(GameProperties.SIZE_TILES, GameProperties.SIZE_TILES)))
.viewFromAnimatedTexture(texture("centerExplode1.png", GameProperties.SIZE_TILES, GameProperties.SIZE_TILES).toAnimatedTexture(1, Duration.seconds(0.5)), false, true)
.with(new CollidableComponent(true))
.build();
}
@Spawns("topExplodeX")
public Entity newTopExploeX(SpawnData data){
return Entities.builder()
.type(GameObject.EXPLODE)
.from (data)
.bbox(new HitBox(BoundingShape.box(GameProperties.SIZE_TILES, GameProperties.SIZE_TILES)))
.viewFromAnimatedTexture(texture("topExplode1.png", GameProperties.SIZE_TILES , GameProperties.SIZE_TILES - 2).toAnimatedTexture(1, Duration.seconds(0.5)), false, true)
.with(new CollidableComponent(true))
.build();
}
@Spawns("topExplodeY")
public Entity newTopExploeY(SpawnData data){
return Entities.builder()
.type(GameObject.EXPLODE)
.from (data)
.bbox(new HitBox(BoundingShape.box(GameProperties.SIZE_TILES - 2, GameProperties.SIZE_TILES - 2)))
.viewFromAnimatedTexture(texture("topExplode2.png", GameProperties.SIZE_TILES, GameProperties.SIZE_TILES).toAnimatedTexture(1, Duration.seconds(0.5)), false, true)
.with(new CollidableComponent(true))
.build();
}
@Spawns("midExplodeX")
public Entity newMidExploeX(SpawnData data){
return Entities.builder()
.type(GameObject.EXPLODE)
.from (data)
.bbox(new HitBox(BoundingShape.box(GameProperties.SIZE_TILES, GameProperties.SIZE_TILES)))
.viewFromAnimatedTexture(texture("midExplode1.png", GameProperties.SIZE_TILES, GameProperties.SIZE_TILES).toAnimatedTexture(1, Duration.seconds(0.5)), false, true)
.with(new CollidableComponent(true))
.build();
}
@Spawns("midExplodeY")
public Entity newMidExploeY(SpawnData data){
return Entities.builder()
.type(GameObject.EXPLODE)
.from (data)
.bbox(new HitBox(BoundingShape.box(GameProperties.SIZE_TILES, GameProperties.SIZE_TILES)))
.viewFromAnimatedTexture(texture("midExplode2.png", GameProperties.SIZE_TILES, GameProperties.SIZE_TILES).toAnimatedTexture(1, Duration.seconds(0.5)), false, true)
.with(new CollidableComponent(true))
.build();
}
@Override
public char emptyChar() {
return ' ';
}
@Override
public int blockWidth() {
return GameProperties.SIZE_TILES;
}
@Override
public int blockHeight() {
return GameProperties.SIZE_TILES;
}
}