1 package ru
.deadsoftware
.cavecraft
.game
;
3 import com
.badlogic
.gdx
.Gdx
;
5 public class GameWorld
{
7 private final int WIDTH
, HEIGHT
;
8 private int[][] foreMap
;
9 private int[][] backMap
;
11 public GameWorld(int w
, int h
) {
14 WorldGen
.genWorld(WIDTH
,HEIGHT
);
15 foreMap
= WorldGen
.getForeMap();
16 backMap
= WorldGen
.getBackMap();
20 public int getWidth() {
24 public int getHeight() {
28 public int getForeMap(int x
, int y
) {
32 } catch (ArrayIndexOutOfBoundsException e
) {
33 Gdx
.app
.error("GameWorld",e
.toString());
38 public void setForeMap(int x
, int y
, int value
) {
40 foreMap
[x
][y
] = value
;
41 } catch (ArrayIndexOutOfBoundsException e
) {
42 Gdx
.app
.error("GameWorld", e
.toString());
46 public int getBackMap(int x
, int y
) {
50 } catch (ArrayIndexOutOfBoundsException e
) {
51 Gdx
.app
.error("GameWorld",e
.toString());
56 public void setBackMap(int x
, int y
, int value
) {
58 backMap
[x
][y
] = value
;
59 } catch (ArrayIndexOutOfBoundsException e
) {
60 Gdx
.app
.error("GameWorld", e
.toString());
64 public void placeToForeground(int x
, int y
, int value
) {
65 if (getForeMap(x
,y
) == 0 || value
== 0) setForeMap(x
,y
,value
);
68 public void placeToBackground(int x
, int y
, int value
) {
69 if (getBackMap(x
,y
) == 0 || value
== 0) setBackMap(x
,y
,value
);