DEADSOFTWARE

Fix bugs
authorfred-boy <fred-boy@protonmail.com>
Sun, 22 Apr 2018 17:34:28 +0000 (00:34 +0700)
committerfred-boy <fred-boy@protonmail.com>
Sun, 22 Apr 2018 17:34:28 +0000 (00:34 +0700)
core/src/ru/deadsoftware/cavecraft/GameScreen.java
core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
core/src/ru/deadsoftware/cavecraft/game/GameProc.java
core/src/ru/deadsoftware/cavecraft/game/GameWorld.java
core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java

index accd1e59cc6ffd25fac1a3f47ae4fd8170e74eca..52c3dcf5c8f2dbf1cedd7952d97fefe8a2648e82 100644 (file)
@@ -16,7 +16,6 @@ public class GameScreen implements Screen {
     public GameScreen() {
         Assets.load();
         Items.load();
-        gameProc = new GameProc();
         menuRenderer = new MenuRenderer(CaveGame.TOUCH?320:480);
         renderer = menuRenderer;
         Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer));
index 07587e688129906f76e67401b01f8afd15b01778..3c2e9ec718f1653526f93b70edf30dda8928054b 100644 (file)
@@ -97,7 +97,7 @@ public class GamePhysics {
         if (pl.position.x+pl.texWidth/2<0) pl.position.x+=gameProc.world.getWidth()*16;
         if (pl.position.x+pl.texWidth/2>gameProc.world.getWidth()*16) pl.position.x-=gameProc.world.getWidth()*16;
         if (pl.position.y > gameProc.world.getHeight()*16) {
-            pl.position = gameProc.world.getSpawnPoint().cpy();
+            pl.position = gameProc.world.getSpawnPoint(0).cpy();
         }
         if (CaveGame.TOUCH && checkJump(pl.getRect(), pl.dir) && !pl.flyMode && pl.canJump && !pl.moveX.equals(Vector2.Zero)) {
             pl.moveY.add(0, -8);
index b100ddc77251572ddee3e4e54d8cde36ce5e2542..dfe4d6bdd306f6a6c139a1a52f00d19283705bc2 100644 (file)
@@ -40,10 +40,10 @@ public class GameProc {
                     480*((float)GameScreen.getHeight()/GameScreen.getWidth()));
         }
         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.add(new Pig(i*16, 0, world));
+            mobs.add(new Pig(i*16, (int)world.getSpawnPoint(i).y, world));
         }
         if (!CaveGame.TOUCH) ctrlMode = 1;
     }
index daa00c004af21ce8356aeec57d0f276d18865376..064eca58ffa72052a0b6afd0695aea1772c159c2 100644 (file)
@@ -100,10 +100,14 @@ public class GameWorld {
         }
     }
 
-    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);
     }
 
index 482db61499fe5b5e1b6a902c14f65a944526e09b..c8cbc288a252b50adc40841a7761aec2b97deb08 100644 (file)
@@ -37,8 +37,7 @@ public class MenuRenderer extends Renderer {
         spriteBatch.begin();
         for (int x=0; x<=getWidth()/16; x++)
             for (int y=0; y<=getHeight()/16; y++) {
-                if (y == 0) spriteBatch.draw(Items.BLOCKS.get("grass").getTexture(), x * 16, y * 16);
-                    else spriteBatch.draw(Items.BLOCKS.get("dirt").getTexture(), x * 16, y * 16);
+                spriteBatch.draw(Items.BLOCKS.get("dirt").getTexture(), x * 16, y * 16);
                 spriteBatch.draw(Assets.shade,x*16,y*16);
             }
         spriteBatch.draw(Assets.gameLogo, getWidth()/2-Assets.gameLogo.getWidth()/2, 0);