1 package ru
.deadsoftware
.cavecraft
.game
;
3 import com
.badlogic
.gdx
.Gdx
;
4 import com
.badlogic
.gdx
.Input
;
5 import com
.badlogic
.gdx
.utils
.TimeUtils
;
6 import ru
.deadsoftware
.cavecraft
.CaveGame
;
7 import ru
.deadsoftware
.cavecraft
.GameScreen
;
8 import ru
.deadsoftware
.cavecraft
.game
.mobs
.FallingGravel
;
9 import ru
.deadsoftware
.cavecraft
.game
.mobs
.FallingSand
;
10 import ru
.deadsoftware
.cavecraft
.game
.mobs
.Mob
;
11 import ru
.deadsoftware
.cavecraft
.game
.mobs
.Pig
;
12 import ru
.deadsoftware
.cavecraft
.game
.objects
.Drop
;
13 import ru
.deadsoftware
.cavecraft
.game
.objects
.Player
;
14 import ru
.deadsoftware
.cavecraft
.misc
.AppState
;
15 import ru
.deadsoftware
.cavecraft
.misc
.Assets
;
17 import java
.io
.Serializable
;
18 import java
.util
.ArrayList
;
20 public class GameProc
implements Serializable
{
22 static boolean DO_UPD
= false;
23 static int UPD_X
= -1, UPD_Y
= -1;
25 public transient GameWorld world
;
26 public transient GameRenderer renderer
;
27 public transient GamePhysics physics
;
30 public ArrayList
<Mob
> mobs
;
31 public ArrayList
<Drop
> drops
;
34 public boolean isTouchDown
, isKeyDown
;
35 public int ctrlMode
, touchDownX
, touchDownY
, touchDownBtn
, keyDownCode
;
36 public long touchDownTime
;
39 int creativeScroll
, maxCreativeScroll
;
43 public GameProc(int gameMode
) {
44 world
= new GameWorld();
45 world
.generate(1024, 256);
46 player
= new Player(world
, gameMode
);
47 drops
= new ArrayList
<Drop
>();
48 mobs
= new ArrayList
<Mob
>();
49 for (int i
= 0; i
< 16; i
++) {
50 mobs
.add(new Pig(i
* 256, 196 * 16));
52 physics
= new GamePhysics(this);
54 renderer
= new GameRenderer(this, 320,
55 320 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
58 renderer
= new GameRenderer(this, 480,
59 480 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
61 maxCreativeScroll
= GameItems
.getItemsSize() / 8;
65 public void resetRenderer() {
67 renderer
= new GameRenderer(this, 320,
68 320 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
70 renderer
= new GameRenderer(this, 480,
71 480 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
75 private boolean isAutoselectable(int x
, int y
) {
76 return (world
.getForeMap(x
, y
) > 0 &&
77 GameItems
.getBlock(world
.getForeMap(x
, y
)).hasCollision());
80 private void moveCursor() {
81 int pastX
= curX
, pastY
= curY
;
82 if (ctrlMode
== 0 && CaveGame
.TOUCH
) {
83 curX
= player
.getMapX();
84 if (player
.getDir() == 0) curX
--;
86 curY
= (int) (player
.pos
.y
+ player
.getWidth()) / 16;
87 if (!isAutoselectable(curX
, curY
)) {
90 if (!isAutoselectable(curX
, curY
)) {
93 if (!isAutoselectable(curX
, curY
)) {
94 if (player
.getDir() == 0) curX
++;
97 } else if (!CaveGame
.TOUCH
) {
98 curX
= (int) (Gdx
.input
.getX() *
99 (renderer
.getWidth() / GameScreen
.getWidth()) + renderer
.getCamX()) / 16;
100 curY
= (int) (Gdx
.input
.getY() *
101 (renderer
.getHeight() / GameScreen
.getHeight()) + renderer
.getCamY()) / 16;
102 if ((Gdx
.input
.getX() *
103 (renderer
.getWidth() / GameScreen
.getWidth()) + renderer
.getCamX()) < 0)
106 if (pastX
!= curX
|| pastY
!= curY
) blockDmg
= 0;
109 private void checkCursorBounds() {
110 if (curY
< 0) curY
= 0;
111 if (curY
>= world
.getHeight()) curY
= world
.getHeight() - 1;
113 if (curX
* 16 + 8 < player
.pos
.x
+ player
.getWidth() / 2)
115 if (curX
* 16 + 8 > player
.pos
.x
+ player
.getWidth() / 2)
120 private void updateFluids(int x
, int y
) {
121 if (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
, y
) != 8) {
122 if (world
.getForeMap(x
, y
) == 60) {
123 if (!GameItems
.isWater(world
.getForeMap(x
, y
- 1)))
124 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
125 } else if ((!GameItems
.isWater(world
.getForeMap(x
- 1, y
)) ||
126 (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
- 1, y
) >= world
.getForeMap(x
, y
))) &&
127 (!GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) ||
128 (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
+ 1, y
) >= world
.getForeMap(x
, y
)))) {
129 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
131 if (world
.getForeMap(x
, y
) > 63) world
.setForeMap(x
, y
, 0);
134 if (world
.getForeMap(x
, y
) == 8 || world
.getForeMap(x
, y
) == 60) {
135 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
136 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
137 world
.setForeMap(x
, y
+ 1, 60);
138 updateBlock(x
, y
+ 2);
139 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
140 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
141 else world
.setForeMap(x
, y
+ 1, 68);
142 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
143 if (world
.getForeMap(x
+ 1, y
) == 0 ||
144 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
145 (GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 61)) {
146 world
.setForeMap(x
+ 1, y
, 61);
147 updateBlock(x
+ 1, y
+ 1);
148 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
149 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
150 else world
.setForeMap(x
+ 1, y
, 68);
151 } else if (world
.getForeMap(x
+ 1, y
) == 61 && (world
.getForeMap(x
+ 2, y
) == 8 || world
.getForeMap(x
+ 2, y
) == 60))
152 world
.setForeMap(x
+ 1, y
, 8);
154 if (world
.getForeMap(x
- 1, y
) == 0 ||
155 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
156 (GameItems
.isWater(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 61)) {
157 world
.setForeMap(x
- 1, y
, 61);
158 updateBlock(x
- 1, y
+ 1);
159 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
160 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
161 else world
.setForeMap(x
- 1, y
, 68);
162 } else if (world
.getForeMap(x
- 1, y
) == 61 && (world
.getForeMap(x
- 2, y
) == 8 || world
.getForeMap(x
- 2, y
) == 60))
163 world
.setForeMap(x
- 1, y
, 8);
167 if (world
.getForeMap(x
, y
) == 61) {
168 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
169 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
170 world
.setForeMap(x
, y
+ 1, 60);
171 updateBlock(x
, y
+ 2);
172 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
173 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
174 else world
.setForeMap(x
, y
+ 1, 68);
175 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
176 if (world
.getForeMap(x
+ 1, y
) == 0 ||
177 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
178 (GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 62)) {
179 world
.setForeMap(x
+ 1, y
, 62);
180 updateBlock(x
+ 1, y
+ 1);
181 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
182 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
183 else world
.setForeMap(x
+ 1, y
, 68);
186 if (world
.getForeMap(x
- 1, y
) == 0 ||
187 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
188 (GameItems
.isWater(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 62)) {
189 world
.setForeMap(x
- 1, y
, 62);
190 updateBlock(x
- 1, y
+ 1);
191 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
192 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
193 else world
.setForeMap(x
- 1, y
, 68);
198 if (world
.getForeMap(x
, y
) == 62) {
199 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
200 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
201 world
.setForeMap(x
, y
+ 1, 60);
202 updateBlock(x
, y
+ 2);
203 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
204 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
205 else world
.setForeMap(x
, y
+ 1, 68);
206 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
207 if (world
.getForeMap(x
+ 1, y
) == 0 ||
208 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
)))) {
209 world
.setForeMap(x
+ 1, y
, 63);
210 updateBlock(x
+ 1, y
+ 1);
211 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
212 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
213 else world
.setForeMap(x
+ 1, y
, 68);
216 if (world
.getForeMap(x
- 1, y
) == 0 ||
217 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
)))) {
218 world
.setForeMap(x
- 1, y
, 63);
219 updateBlock(x
- 1, y
+ 1);
220 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
221 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
222 else world
.setForeMap(x
- 1, y
, 68);
227 if (world
.getForeMap(x
, y
) == 63) {
228 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
229 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
230 world
.setForeMap(x
, y
+ 1, 60);
231 updateBlock(x
, y
+ 2);
232 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
233 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
234 else world
.setForeMap(x
, y
+ 1, 68);
239 if (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
, y
) != 9) {
240 if (world
.getForeMap(x
, y
) == 64) {
241 if (!GameItems
.isLava(world
.getForeMap(x
, y
- 1)))
242 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
243 } else if ((!GameItems
.isLava(world
.getForeMap(x
, y
- 1))) &&
244 (!GameItems
.isLava(world
.getForeMap(x
- 1, y
)) ||
245 (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
- 1, y
) >= world
.getForeMap(x
, y
))) &&
246 (!GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) ||
247 (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
+ 1, y
) >= world
.getForeMap(x
, y
)))) {
248 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
250 if (world
.getForeMap(x
, y
) > 67) world
.setForeMap(x
, y
, 0);
253 if (world
.getForeMap(x
, y
) == 9 || world
.getForeMap(x
, y
) == 64) {
254 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
255 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
256 world
.setForeMap(x
, y
+ 1, 64);
257 updateBlock(x
, y
+ 2);
258 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
259 world
.setForeMap(x
, y
+ 1, 1);
260 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
261 if (world
.getForeMap(x
+ 1, y
) == 0 ||
262 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
263 (GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 65)) {
264 world
.setForeMap(x
+ 1, y
, 65);
265 updateBlock(x
+ 1, y
+ 1);
266 } else if (GameItems
.isWater(world
.getForeMap(x
+ 1, y
))) {
267 world
.setForeMap(x
+ 1, y
, 1);
270 if (world
.getForeMap(x
- 1, y
) == 0 ||
271 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
272 (GameItems
.isLava(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 65)) {
273 world
.setForeMap(x
- 1, y
, 65);
274 updateBlock(x
- 1, y
+ 1);
275 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
276 world
.setForeMap(x
- 1, y
, 1);
281 if (world
.getForeMap(x
, y
) == 65) {
282 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
283 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
284 world
.setForeMap(x
, y
+ 1, 64);
285 updateBlock(x
, y
+ 2);
286 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
287 world
.setForeMap(x
, y
+ 1, 1);
288 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
289 if (world
.getForeMap(x
+ 1, y
) == 0 ||
290 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
291 (GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 66)) {
292 world
.setForeMap(x
+ 1, y
, 66);
293 updateBlock(x
+ 1, y
+ 1);
294 } else if (GameItems
.isWater(world
.getForeMap(x
+ 1, y
))) {
295 world
.setForeMap(x
+ 1, y
, 1);
298 if (world
.getForeMap(x
- 1, y
) == 0 ||
299 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
300 (GameItems
.isLava(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 66)) {
301 world
.setForeMap(x
- 1, y
, 66);
302 updateBlock(x
- 1, y
+ 1);
303 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
304 world
.setForeMap(x
- 1, y
, 1);
309 if (world
.getForeMap(x
, y
) == 66) {
310 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
311 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
312 world
.setForeMap(x
, y
+ 1, 64);
313 updateBlock(x
, y
+ 2);
314 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
315 world
.setForeMap(x
, y
+ 1, 1);
316 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
317 if (world
.getForeMap(x
+ 1, y
) == 0 ||
318 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
)))) {
319 world
.setForeMap(x
+ 1, y
, 67);
320 updateBlock(x
+ 1, y
+ 1);
321 } else if (GameItems
.isWater(world
.getForeMap(x
+ 1, y
))) {
322 world
.setForeMap(x
+ 1, y
, 1);
325 if (world
.getForeMap(x
- 1, y
) == 0 ||
326 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
)))) {
327 world
.setForeMap(x
- 1, y
, 67);
328 updateBlock(x
- 1, y
+ 1);
329 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
330 world
.setForeMap(x
- 1, y
, 1);
335 if (world
.getForeMap(x
, y
) == 67) {
336 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
337 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
338 world
.setForeMap(x
, y
+ 1, 64);
339 updateBlock(x
, y
+ 2);
340 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
341 world
.setForeMap(x
, y
+ 1, 1);
347 private void updateBlock(int x
, int y
) {
348 if (world
.getForeMap(x
, y
) == 10) {
349 if (world
.getForeMap(x
, y
+ 1) == 0 || !GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
350 world
.setForeMap(x
, y
, 0);
351 mobs
.add(new FallingSand(x
* 16, y
* 16));
352 updateBlock(x
, y
- 1);
356 if (world
.getForeMap(x
, y
) == 11) {
357 if (world
.getForeMap(x
, y
+ 1) == 0 || !GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
358 world
.setForeMap(x
, y
, 0);
359 mobs
.add(new FallingGravel(x
* 16, y
* 16));
360 updateBlock(x
, y
- 1);
364 if (world
.getForeMap(x
, y
) > 0 && GameItems
.getBlock(world
.getForeMap(x
, y
)).requiresBlock()) {
365 if (world
.getForeMap(x
, y
+ 1) == 0 || !GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
366 world
.destroyForeMap(x
, y
, this);
367 updateBlock(x
, y
- 1);
371 if (world
.getForeMap(x
, y
) == 2) {
372 if (world
.getForeMap(x
, y
- 1) > 0 && (GameItems
.getBlock(world
.getForeMap(x
, y
- 1)).hasCollision() ||
373 GameItems
.isFluid(world
.getForeMap(x
, y
- 1)))) {
374 world
.setForeMap(x
, y
, 3);
379 void useItem(int x
, int y
, int id
, boolean bg
) {
380 if (id
> 0 && GameItems
.getItem(id
).getType() == 0) {
381 if (!bg
) world
.placeToForeground(x
, y
, GameItems
.getItem(id
).getBlock());
382 else world
.placeToBackground(x
, y
, GameItems
.getItem(id
).getBlock());
386 public void update(float delta
) {
388 for (int y
= UPD_Y
; y
< UPD_Y
+ 16; y
++)
389 for (int x
= UPD_X
; x
< UPD_X
+ 16; x
++) {
395 for (int y
= 0; y
< world
.getHeight(); y
++) {
396 for (int x
= (int) renderer
.getCamX() / 16 - 1; x
< (int) (renderer
.getCamX() + renderer
.getWidth()) / 16 + 1; x
++) {
401 physics
.update(delta
);
405 if (isTouchDown
&& touchDownBtn
== Input
.Buttons
.LEFT
) {
406 if ((world
.getForeMap(curX
, curY
) > 0 && GameItems
.getBlock(world
.getForeMap(curX
, curY
)).getHp() >= 0) ||
407 (world
.getForeMap(curX
, curY
) == 0 &&
408 world
.getBackMap(curX
, curY
) > 0 &&
409 GameItems
.getBlock(world
.getBackMap(curX
, curY
)).getHp() >= 0)) {
410 if (player
.gameMode
== 0) {
412 if (world
.getForeMap(curX
, curY
) > 0) {
413 if (blockDmg
>= GameItems
.getBlock(world
.getForeMap(curX
, curY
)).getHp()) {
414 world
.destroyForeMap(curX
, curY
, this);
417 } else if (world
.getBackMap(curX
, curY
) > 0) {
418 if (blockDmg
>= GameItems
.getBlock(world
.getBackMap(curX
, curY
)).getHp()) {
419 world
.destroyBackMap(curX
, curY
, this);
424 if (world
.getForeMap(curX
, curY
) > 0) world
.placeToForeground(curX
, curY
, 0);
425 else if (world
.getBackMap(curX
, curY
) > 0) world
.placeToBackground(curX
, curY
, 0);
431 if (isTouchDown
&& TimeUtils
.timeSinceMillis(touchDownTime
) > 500) {
432 if (touchDownBtn
== Input
.Buttons
.RIGHT
) {
433 useItem(curX
, curY
, player
.inv
[player
.invSlot
], true);
435 } else if (touchDownY
< Assets
.invBar
.getRegionHeight() &&
436 touchDownX
> renderer
.getWidth() / 2 - Assets
.invBar
.getRegionWidth() / 2 &&
437 touchDownX
< renderer
.getWidth() / 2 + Assets
.invBar
.getRegionWidth() / 2) {
438 CaveGame
.STATE
= AppState
.GAME_CREATIVE_INV
;