summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c21d1b3)
raw | patch | inline | side by side (parent: c21d1b3)
author | fred-boy <fred-boy@protonmail.com> | |
Thu, 12 Apr 2018 15:57:28 +0000 (22:57 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Thu, 12 Apr 2018 15:57:28 +0000 (22:57 +0700) |
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java b/core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java
index 102a0f7b003f79471cca77e2dc3c65778debe6a3..0b714ddd43eda90fa210a60108f592d79ece325e 100644 (file)
import com.badlogic.gdx.Input;
import com.badlogic.gdx.utils.TimeUtils;
+import ru.deadsoftware.cavecraft.GameScreen;
public class GameInputHandler {
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
index 8b79fe0116273791655bac30dc245e82c962371e..e461a9399381d38c59b31dfcf518b6cba66176da 100644 (file)
while (checkColl(pl.getRect())) pl.position.x += d;
}
}
-
+ if (pl.position.y > gameProc.world.getHeight()*16) {
+ pl.position = gameProc.world.getSpawnPoint().cpy();
+ }
/*if (checkJump(pl.getRect(), pl.dir) && !pl.flyMode && pl.canJump && !pl.moveX.equals(Vector2.Zero)) {
pl.moveY.add(0, -8);
pl.canJump = false;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index b955d2309d24cbc6d76158e38811f78e8b9846e6..0e3993d8a4caf0018cd28e9e5e5279d1e8ad3b74 100644 (file)
world = new GameWorld(4096,256);
renderer = new GameRenderer(this);
physics = new GamePhysics(this);
- player = new Player(world.getWidth()/2*16+4, 0);
+ player = new Player(world.getSpawnPoint());
mobs = new Array<Mob>();
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java
index c32bbd9358f297088f28c43572154652520b919c..97d05cb2d41f5767cd88482f27c238453da61f41 100644 (file)
package ru.deadsoftware.cavecraft.game;
import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.math.Vector2;
import ru.deadsoftware.cavecraft.Items;
public class GameWorld {
setBackMap(x,y,value);
}
+ public Vector2 getSpawnPoint() {
+ float x=0, y=0;
+ boolean found = false;
+ x = getWidth()/2;
+ while (!found) {
+ for (int i = 0; i < getHeight(); i++) {
+ if (getForeMap((int)x, i)>0 &&
+ Items.BLOCKS.getValueAt(getForeMap((int)x, i)).collision) {
+ y = i-3;
+ found = true;
+ break;
+ }
+ }
+ if (!found) x--;
+ }
+ x = x*16 + 4;
+ y *= 16;
+ return new Vector2(x,y);
+ }
+
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java
index bcebde6f3d6198ae7ecba5185c4d3ff445ccabe6..92c81716c3b13c1007e2b3758ae342f5aa3fb82d 100644 (file)
public int[] inventory;
public boolean flyMode = false;
- public Player(int x, int y) {
- position = new Vector2(x, y);
+ public Player(Vector2 spawnPoint) {
+ position = spawnPoint.cpy();
moveX = new Vector2(0, 0);
moveY = new Vector2(0, 0);
width = 4;