summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 50082e8)
raw | patch | inline | side by side (parent: 50082e8)
author | fred-boy <fred-boy@protonmail.com> | |
Thu, 12 Apr 2018 05:10:44 +0000 (12:10 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Thu, 12 Apr 2018 05:10:44 +0000 (12:10 +0700) |
13 files changed:
diff --git a/android/assets/char.png b/android/assets/char.png
deleted file mode 100644 (file)
index f8f6dca..0000000
Binary files a/android/assets/char.png and /dev/null differ
index f8f6dca..0000000
Binary files a/android/assets/char.png and /dev/null differ
diff --git a/android/assets/font.fnt b/android/assets/font.fnt
--- /dev/null
+++ b/android/assets/font.fnt
@@ -0,0 +1,100 @@
+info face="Minecraft Regular" size=18 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2
+common lineHeight=19 base=15 scaleW=512 scaleH=512 pages=1 packed=0
+page id=0 file="font.png"
+chars count=95
+char id=10 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=0 page=0 chnl=0
+char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=17 xadvance=7 page=0 chnl=0
+char id=33 x=472 y=0 width=4 height=15 xoffset=-1 yoffset=4 xadvance=4 page=0 chnl=0
+char id=34 x=349 y=17 width=9 height=8 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=35 x=114 y=17 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=36 x=92 y=17 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=37 x=103 y=17 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=38 x=125 y=17 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=39 x=358 y=17 width=6 height=8 xoffset=-1 yoffset=4 xadvance=6 page=0 chnl=0
+char id=40 x=491 y=0 width=10 height=15 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=41 x=501 y=0 width=9 height=15 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=42 x=379 y=17 width=9 height=7 xoffset=-1 yoffset=8 xadvance=9 page=0 chnl=0
+char id=43 x=327 y=17 width=11 height=11 xoffset=-1 yoffset=6 xadvance=11 page=0 chnl=0
+char id=44 x=364 y=17 width=4 height=7 xoffset=-1 yoffset=14 xadvance=4 page=0 chnl=0
+char id=45 x=405 y=17 width=11 height=4 xoffset=-1 yoffset=10 xadvance=11 page=0 chnl=0
+char id=46 x=388 y=17 width=4 height=6 xoffset=-1 yoffset=13 xadvance=4 page=0 chnl=0
+char id=47 x=57 y=17 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=48 x=461 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=49 x=362 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=50 x=373 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=51 x=384 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=52 x=395 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=53 x=406 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=54 x=417 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=55 x=428 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=56 x=439 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=57 x=450 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=58 x=180 y=17 width=4 height=13 xoffset=-1 yoffset=6 xadvance=4 page=0 chnl=0
+char id=59 x=487 y=0 width=4 height=15 xoffset=-1 yoffset=6 xadvance=4 page=0 chnl=0
+char id=60 x=35 y=17 width=9 height=15 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=61 x=338 y=17 width=11 height=9 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=62 x=44 y=17 width=9 height=15 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=63 x=476 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=64 x=68 y=17 width=13 height=15 xoffset=-1 yoffset=4 xadvance=13 page=0 chnl=0
+char id=65 x=11 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=66 x=22 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=67 x=33 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=68 x=44 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=69 x=55 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=70 x=66 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=71 x=77 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=72 x=88 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=73 x=99 y=0 width=7 height=15 xoffset=-1 yoffset=4 xadvance=7 page=0 chnl=0
+char id=74 x=106 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=75 x=117 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=76 x=128 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=77 x=139 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=78 x=150 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=79 x=161 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=80 x=172 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=81 x=183 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=82 x=194 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=83 x=205 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=84 x=216 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=85 x=227 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=86 x=238 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=87 x=249 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=88 x=260 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=89 x=271 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=90 x=282 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=91 x=0 y=17 width=8 height=15 xoffset=-1 yoffset=4 xadvance=7 page=0 chnl=0
+char id=92 x=81 y=17 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=93 x=8 y=17 width=8 height=15 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0
+char id=94 x=368 y=17 width=11 height=7 xoffset=-1 yoffset=5 xadvance=11 page=0 chnl=0
+char id=95 x=405 y=17 width=11 height=4 xoffset=-1 yoffset=17 xadvance=11 page=0 chnl=0
+char id=97 x=184 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=98 x=293 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=99 x=195 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=100 x=304 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=101 x=206 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=102 x=315 y=0 width=9 height=15 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=103 x=136 y=17 width=11 height=13 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=104 x=324 y=0 width=11 height=15 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=105 x=335 y=0 width=4 height=15 xoffset=-1 yoffset=4 xadvance=4 page=0 chnl=0
+char id=106 x=0 y=0 width=11 height=17 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0
+char id=107 x=339 y=0 width=9 height=15 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=108 x=348 y=0 width=6 height=15 xoffset=-1 yoffset=4 xadvance=6 page=0 chnl=0
+char id=109 x=217 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=110 x=228 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=111 x=239 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=112 x=147 y=17 width=11 height=13 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=113 x=158 y=17 width=11 height=13 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=114 x=250 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=115 x=261 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=116 x=354 y=0 width=8 height=15 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0
+char id=117 x=272 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=118 x=283 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=119 x=294 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=120 x=305 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=121 x=169 y=17 width=11 height=13 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=122 x=316 y=17 width=11 height=11 xoffset=-1 yoffset=8 xadvance=11 page=0 chnl=0
+char id=123 x=16 y=17 width=10 height=15 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=124 x=53 y=17 width=4 height=15 xoffset=-1 yoffset=4 xadvance=4 page=0 chnl=0
+char id=125 x=26 y=17 width=9 height=15 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
+char id=126 x=392 y=17 width=13 height=6 xoffset=-1 yoffset=4 xadvance=13 page=0 chnl=0
+kernings count=0
diff --git a/android/assets/font.png b/android/assets/font.png
new file mode 100644 (file)
index 0000000..e489797
Binary files /dev/null and b/android/assets/font.png differ
index 0000000..e489797
Binary files /dev/null and b/android/assets/font.png differ
diff --git a/core/src/ru/deadsoftware/cavecraft/Assets.java b/core/src/ru/deadsoftware/cavecraft/Assets.java
index b24356fb6686593613a39f17e2d532b1a0cdd3f7..3764a587345a0b5979a21e93730eeed5d2db8298 100644 (file)
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
+import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
public static final int BLOCK_TEXTURES = 3;
+ public static BitmapFont minecraftFont;
+
public static Texture charTexture;
public static Sprite[][] playerSkin = new Sprite[2][4];
public static TextureRegion touchSpace;
public static void load() {
+ minecraftFont = new BitmapFont(Gdx.files.internal("font.fnt"), true);
charTexture = new Texture(Gdx.files.internal("mobs/char.png"));
//LOOK TO LEFT
//head
diff --git a/core/src/ru/deadsoftware/cavecraft/CaveGame.java b/core/src/ru/deadsoftware/cavecraft/CaveGame.java
index 1856a333cd59933ac02cf345d3ecdbd256c11250..50d9447f979d9f046041df08643c021c5260a6be 100644 (file)
public class CaveGame extends Game {
+ public static final String VERSION = "alpha 0.0";
+
public static boolean TOUCH;
public CaveGame() {
diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java
index 3301805e5854acafb14a33263b1e32ec447167b6..f9f42ea6969a3b19ca3dd912126f671771fa09ed 100644 (file)
public class GameScreen implements Screen {
+ public static int FPS;
+
private GameProc gameProc;
private GameInputHandler gameInput;
@Override
public void render(float delta) {
+ FPS = (int)(1/delta);
gameProc.update(delta);
gameProc.renderer.render();
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
index f8843f2c6851ba086a4c3a8e3fbb6aeccb61e529..3bd467d2ab05ce5ae97f0f9dc7f93efb49e0ead4 100644 (file)
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.math.Vector3;
import ru.deadsoftware.cavecraft.game.mobs.Mob;
import ru.deadsoftware.cavecraft.game.objects.Player;
gravity = new Vector2(0,1);
}
+ private boolean checkJump(Rectangle rect, int dir) {
+ int bl;
+ switch (dir) {
+ case 0:
+ bl = gameProc.world.getForeMap(
+ (int)((rect.x+(rect.width/2))/16) - 1,
+ (int)(rect.y/16)+1);
+ break;
+ case 1:
+ bl = gameProc.world.getForeMap(
+ (int)((rect.x+(rect.width/2))/16) + 1,
+ (int)(rect.y/16)+1);
+ break;
+ default:
+ bl=0;
+ }
+ return (bl!=0);
+ }
+
private boolean checkColl(Rectangle rect) {
int[] bl = new int [6];
bl[0] = gameProc.world.getForeMap(((int)(rect.x)/16), ((int)rect.y/16));
if (!pl.flyMode) pl.moveY.add(gravity);
pl.position.add(pl.moveX);
if (pl.position.x<0 ||
- pl.position.x+pl.width>gameProc.world.getWidth()*16)
+ pl.position.x+pl.texWidth>=gameProc.world.getWidth()*16)
pl.position.sub(pl.moveX);
if (checkColl(pl.getRect())) {
int d = 0;
pl.position.x = MathUtils.round(pl.position.x);
while (checkColl(pl.getRect())) pl.position.x+=d;
}
- switch (pl.dir) {
- case 0:
- gameProc.renderer.camTargetPos.x = pl.position.x-gameProc.renderer.camera.viewportWidth+100;
- break;
- case 1:
- gameProc.renderer.camTargetPos.x = pl.position.x-100;
- break;
+
+ if (checkJump(pl.getRect(), pl.dir) && !pl.flyMode && pl.canJump && !pl.moveX.equals(Vector2.Zero)) {
+ pl.moveY.add(0, -8);
+ pl.canJump = false;
}
- if (gameProc.renderer.camTargetPos.x < 0) gameProc.renderer.camTargetPos.x = 0;
- if (gameProc.renderer.camTargetPos.x + gameProc.renderer.camera.viewportWidth >
- gameProc.world.getWidth()*16)
- gameProc.renderer.camTargetPos.x = gameProc.world.getWidth()*16-gameProc.renderer.camera.viewportWidth;
}
private void mobPhy(Mob mob) {
}
playerPhy(gameProc.player);
- if (gameProc.renderer.camera.position.x - gameProc.renderer.camTargetPos.x <= 8 &&
- gameProc.renderer.camera.position.x - gameProc.renderer.camTargetPos.x >= -8) {
- gameProc.renderer.camera.position.x = gameProc.renderer.camTargetPos.x;
- }
- if (gameProc.renderer.camera.position.x > gameProc.renderer.camTargetPos.x) {
- gameProc.renderer.camera.position.sub(16,0,0);
- }
- if (gameProc.renderer.camera.position.x < gameProc.renderer.camTargetPos.x) {
- gameProc.renderer.camera.position.add(16,0,0);
- }
- gameProc.renderer.camera.position.y = gameProc.player.position.y+gameProc.player.height/2
- -gameProc.renderer.camera.viewportHeight/2;
+ gameProc.renderer.camera.position.set(
+ gameProc.player.position.x+gameProc.player.texWidth/2 - gameProc.renderer.camera.viewportWidth/2,
+ gameProc.player.position.y+gameProc.player.height/2-gameProc.renderer.camera.viewportHeight/2,
+ 0
+ );
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index 4c639125283b841f9baa82ec8a365a046f91f122..fd6d0fe748622debb40ff4f5db865388c57f36f8 100644 (file)
physics = new GamePhysics(this);
player = new Player();
mobs = new Array<Mob>();
- for (int i=0; i<6; i++) {
- mobs.add(new Human(64*(i+1),0, this));
- }
+
}
public void resetRenderer() {
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
index 59557a2b9418ceebdcc5fc1f229d05ba512aceb0..cc3bcdee8c9f849e89f1d8184bb68b397c4660e8 100644 (file)
private GameProc gameProc;
- public Vector3 camTargetPos;
- public OrthographicCamera camera;
+ public OrthographicCamera camera, fontCam;
ShapeRenderer shapeRenderer;
- SpriteBatch spriteBatch;
+ SpriteBatch spriteBatch, fontBatch;
public GameRenderer(GameProc gameProc) {
Gdx.gl.glClearColor(0f,.6f,.6f,1f);
camera = new OrthographicCamera();
camera.setToOrtho(true, 360,
360*((float)GameScreen.getHeight()/GameScreen.getWidth()));
- camera.position.x=0;
- camera.position.y=0;
- camTargetPos = camera.position.cpy();
+
shapeRenderer = new ShapeRenderer();
shapeRenderer.setProjectionMatrix(camera.combined);
shapeRenderer.setAutoShapeType(true);
spriteBatch = new SpriteBatch();
spriteBatch.setProjectionMatrix(camera.combined);
+
+ fontCam = new OrthographicCamera();
+ fontCam.setToOrtho(true, GameScreen.getWidth(), GameScreen.getHeight());
+ fontBatch = new SpriteBatch();
+ fontBatch.setProjectionMatrix(fontCam.combined);
+ }
+
+ private void setFontColor(int r, int g, int b) {
+ Assets.minecraftFont.setColor(r/255f, g/255f, b/255f, 1f);
+ }
+
+ private void drawString(String str, float x, float y) {
+ Assets.minecraftFont.draw(fontBatch, str, x, y);
}
private void drawWorld() {
}
private void drawPlayer(Player pl) {
- if (!pl.moveX.equals(Vector2.Zero)) {
+ if (!pl.moveX.equals(Vector2.Zero) || Assets.playerSkin[0][2].getRotation()!=0) {
Assets.playerSkin[0][2].rotate(Mob.ANIM_SPEED);
Assets.playerSkin[1][2].rotate(-Mob.ANIM_SPEED);
Assets.playerSkin[0][3].rotate(-Mob.ANIM_SPEED);
gameProc.cursorY * 16 - camera.position.y, 16, 16);
shapeRenderer.end();
}
+
+ fontBatch.begin();
+ setFontColor(255,255,255);
+ drawString("CaveCraft "+CaveGame.VERSION, 0, 0);
+ drawString("FPS: "+GameScreen.FPS, 0, 20);
+ drawString("X: "+(int)(gameProc.player.position.x/16), 0, 40);
+ drawString("Y: "+(int)(gameProc.player.position.y/16), 0, 60);
+ drawString("Block: "+
+ Items.BLOCKS.keys().toArray().get(gameProc.world.getForeMap(
+ (int)(gameProc.player.position.x/16),
+ (int)(gameProc.player.position.y/16+2))),
+ 0, 80);
+ fontBatch.end();
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java
index 9f6e693886a11db7386bebeb2b9a3f7f4ced59dc..5bc94ff2944f5c0f642227f188524d473142c86a 100644 (file)
public class WorldGen {
+ private static RandomXS128 rand;
+ private static long seed;
+
private static int[][] foreMap, backMap;
private static int[] hMap;
+ public static long getSeed() {
+ return seed;
+ }
+
static int[] genLandscape(int width, int mid, int min, int max) {
- RandomXS128 rand = new RandomXS128(TimeUtils.millis());
int[] res = new int[width];
int t;
res[0] = mid;
}
static void genWorld(int width, int height) {
+ genWorld(width, height, TimeUtils.millis());
+ }
+
+ static void genWorld(int width, int height, long s) {
+ int dirtH;
+ seed = s;
+ rand = new RandomXS128(seed);
foreMap = new int[width][height];
backMap = new int[width][height];
hMap = genLandscape(width, height/2, height/4, height/4*3);
for (int x=0; x<width; x++) {
+ dirtH = 4+rand.nextInt(2);
for (int y = height- hMap[x]; y<height; y++) {
if (y==height- hMap[x]) {
foreMap[x][y] = 3;
backMap[x][y] = 3;
- } else if (y<height- hMap[x]+4) {
+ } else if (y<height-hMap[x]+dirtH) {
foreMap[x][y] = 2;
backMap[x][y] = 2;
} else {
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Human.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Human.java
index 97b1c18dc0b16f86bed4e7ba3998202691f3be48..245d34960407d99c2aaf9231fd198d5e3766a282 100644 (file)
package ru.deadsoftware.cavecraft.game.mobs;
+import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.RandomXS128;
import com.badlogic.gdx.math.Rectangle;
private RandomXS128 rand = new RandomXS128();
private GameProc gameProc;
+ private Sprite[][] tex;
public Human(int x, int y, GameProc gameProc) {
this.gameProc = gameProc;
moveY = new Vector2(0, 0);
width = 8;
height = 30;
- dir = 1;
+ dir = 0;
canJump = false;
+ tex = Assets.playerSkin.clone();
+ animation = 0;
+ anim_d = 1;
}
@Override
@Override
public void draw(SpriteBatch spriteBatch, float x, float y) {
- spriteBatch.draw(Assets.playerSkin[dir][0], x-2, y-2);
- if (Assets.playerSkin[0][2].getRotation()>=60 || Assets.playerSkin[0][2].getRotation()<=-60)
+ if (moveX.x!=0) {
+ animation+=Mob.ANIM_SPEED*anim_d;
+ if (animation<=-60 || animation>=60) anim_d=-anim_d;
+ }
+ tex[0][2].setRotation(animation);
+ tex[1][2].setRotation(-animation);
+ tex[0][3].setRotation(-animation);
+ tex[1][3].setRotation(animation);
+ spriteBatch.draw(tex[dir][0], x-2, y-2);
+ if (tex[0][2].getRotation()>=60 || tex[0][2].getRotation()<=-60)
Mob.ANIM_SPEED = -Mob.ANIM_SPEED;
- Assets.playerSkin[1][2].setPosition(x-6,y);
- Assets.playerSkin[1][2].draw(spriteBatch);
- Assets.playerSkin[1][3].setPosition(x-6, y+10);
- Assets.playerSkin[1][3].draw(spriteBatch);
- Assets.playerSkin[0][3].setPosition(x-6, y+10);
- Assets.playerSkin[0][3].draw(spriteBatch);
- spriteBatch.draw(Assets.playerSkin[dir][1], x-2, y + 8);
-
- Assets.playerSkin[0][2].setPosition(x-6, y);
- Assets.playerSkin[0][2].draw(spriteBatch);
+ tex[1][2].setPosition(x-6,y);
+ tex[1][2].draw(spriteBatch);
+ tex[1][3].setPosition(x-6, y+10);
+ tex[1][3].draw(spriteBatch);
+ tex[0][3].setPosition(x-6, y+10);
+ tex[0][3].draw(spriteBatch);
+ spriteBatch.draw(tex[dir][1], x-2, y + 8);
+
+ tex[0][2].setPosition(x-6, y);
+ tex[0][2].draw(spriteBatch);
}
public Rectangle getRect() {
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java
index a4dca28e465841cfb177ccfa9f9fd2a63982e732..e0ff0e2afc125d7be02029661ff242068197e669 100644 (file)
public Vector2 position;
public Vector2 moveX, moveY;
- public int width, height, dir;
+ public int width, height, dir, animation, anim_d;
public boolean canJump;
public abstract void ai();
diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java
index 56aa9c1e4d098aef7d371f1be9083a9602b58484..1dc516bdd9e761b57124c18d6777df4364d7418d 100644 (file)
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
+import ru.deadsoftware.cavecraft.Assets;
public class Player {
public Vector2 position;
public Vector2 moveX, moveY;
- public int width, height, dir;
+ public int width, height, dir, texWidth;
public boolean canJump;
public int[] inventory;
public boolean flyMode = false;
moveY = new Vector2(0, 0);
width = 4;
height = 30;
+ texWidth = 8;
inventory = new int[9];
inventory[0] = 1;
inventory[1] = 2;