diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java
index ab89dd78d2b423c022e448145a266bdc0cb256bf..064eca58ffa72052a0b6afd0695aea1772c159c2 100644 (file)
int map = 0;
try {
if (x<0) {
- x = x % (getWidth()-1)-1;
+ x = x % (getWidth());
x = getWidth()- Math.abs(x);
} else if (x>0) {
- x = x % (getWidth()-1)+1;
+ x = x % (getWidth());
}
map = foreMap[x][y];
} catch (ArrayIndexOutOfBoundsException e) {
public void setForeMap(int x, int y, int value) {
try {
if (x<0) {
- x = x % (getWidth()-1)-1;
+ x = x % (getWidth());
x = getWidth()- Math.abs(x);
} else if (x>0) {
- x = x % (getWidth()-1)+1;
+ x = x % (getWidth());
}
foreMap[x][y] = value;
} catch (ArrayIndexOutOfBoundsException e) {
int map = 0;
try {
if (x<0) {
- x = x % (getWidth()-1)-1;
+ x = x % (getWidth());
x = getWidth()- Math.abs(x);
} else if (x>0) {
- x = x % (getWidth()-1)+1;
+ x = x % (getWidth());
}
map = backMap[x][y];
} catch (ArrayIndexOutOfBoundsException e) {
public void setBackMap(int x, int y, int value) {
try {
if (x<0) {
- x = x % (getWidth()-1)-1;
+ x = x % (getWidth());
x = getWidth()- Math.abs(x);
} else if (x>0) {
- x = x % (getWidth()-1)+1;
+ x = x % (getWidth());
}
backMap[x][y] = value;
} catch (ArrayIndexOutOfBoundsException e) {
}
}
- public Vector2 getSpawnPoint() {
- float x=0, y=0;
+ public Vector2 getSpawnPoint(int x) {
+ int y=0;
+ while (true) {
+ y++;
+ if (getForeMap(x,y)>0 && Items.BLOCKS.getValueAt(getForeMap(x,y)).collision) break;
+ }
x = x*16 + 4;
- y *= 16;
+ y = y*16 - 32;
return new Vector2(x,y);
}