cd957a0842583ebc6f8fc5ec87bc353a60a6abfa
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;
62 new Thread(new Runnable() {
65 while (true) fluidUpdater();
72 public void resetRenderer() {
74 renderer
= new GameRenderer(320,
75 320 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
77 renderer
= new GameRenderer(480,
78 480 * ((float) GameScreen
.getHeight() / GameScreen
.getWidth()));
82 private boolean isAutoselectable(int x
, int y
) {
83 return (world
.getForeMap(x
, y
) > 0 &&
84 GameItems
.getBlock(world
.getForeMap(x
, y
)).hasCollision());
87 private void moveCursor() {
88 int pastX
= curX
, pastY
= curY
;
89 if (ctrlMode
== 0 && CaveGame
.TOUCH
) {
90 curX
= player
.getMapX();
91 if (player
.getDir() == 0) curX
--;
93 curY
= (int) (player
.pos
.y
+ player
.getWidth()) / 16;
94 if (!isAutoselectable(curX
, curY
)) {
97 if (!isAutoselectable(curX
, curY
)) {
100 if (!isAutoselectable(curX
, curY
)) {
101 if (player
.getDir() == 0) curX
++;
104 } else if (!CaveGame
.TOUCH
) {
105 curX
= (int) (Gdx
.input
.getX() *
106 (renderer
.getWidth() / GameScreen
.getWidth()) + renderer
.getCamX()) / 16;
107 curY
= (int) (Gdx
.input
.getY() *
108 (renderer
.getHeight() / GameScreen
.getHeight()) + renderer
.getCamY()) / 16;
109 if ((Gdx
.input
.getX() *
110 (renderer
.getWidth() / GameScreen
.getWidth()) + renderer
.getCamX()) < 0)
113 if (pastX
!= curX
|| pastY
!= curY
) blockDmg
= 0;
116 private void checkCursorBounds() {
117 if (curY
< 0) curY
= 0;
118 if (curY
>= world
.getHeight()) curY
= world
.getHeight() - 1;
120 if (curX
* 16 + 8 < player
.pos
.x
+ player
.getWidth() / 2)
122 if (curX
* 16 + 8 > player
.pos
.x
+ player
.getWidth() / 2)
127 private void updateFluids(int x
, int y
) {
128 if (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
, y
) != 8) {
129 if (world
.getForeMap(x
, y
) == 60) {
130 if (!GameItems
.isWater(world
.getForeMap(x
, y
- 1)))
131 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
132 } else if ((!GameItems
.isWater(world
.getForeMap(x
- 1, y
)) ||
133 (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
- 1, y
) >= world
.getForeMap(x
, y
))) &&
134 (!GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) ||
135 (GameItems
.isWater(world
.getForeMap(x
, y
)) && world
.getForeMap(x
+ 1, y
) >= world
.getForeMap(x
, y
)))) {
136 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
138 if (world
.getForeMap(x
, y
) > 63) world
.setForeMap(x
, y
, 0);
141 if (world
.getForeMap(x
, y
) == 8 || world
.getForeMap(x
, y
) == 60) {
142 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
143 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
144 world
.setForeMap(x
, y
+ 1, 60);
145 updateBlock(x
, y
+ 2);
146 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
147 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
148 else world
.setForeMap(x
, y
+ 1, 68);
149 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
150 if (world
.getForeMap(x
+ 1, y
) == 0 ||
151 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
152 (GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 61)) {
153 world
.setForeMap(x
+ 1, y
, 61);
154 updateBlock(x
+ 1, y
+ 1);
155 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
156 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
157 else world
.setForeMap(x
+ 1, y
, 68);
158 } else if (world
.getForeMap(x
+ 1, y
) == 61 && (world
.getForeMap(x
+ 2, y
) == 8 || world
.getForeMap(x
+ 2, y
) == 60))
159 world
.setForeMap(x
+ 1, y
, 8);
161 if (world
.getForeMap(x
- 1, y
) == 0 ||
162 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
163 (GameItems
.isWater(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 61)) {
164 world
.setForeMap(x
- 1, y
, 61);
165 updateBlock(x
- 1, y
+ 1);
166 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
167 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
168 else world
.setForeMap(x
- 1, y
, 68);
169 } else if (world
.getForeMap(x
- 1, y
) == 61 && (world
.getForeMap(x
- 2, y
) == 8 || world
.getForeMap(x
- 2, y
) == 60))
170 world
.setForeMap(x
- 1, y
, 8);
174 if (world
.getForeMap(x
, y
) == 61) {
175 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
176 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
177 world
.setForeMap(x
, y
+ 1, 60);
178 updateBlock(x
, y
+ 2);
179 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
180 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
181 else world
.setForeMap(x
, y
+ 1, 68);
182 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
183 if (world
.getForeMap(x
+ 1, y
) == 0 ||
184 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
185 (GameItems
.isWater(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 62)) {
186 world
.setForeMap(x
+ 1, y
, 62);
187 updateBlock(x
+ 1, y
+ 1);
188 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
189 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
190 else world
.setForeMap(x
+ 1, y
, 68);
193 if (world
.getForeMap(x
- 1, y
) == 0 ||
194 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
195 (GameItems
.isWater(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 62)) {
196 world
.setForeMap(x
- 1, y
, 62);
197 updateBlock(x
- 1, y
+ 1);
198 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
199 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
200 else world
.setForeMap(x
- 1, y
, 68);
205 if (world
.getForeMap(x
, y
) == 62) {
206 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
207 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
208 world
.setForeMap(x
, y
+ 1, 60);
209 updateBlock(x
, y
+ 2);
210 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
211 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
212 else world
.setForeMap(x
, y
+ 1, 68);
213 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
214 if (world
.getForeMap(x
+ 1, y
) == 0 ||
215 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
)))) {
216 world
.setForeMap(x
+ 1, y
, 63);
217 updateBlock(x
+ 1, y
+ 1);
218 } else if (GameItems
.isLava(world
.getForeMap(x
+ 1, y
))) {
219 if (world
.getForeMap(x
+ 1, y
) > 9) world
.setForeMap(x
+ 1, y
, 4);
220 else world
.setForeMap(x
+ 1, y
, 68);
223 if (world
.getForeMap(x
- 1, y
) == 0 ||
224 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
)))) {
225 world
.setForeMap(x
- 1, y
, 63);
226 updateBlock(x
- 1, y
+ 1);
227 } else if (GameItems
.isLava(world
.getForeMap(x
- 1, y
))) {
228 if (world
.getForeMap(x
- 1, y
) > 9) world
.setForeMap(x
- 1, y
, 4);
229 else world
.setForeMap(x
- 1, y
, 68);
234 if (world
.getForeMap(x
, y
) == 63) {
235 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 61 && world
.getForeMap(x
, y
+ 1) <= 63) ||
236 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
237 world
.setForeMap(x
, y
+ 1, 60);
238 updateBlock(x
, y
+ 2);
239 } else if (GameItems
.isLava(world
.getForeMap(x
, y
+ 1))) {
240 if (world
.getForeMap(x
, y
+ 1) > 9) world
.setForeMap(x
, y
+ 1, 4);
241 else world
.setForeMap(x
, y
+ 1, 68);
246 if (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
, y
) != 9) {
247 if (world
.getForeMap(x
, y
) == 64) {
248 if (!GameItems
.isLava(world
.getForeMap(x
, y
- 1)))
249 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
250 } else if ((!GameItems
.isLava(world
.getForeMap(x
, y
- 1))) &&
251 (!GameItems
.isLava(world
.getForeMap(x
- 1, y
)) ||
252 (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
- 1, y
) >= world
.getForeMap(x
, y
))) &&
253 (!GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) ||
254 (GameItems
.isLava(world
.getForeMap(x
, y
)) && world
.getForeMap(x
+ 1, y
) >= world
.getForeMap(x
, y
)))) {
255 world
.setForeMap(x
, y
, world
.getForeMap(x
, y
) + 1);
257 if (world
.getForeMap(x
, y
) > 67) world
.setForeMap(x
, y
, 0);
260 if (world
.getForeMap(x
, y
) == 9 || world
.getForeMap(x
, y
) == 64) {
261 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
262 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
263 world
.setForeMap(x
, y
+ 1, 64);
264 updateBlock(x
, y
+ 2);
265 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
266 world
.setForeMap(x
, y
+ 1, 1);
267 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
268 if (world
.getForeMap(x
+ 1, y
) == 0 ||
269 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
270 (GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 65)) {
271 world
.setForeMap(x
+ 1, y
, 65);
272 updateBlock(x
+ 1, y
+ 1);
273 } else if (GameItems
.isWater(world
.getForeMap(x
+ 1, y
))) {
274 world
.setForeMap(x
+ 1, y
, 1);
277 if (world
.getForeMap(x
- 1, y
) == 0 ||
278 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
279 (GameItems
.isLava(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 65)) {
280 world
.setForeMap(x
- 1, y
, 65);
281 updateBlock(x
- 1, y
+ 1);
282 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
283 world
.setForeMap(x
- 1, y
, 1);
288 if (world
.getForeMap(x
, y
) == 65) {
289 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
290 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
291 world
.setForeMap(x
, y
+ 1, 64);
292 updateBlock(x
, y
+ 2);
293 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
294 world
.setForeMap(x
, y
+ 1, 1);
295 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
296 if (world
.getForeMap(x
+ 1, y
) == 0 ||
297 (!GameItems
.getBlock(world
.getForeMap(x
+ 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
+ 1, y
))) ||
298 (GameItems
.isLava(world
.getForeMap(x
+ 1, y
)) && world
.getForeMap(x
+ 1, y
) > 66)) {
299 world
.setForeMap(x
+ 1, y
, 66);
300 updateBlock(x
+ 1, y
+ 1);
301 } else if (GameItems
.isWater(world
.getForeMap(x
+ 1, y
))) {
302 world
.setForeMap(x
+ 1, y
, 1);
305 if (world
.getForeMap(x
- 1, y
) == 0 ||
306 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
))) ||
307 (GameItems
.isLava(world
.getForeMap(x
- 1, y
)) && world
.getForeMap(x
- 1, y
) > 66)) {
308 world
.setForeMap(x
- 1, y
, 66);
309 updateBlock(x
- 1, y
+ 1);
310 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
311 world
.setForeMap(x
- 1, y
, 1);
316 if (world
.getForeMap(x
, y
) == 66) {
317 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
318 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
319 world
.setForeMap(x
, y
+ 1, 64);
320 updateBlock(x
, y
+ 2);
321 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
322 world
.setForeMap(x
, y
+ 1, 1);
323 } else if (GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
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);
332 if (world
.getForeMap(x
- 1, y
) == 0 ||
333 (!GameItems
.getBlock(world
.getForeMap(x
- 1, y
)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
- 1, y
)))) {
334 world
.setForeMap(x
- 1, y
, 67);
335 updateBlock(x
- 1, y
+ 1);
336 } else if (GameItems
.isWater(world
.getForeMap(x
- 1, y
))) {
337 world
.setForeMap(x
- 1, y
, 1);
342 if (world
.getForeMap(x
, y
) == 67) {
343 if (world
.getForeMap(x
, y
+ 1) == 0 || (world
.getForeMap(x
, y
+ 1) >= 65 && world
.getForeMap(x
, y
+ 1) <= 67) ||
344 (!GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision() && !GameItems
.isFluid(world
.getForeMap(x
, y
+ 1)))) {
345 world
.setForeMap(x
, y
+ 1, 64);
346 updateBlock(x
, y
+ 2);
347 } else if (GameItems
.isWater(world
.getForeMap(x
, y
+ 1))) {
348 world
.setForeMap(x
, y
+ 1, 1);
354 private void updateBlock(int x
, int y
) {
355 if (world
.getForeMap(x
, y
) == 10) {
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 FallingSand(x
* 16, y
* 16));
359 updateBlock(x
, y
- 1);
363 if (world
.getForeMap(x
, y
) == 11) {
364 if (world
.getForeMap(x
, y
+ 1) == 0 || !GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
365 world
.setForeMap(x
, y
, 0);
366 mobs
.add(new FallingGravel(x
* 16, y
* 16));
367 updateBlock(x
, y
- 1);
371 if (world
.getForeMap(x
, y
) > 0 && GameItems
.getBlock(world
.getForeMap(x
, y
)).requiresBlock()) {
372 if (world
.getForeMap(x
, y
+ 1) == 0 || !GameItems
.getBlock(world
.getForeMap(x
, y
+ 1)).hasCollision()) {
373 world
.destroyForeMap(x
, y
);
374 updateBlock(x
, y
- 1);
378 if (world
.getForeMap(x
, y
) == 2) {
379 if (world
.getForeMap(x
, y
- 1) > 0 && (GameItems
.getBlock(world
.getForeMap(x
, y
- 1)).hasCollision() ||
380 GameItems
.isFluid(world
.getForeMap(x
, y
- 1)))) {
381 world
.setForeMap(x
, y
, 3);
386 private void fluidUpdater() {
387 for (int y
= 0; y
< world
.getHeight(); y
++) {
388 for (int x
= (int) renderer
.getCamX() / 16 - 1; x
< (int) (renderer
.getCamX() + renderer
.getWidth()) / 16 + 1; x
++) {
394 void useItem(int x
, int y
, int id
, boolean bg
) {
396 if (GameItems
.getItem(id
).isBlock()) {
397 if (!bg
) world
.placeToForeground(x
, y
, GameItems
.getBlockIdByItemId(id
));
398 else world
.placeToBackground(x
, y
, GameItems
.getBlockIdByItemId(id
));
402 world
.placeToForeground(x
, y
, 8);
403 player
.inv
[player
.invSlot
] = 64;
406 world
.placeToForeground(x
, y
, 9);
407 player
.inv
[player
.invSlot
] = 64;
414 public void update(float delta
) {
416 for (int y
= UPD_Y
; y
< UPD_Y
+ 16; y
++)
417 for (int x
= UPD_X
; x
< UPD_X
+ 16; x
++) {
423 physics
.update(delta
);
427 if (isTouchDown
&& touchDownBtn
== Input
.Buttons
.LEFT
) {
428 if ((world
.getForeMap(curX
, curY
) > 0 && GameItems
.getBlock(world
.getForeMap(curX
, curY
)).getHp() >= 0) ||
429 (world
.getForeMap(curX
, curY
) == 0 &&
430 world
.getBackMap(curX
, curY
) > 0 &&
431 GameItems
.getBlock(world
.getBackMap(curX
, curY
)).getHp() >= 0)) {
432 if (player
.gameMode
== 0) {
434 if (world
.getForeMap(curX
, curY
) > 0) {
435 if (blockDmg
>= GameItems
.getBlock(world
.getForeMap(curX
, curY
)).getHp()) {
436 world
.destroyForeMap(curX
, curY
);
439 } else if (world
.getBackMap(curX
, curY
) > 0) {
440 if (blockDmg
>= GameItems
.getBlock(world
.getBackMap(curX
, curY
)).getHp()) {
441 world
.destroyBackMap(curX
, curY
);
446 if (world
.getForeMap(curX
, curY
) > 0) world
.placeToForeground(curX
, curY
, 0);
447 else if (world
.getBackMap(curX
, curY
) > 0) world
.placeToBackground(curX
, curY
, 0);
453 if (isTouchDown
&& TimeUtils
.timeSinceMillis(touchDownTime
) > 500) {
454 if (touchDownBtn
== Input
.Buttons
.RIGHT
) {
455 useItem(curX
, curY
, player
.inv
[player
.invSlot
], true);
457 } else if (touchDownY
< Assets
.invBar
.getRegionHeight() &&
458 touchDownX
> renderer
.getWidth() / 2 - Assets
.invBar
.getRegionWidth() / 2 &&
459 touchDownX
< renderer
.getWidth() / 2 + Assets
.invBar
.getRegionWidth() / 2) {
460 CaveGame
.STATE
= AppState
.GAME_CREATIVE_INV
;