1 package ru
.deadsoftware
.cavedroid
.game
;
3 import com
.badlogic
.gdx
.Gdx
;
4 import com
.badlogic
.gdx
.Input
;
5 import com
.badlogic
.gdx
.utils
.TimeUtils
;
6 import ru
.deadsoftware
.cavedroid
.CaveGame
;
7 import ru
.deadsoftware
.cavedroid
.GameScreen
;
8 import ru
.deadsoftware
.cavedroid
.game
.mobs
.FallingGravel
;
9 import ru
.deadsoftware
.cavedroid
.game
.mobs
.FallingSand
;
10 import ru
.deadsoftware
.cavedroid
.game
.mobs
.Mob
;
11 import ru
.deadsoftware
.cavedroid
.game
.mobs
.Pig
;
12 import ru
.deadsoftware
.cavedroid
.game
.objects
.Drop
;
13 import ru
.deadsoftware
.cavedroid
.game
.objects
.Player
;
14 import ru
.deadsoftware
.cavedroid
.misc
.AppState
;
15 import ru
.deadsoftware
.cavedroid
.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
;
42 public void initGame(int gameMode
) {
43 world
= new GameWorld();
44 world
.generate(1024, 256);
45 player
= new Player(gameMode
);
46 drops
= new ArrayList
<Drop
>();
47 mobs
= new ArrayList
<Mob
>();
48 for (int i
= 0; i
< 16; i
++) {
49 mobs
.add(new Pig(i
* 256, 196 * 16));
51 physics
= new GamePhysics();
53 renderer
= new GameRenderer(320,
54 320 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
57 renderer
= new GameRenderer(480,
58 480 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
60 maxCreativeScroll
= GameItems
.getItemsSize() / 8;
64 public void resetRenderer() {
66 renderer
= new GameRenderer(320,
67 320 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
69 renderer
= new GameRenderer(480,
70 480 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
74 private boolean isAutoselectable(int x
, int y
) {
75 return (world
.getForeMap(x
, y
) > 0 &&
76 GameItems
.getBlock(world
.getForeMap(x
, y
)).hasCollision());
79 private void moveCursor() {
80 int pastX
= curX
, pastY
= curY
;
81 if (ctrlMode
== 0 && CaveGame
.TOUCH
) {
82 curX
= player
.getMapX();
83 if (player
.getDir() == 0) curX
--;
85 curY
= (int) (player
.pos
.y
+ player
.getWidth()) / 16;
86 if (!isAutoselectable(curX
, curY
)) {
89 if (!isAutoselectable(curX
, curY
)) {
92 if (!isAutoselectable(curX
, curY
)) {
93 if (player
.getDir() == 0) curX
++;
96 } else if (!CaveGame
.TOUCH
) {
97 curX
= (int) (Gdx
.input
.getX() *
98 (renderer
.getWidth() / GameScreen
.getWidth()) + renderer
.getCamX()) / 16;
99 curY
= (int) (Gdx
.input
.getY() *
100 (renderer
.getHeight() / GameScreen
.getHeight()) + renderer
.getCamY()) / 16;
101 if ((Gdx
.input
.getX() *
102 (renderer
.getWidth() / GameScreen
.getWidth()) + renderer
.getCamX()) < 0)
105 if (pastX
!= curX
|| pastY
!= curY
) blockDmg
= 0;
108 private void checkCursorBounds() {
109 if (curY
< 0) curY
= 0;
110 if (curY
>= world
.getHeight()) curY
= world
.getHeight() - 1;
112 if (curX
* 16 + 8 < player
.pos
.x
+ player
.getWidth() / 2)
114 if (curX
* 16 + 8 > player
.pos
.x
+ player
.getWidth() / 2)
119 private void updateFluids(int x
, int y
) {
120 if (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
, y
) != 8) {
121 if (world
.getForeMap(x
, y
) == 60) {
122 if (!GameItems
.isWater(world
.getForeMap(x
, y
- 1)))
123 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
124 } else if ((!GameItems
.isWater(world
.getForeMap(x
- 1, y
)) ||
125 (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
- 1, y
) >= world
.getForeMap(x
, y
))) &&
126 (!GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) ||
127 (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
+ 1, y
) >= world
.getForeMap(x
, y
)))) {
128 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
130 if (world
.getForeMap(x
, y
) > 63) world
.setForeMap(x
, y
, 0);
133 if (world
.getForeMap(x
, y
) == 8 || world
.getForeMap(x
, y
) == 60) {
134 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
135 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
136 world
.setForeMap(x
, y
+ 1, 60);
137 updateBlock(x
, y
+ 2);
138 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
139 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
140 else world
.setForeMap(x
, y
+ 1, 68);
141 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
142 if (world
.getForeMap(x
+ 1, y
) == 0 ||
143 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
144 (GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 61)) {
145 world
.setForeMap(x
+ 1, y
, 61);
146 updateBlock(x
+ 1, y
+ 1);
147 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
148 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
149 else world
.setForeMap(x
+ 1, y
, 68);
150 } else if (world
.getForeMap(x
+ 1, y
) == 61 && (world
.getForeMap(x
+ 2, y
) == 8 || world
.getForeMap(x
+ 2, y
) == 60))
151 world
.setForeMap(x
+ 1, y
, 8);
153 if (world
.getForeMap(x
- 1, y
) == 0 ||
154 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
155 (GameItems
.isWater(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 61)) {
156 world
.setForeMap(x
- 1, y
, 61);
157 updateBlock(x
- 1, y
+ 1);
158 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
159 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
160 else world
.setForeMap(x
- 1, y
, 68);
161 } else if (world
.getForeMap(x
- 1, y
) == 61 && (world
.getForeMap(x
- 2, y
) == 8 || world
.getForeMap(x
- 2, y
) == 60))
162 world
.setForeMap(x
- 1, y
, 8);
166 if (world
.getForeMap(x
, y
) == 61) {
167 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
168 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
169 world
.setForeMap(x
, y
+ 1, 60);
170 updateBlock(x
, y
+ 2);
171 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
172 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
173 else world
.setForeMap(x
, y
+ 1, 68);
174 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
175 if (world
.getForeMap(x
+ 1, y
) == 0 ||
176 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
177 (GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 62)) {
178 world
.setForeMap(x
+ 1, y
, 62);
179 updateBlock(x
+ 1, y
+ 1);
180 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
181 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
182 else world
.setForeMap(x
+ 1, y
, 68);
185 if (world
.getForeMap(x
- 1, y
) == 0 ||
186 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
187 (GameItems
.isWater(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 62)) {
188 world
.setForeMap(x
- 1, y
, 62);
189 updateBlock(x
- 1, y
+ 1);
190 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
191 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
192 else world
.setForeMap(x
- 1, y
, 68);
197 if (world
.getForeMap(x
, y
) == 62) {
198 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
199 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
200 world
.setForeMap(x
, y
+ 1, 60);
201 updateBlock(x
, y
+ 2);
202 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
203 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
204 else world
.setForeMap(x
, y
+ 1, 68);
205 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
206 if (world
.getForeMap(x
+ 1, y
) == 0 ||
207 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
)))) {
208 world
.setForeMap(x
+ 1, y
, 63);
209 updateBlock(x
+ 1, y
+ 1);
210 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
211 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
212 else world
.setForeMap(x
+ 1, y
, 68);
215 if (world
.getForeMap(x
- 1, y
) == 0 ||
216 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
)))) {
217 world
.setForeMap(x
- 1, y
, 63);
218 updateBlock(x
- 1, y
+ 1);
219 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
220 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
221 else world
.setForeMap(x
- 1, y
, 68);
226 if (world
.getForeMap(x
, y
) == 63) {
227 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
228 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
229 world
.setForeMap(x
, y
+ 1, 60);
230 updateBlock(x
, y
+ 2);
231 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
232 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
233 else world
.setForeMap(x
, y
+ 1, 68);
238 if (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
, y
) != 9) {
239 if (world
.getForeMap(x
, y
) == 64) {
240 if (!GameItems
.isLava(world
.getForeMap(x
, y
- 1)))
241 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
242 } else if ((!GameItems
.isLava(world
.getForeMap(x
, y
- 1))) &&
243 (!GameItems
.isLava(world
.getForeMap(x
- 1, y
)) ||
244 (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
- 1, y
) >= world
.getForeMap(x
, y
))) &&
245 (!GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) ||
246 (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
+ 1, y
) >= world
.getForeMap(x
, y
)))) {
247 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
249 if (world
.getForeMap(x
, y
) > 67) world
.setForeMap(x
, y
, 0);
252 if (world
.getForeMap(x
, y
) == 9 || world
.getForeMap(x
, y
) == 64) {
253 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
254 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
255 world
.setForeMap(x
, y
+ 1, 64);
256 updateBlock(x
, y
+ 2);
257 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
258 world
.setForeMap(x
, y
+ 1, 1);
259 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
260 if (world
.getForeMap(x
+ 1, y
) == 0 ||
261 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
262 (GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 65)) {
263 world
.setForeMap(x
+ 1, y
, 65);
264 updateBlock(x
+ 1, y
+ 1);
265 } else if (GameItems
.isWater(world
.getForeMap(x
+ 1, y
))) {
266 world
.setForeMap(x
+ 1, y
, 1);
269 if (world
.getForeMap(x
- 1, y
) == 0 ||
270 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
271 (GameItems
.isLava(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 65)) {
272 world
.setForeMap(x
- 1, y
, 65);
273 updateBlock(x
- 1, y
+ 1);
274 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
275 world
.setForeMap(x
- 1, y
, 1);
280 if (world
.getForeMap(x
, y
) == 65) {
281 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
282 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
283 world
.setForeMap(x
, y
+ 1, 64);
284 updateBlock(x
, y
+ 2);
285 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
286 world
.setForeMap(x
, y
+ 1, 1);
287 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
288 if (world
.getForeMap(x
+ 1, y
) == 0 ||
289 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
290 (GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 66)) {
291 world
.setForeMap(x
+ 1, y
, 66);
292 updateBlock(x
+ 1, y
+ 1);
293 } else if (GameItems
.isWater(world
.getForeMap(x
+ 1, y
))) {
294 world
.setForeMap(x
+ 1, y
, 1);
297 if (world
.getForeMap(x
- 1, y
) == 0 ||
298 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
299 (GameItems
.isLava(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 66)) {
300 world
.setForeMap(x
- 1, y
, 66);
301 updateBlock(x
- 1, y
+ 1);
302 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
303 world
.setForeMap(x
- 1, y
, 1);
308 if (world
.getForeMap(x
, y
) == 66) {
309 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
310 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
311 world
.setForeMap(x
, y
+ 1, 64);
312 updateBlock(x
, y
+ 2);
313 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
314 world
.setForeMap(x
, y
+ 1, 1);
315 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
316 if (world
.getForeMap(x
+ 1, y
) == 0 ||
317 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
)))) {
318 world
.setForeMap(x
+ 1, y
, 67);
319 updateBlock(x
+ 1, y
+ 1);
320 } else if (GameItems
.isWater(world
.getForeMap(x
+ 1, y
))) {
321 world
.setForeMap(x
+ 1, y
, 1);
324 if (world
.getForeMap(x
- 1, y
) == 0 ||
325 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
)))) {
326 world
.setForeMap(x
- 1, y
, 67);
327 updateBlock(x
- 1, y
+ 1);
328 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
329 world
.setForeMap(x
- 1, y
, 1);
334 if (world
.getForeMap(x
, y
) == 67) {
335 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
336 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
337 world
.setForeMap(x
, y
+ 1, 64);
338 updateBlock(x
, y
+ 2);
339 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
340 world
.setForeMap(x
, y
+ 1, 1);
346 private void updateBlock(int x
, int y
) {
347 if (world
.getForeMap(x
, y
) == 10) {
348 if (world
.getForeMap(x
, y
+ 1) == 0 || !GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
349 world
.setForeMap(x
, y
, 0);
350 mobs
.add(new FallingSand(x
* 16, y
* 16));
351 updateBlock(x
, y
- 1);
355 if (world
.getForeMap(x
, y
) == 11) {
356 if (world
.getForeMap(x
, y
+ 1) == 0 || !GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
357 world
.setForeMap(x
, y
, 0);
358 mobs
.add(new FallingGravel(x
* 16, y
* 16));
359 updateBlock(x
, y
- 1);
363 if (world
.getForeMap(x
, y
) > 0 && GameItems
.getBlock(world
.getForeMap(x
, y
)).requiresBlock()) {
364 if (world
.getForeMap(x
, y
+ 1) == 0 || !GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
365 world
.destroyForeMap(x
, y
, this);
366 updateBlock(x
, y
- 1);
370 if (world
.getForeMap(x
, y
) == 2) {
371 if (world
.getForeMap(x
, y
- 1) > 0 && (GameItems
.getBlock(world
.getForeMap(x
, y
- 1)).hasCollision() ||
372 GameItems
.isFluid(world
.getForeMap(x
, y
- 1)))) {
373 world
.setForeMap(x
, y
, 3);
378 void useItem(int x
, int y
, int id
, boolean bg
) {
380 switch (GameItems
.getItem(id
).getType()) {
382 if (!bg
) world
.placeToForeground(x
, y
, GameItems
.getItem(id
).getBlock());
383 else world
.placeToBackground(x
, y
, GameItems
.getItem(id
).getBlock());
388 world
.placeToForeground(x
, y
, 8);
389 player
.inv
[player
.invSlot
] = 64;
392 world
.placeToForeground(x
, y
, 9);
393 player
.inv
[player
.invSlot
] = 64;
401 public void update(float delta
) {
403 for (int y
= UPD_Y
; y
< UPD_Y
+ 16; y
++)
404 for (int x
= UPD_X
; x
< UPD_X
+ 16; x
++) {
410 for (int y
= 0; y
< world
.getHeight(); y
++) {
411 for (int x
= (int) renderer
.getCamX() / 16 - 1; x
< (int) (renderer
.getCamX() + renderer
.getWidth()) / 16 + 1; x
++) {
416 physics
.update(delta
);
420 if (isTouchDown
&& touchDownBtn
== Input
.Buttons
.LEFT
) {
421 if ((world
.getForeMap(curX
, curY
) > 0 && GameItems
.getBlock(world
.getForeMap(curX
, curY
)).getHp() >= 0) ||
422 (world
.getForeMap(curX
, curY
) == 0 &&
423 world
.getBackMap(curX
, curY
) > 0 &&
424 GameItems
.getBlock(world
.getBackMap(curX
, curY
)).getHp() >= 0)) {
425 if (player
.gameMode
== 0) {
427 if (world
.getForeMap(curX
, curY
) > 0) {
428 if (blockDmg
>= GameItems
.getBlock(world
.getForeMap(curX
, curY
)).getHp()) {
429 world
.destroyForeMap(curX
, curY
, this);
432 } else if (world
.getBackMap(curX
, curY
) > 0) {
433 if (blockDmg
>= GameItems
.getBlock(world
.getBackMap(curX
, curY
)).getHp()) {
434 world
.destroyBackMap(curX
, curY
, this);
439 if (world
.getForeMap(curX
, curY
) > 0) world
.placeToForeground(curX
, curY
, 0);
440 else if (world
.getBackMap(curX
, curY
) > 0) world
.placeToBackground(curX
, curY
, 0);
446 if (isTouchDown
&& TimeUtils
.timeSinceMillis(touchDownTime
) > 500) {
447 if (touchDownBtn
== Input
.Buttons
.RIGHT
) {
448 useItem(curX
, curY
, player
.inv
[player
.invSlot
], true);
450 } else if (touchDownY
< Assets
.invBar
.getRegionHeight() &&
451 touchDownX
> renderer
.getWidth() / 2 - Assets
.invBar
.getRegionWidth() / 2 &&
452 touchDownX
< renderer
.getWidth() / 2 + Assets
.invBar
.getRegionWidth() / 2) {
453 CaveGame
.STATE
= AppState
.GAME_CREATIVE_INV
;