summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 64a6c34)
raw | patch | inline | side by side (parent: 64a6c34)
author | fred-boy <fred-boy@protonmail.com> | |
Fri, 6 Apr 2018 13:28:08 +0000 (20:28 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Fri, 6 Apr 2018 13:28:08 +0000 (20:28 +0700) |
diff --git a/android/assets/gui.png b/android/assets/gui.png
new file mode 100644 (file)
index 0000000..ef76dc0
Binary files /dev/null and b/android/assets/gui.png differ
index 0000000..ef76dc0
Binary files /dev/null and b/android/assets/gui.png differ
diff --git a/core/src/ru/deadsoftware/cavecraft/Assets.java b/core/src/ru/deadsoftware/cavecraft/Assets.java
index fcbfe7a1a1ee8fd345216999555c06c710d0d53e..45634ebfa449f2ed7fd4ec1357570d6f3e3d9562 100644 (file)
public static Texture terrain;
public static TextureRegion[] blockTextures = new TextureRegion[BLOCK_TEXTURES];
+ public static Texture gui;
+ public static TextureRegion invBar;
+ public static TextureRegion invCur;
+
public static void load() {
charTexture = new Texture(Gdx.files.internal("char.png"));
playerSprite[0] = new Sprite(new TextureRegion(charTexture, 0,0,8,30));
shade = new Sprite(new Texture(Gdx.files.internal("shade.png")));
+ gui = new Texture(Gdx.files.internal("gui.png"));
+ invBar = new TextureRegion(gui,0,0,182,22);
+ invCur = new TextureRegion(gui,0,22,24,24);
+
terrain = new Texture(Gdx.files.internal("terrain.png"));
for (int i=0; i<BLOCK_TEXTURES; i++) {
blockTextures[i] = new TextureRegion(terrain,
diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java
index 02d07e212a615d3314ea4cfe283e6fc78e70106c..efdce0440b8bb2a74d179fdd6188ee211ff59671 100644 (file)
@Override
public boolean scrolled(int amount) {
+ gameInput.scrolled(amount);
return false;
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java b/core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java
index ff8fa2e89438cec46984e53333740fcc9e72521b..d63568cb1dad36a1cfd5bd16d310e6fe43297657 100644 (file)
public void touchUp(int screenX, int screenY, int button) {
if (gameProc.isTouchDown) {
if (button == Input.Buttons.RIGHT){
- gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY, 1);
+ gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY,
+ gameProc.player.inventory[gameProc.invSlot]);
} else if (button == Input.Buttons.LEFT) {
if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY) > 0) {
gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY, 0);
gameProc.isTouchDown = false;*/
}
+ public void scrolled(int amount) {
+ gameProc.invSlot += amount;
+ if (gameProc.invSlot < 0) gameProc.invSlot = 8;
+ if (gameProc.invSlot > 8) gameProc.invSlot = 0;
+ }
+
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index 61c64ffebf940ab81233bce72fb7da74977c4e2a..cf70144d75948eeac988b7c517b12a8247d11d0a 100644 (file)
public GamePhysics physics;
public int cursorX, cursorY;
+ public int invSlot;
public boolean isTouchDown = false;
public int touchDownX, touchDownY;
physics.update(delta);
if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) {
- world.placeToBackground(cursorX,cursorY,1);
+ world.placeToBackground(cursorX,cursorY,
+ player.inventory[invSlot]);
isTouchDown = false;
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
index 09a433a81e2f8d9d31702e0f910d66ac670c4e0e..54ec384e040cf91cf688cce9b31ba7bcd9ad357f 100644 (file)
Assets.playerSprite[pl.dir].draw(spriteBatch);
}
+ private void drawGUI() {
+ spriteBatch.draw(Assets.invBar, camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2,
+ camera.viewportHeight - Assets.invBar.getRegionHeight());
+ for (int i=0; i<8; i++) {
+ if (gameProc.player.inventory[i]>0) {
+ spriteBatch.draw(BlocksLoader.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture(),
+ camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2+3+i*20,
+ camera.viewportHeight-19);
+ }
+ }
+ spriteBatch.draw(Assets.invCur,
+ camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2 - 1 + 20*gameProc.invSlot,
+ camera.viewportHeight - Assets.invBar.getRegionHeight() - 2);
+ }
+
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
spriteBatch.begin();
drawWorld();
drawPlayer(gameProc.player);
+ drawGUI();
spriteBatch.end();
shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
shapeRenderer.setColor(Color.ORANGE);
diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java
index 0c5581a7ee2711999f526e52bbc77cafa4385a2e..2953d940989febecabc83467aff77e0de7c98623 100644 (file)
public Vector2 moveX, moveY;
public int width, height, dir;
public boolean canJump;
+ public int[] inventory;
public Player() {
position = new Vector2(0, 0);
moveY = new Vector2(0, 0);
width = 8;
height = 30;
+ inventory = new int[9];
+ inventory[0] = 1;
+ inventory[1] = 2;
+ inventory[2] = 3;
}
public Rectangle getRect() {