diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index 6c532ace6a77c6a6537d7b5b0196f44c3e7d08fc..a2107fa956fd9bc0948d2e02fd0f770b511b1183 100644 (file)
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.TimeUtils;
import ru.deadsoftware.cavecraft.*;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.TimeUtils;
import ru.deadsoftware.cavecraft.*;
+import ru.deadsoftware.cavecraft.AppState;
import ru.deadsoftware.cavecraft.game.mobs.Mob;
import ru.deadsoftware.cavecraft.game.mobs.Pig;
import ru.deadsoftware.cavecraft.game.objects.Player;
import ru.deadsoftware.cavecraft.game.mobs.Mob;
import ru.deadsoftware.cavecraft.game.mobs.Pig;
import ru.deadsoftware.cavecraft.game.objects.Player;
public long touchDownTime;
public GameProc() {
public long touchDownTime;
public GameProc() {
- world = new GameWorld(1024,256);
- renderer = new GameRenderer(this);
+ world = new GameWorld();
+ if (WorldSaver.exists()) {
+ world.load();
+ } else {
+ world.generate(1024, 256);
+ }
+ if (CaveGame.TOUCH) {
+ renderer = new GameRenderer(this,320,
+ 320*((float)GameScreen.getHeight()/GameScreen.getWidth()));
+ } else {
+ renderer = new GameRenderer(this,480,
+ 480*((float)GameScreen.getHeight()/GameScreen.getWidth()));
+ }
physics = new GamePhysics(this);
physics = new GamePhysics(this);
- player = new Player(world.getSpawnPoint());
+ player = new Player(world.getSpawnPoint(0));
mobs = new Array<Mob>();
for (int i=0; i<world.getWidth(); i+=64) {
mobs = new Array<Mob>();
for (int i=0; i<world.getWidth(); i+=64) {
- mobs.add(new Pig(i*16, 0, world));
+ mobs.add(new Pig(i*16, (int)world.getSpawnPoint(i).y, world));
}
if (!CaveGame.TOUCH) ctrlMode = 1;
}
public void resetRenderer() {
}
if (!CaveGame.TOUCH) ctrlMode = 1;
}
public void resetRenderer() {
- renderer = new GameRenderer(this);
+ if (CaveGame.TOUCH) {
+ renderer = new GameRenderer(this,320,
+ 320*((float)GameScreen.getHeight()/GameScreen.getWidth()));
+ } else {
+ renderer = new GameRenderer(this,480,
+ 480*((float)GameScreen.getHeight()/GameScreen.getWidth()));
+ }
}
private boolean isAutoselectable(int x, int y) {
}
private boolean isAutoselectable(int x, int y) {
}
private void moveCursor() {
}
private void moveCursor() {
- if (ctrlMode==0 && CaveGame.TOUCH) {
- if (player.canJump) {
- cursorX = (int) (player.position.x + player.texWidth / 2) / 16;
- if (player.dir == 0) cursorX--;
+ if (ctrlMode == 0 && CaveGame.TOUCH) {
+ cursorX = (int) (player.position.x + player.texWidth / 2) / 16;
+ if (player.dir == 0) cursorX--;
else cursorX++;
else cursorX++;
- cursorY = (int) (player.position.y + player.texWidth) / 16;
- if (!isAutoselectable(cursorX, cursorY)) {
- cursorY++;
- }
- if (!isAutoselectable(cursorX, cursorY)) {
- cursorY++;
- }
- if (!isAutoselectable(cursorX, cursorY)) {
- if (player.dir == 0) cursorX++;
- else cursorX--;
- }
- } else {
- cursorX = (int) (player.position.x + player.texWidth / 2) / 16;
- cursorY = (int) (player.position.y + player.height+8)/16;
+ cursorY = (int) (player.position.y + player.texWidth) / 16;
+ if (!isAutoselectable(cursorX, cursorY)) {
+ cursorY++;
+ }
+ if (!isAutoselectable(cursorX, cursorY)) {
+ cursorY++;
+ }
+ if (!isAutoselectable(cursorX, cursorY)) {
+ if (player.dir == 0) cursorX++;
+ else cursorX--;
}
} else if (!CaveGame.TOUCH){
cursorX = (int)(Gdx.input.getX()*
}
} else if (!CaveGame.TOUCH){
cursorX = (int)(Gdx.input.getX()*
private void checkCursorBounds() {
if (cursorY < 0) cursorY = 0;
if (cursorY >= world.getHeight()) cursorY = world.getHeight()-1;
private void checkCursorBounds() {
if (cursorY < 0) cursorY = 0;
if (cursorY >= world.getHeight()) cursorY = world.getHeight()-1;
- if (cursorX<(player.position.x+player.texWidth/2)/16)
- player.dir=0;
- if (cursorX>(player.position.x+player.texWidth/2)/16)
- player.dir=1;
+ if (ctrlMode==1) {
+ if (cursorX*16+8<player.position.x+player.texWidth/2)
+ player.dir=0;
+ if (cursorX*16+8>player.position.x+player.texWidth/2)
+ player.dir=1;
+ }
}
public void update(float delta) {
}
public void update(float delta) {
touchDownY< Assets.invBar.getRegionHeight() &&
touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 &&
touchDownX<renderer.camera.viewportWidth/2+Assets.invBar.getRegionWidth()/2) {
touchDownY< Assets.invBar.getRegionHeight() &&
touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 &&
touchDownX<renderer.camera.viewportWidth/2+Assets.invBar.getRegionWidth()/2) {
- CaveGame.STATE = GameState.GAME_CREATIVE_INV;
+ CaveGame.STATE = AppState.GAME_CREATIVE_INV;
}
isTouchDown = false;
}
}
isTouchDown = false;
}