summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 59d07dd)
raw | patch | inline | side by side (parent: 59d07dd)
author | fred-boy <fredboy@protonmail.com> | |
Sat, 28 Sep 2019 15:54:50 +0000 (22:54 +0700) | ||
committer | fred-boy <fredboy@protonmail.com> | |
Sun, 29 Sep 2019 04:39:18 +0000 (11:39 +0700) |
diff --git a/android/assets/background.png b/android/assets/background.png
new file mode 100644 (file)
index 0000000..1774f86
Binary files /dev/null and b/android/assets/background.png differ
index 0000000..1774f86
Binary files /dev/null and b/android/assets/background.png differ
index d032497ad11b763fc4f07f47c37585181b39334a..e1f3e48adc14ebf25d3578a590cfc545826017c8 100644 (file)
"h": 16
}
},
- "shade": {
- "shade": {}
- },
- "gamelogo": {
- "gamelogo": {}
- }
+ "shade": {},
+ "gamelogo": {},
+ "background": {}
}
\ No newline at end of file
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameProc.java b/core/src/ru/deadsoftware/cavedroid/game/GameProc.java
index fdfef6356f3634a73a63675e05aca3e032db02f7..432ff51ef1828deafc26a47aa973eb5e37d4d576 100644 (file)
public void update() {
physics.update();
+ blockUpdater();
moveCursor();
-
if (isTouchDown && touchDownBtn == Input.Buttons.LEFT) pressLMB();
if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) holdMB();
if (fluidThread == null || !fluidThread.isAlive()) startFluidThread();
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java
index f6149ea855ba7ace63aa3f58f4013de8250df0e1..fe4e46af1b855628fcf96836fe01c4d2f998c8bc 100644 (file)
@Override
public void draw(SpriteBatch spriteBatch, float x, float y) {
- spriteBatch.draw(GameItems.getBlock("gravel").getTex(), x, y);
+ spriteBatch.draw(Assets.fallingGravelSprite, x, y);
}
@Override
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java
index b1777c485c7ecffb1bd553bc5c7115a57c53d33a..315fcfc6a92fa3e2cf8f53122d6c518c50ad1358 100644 (file)
@Override
public void draw(SpriteBatch spriteBatch, float x, float y) {
- spriteBatch.draw(GameItems.getBlock("sand").getTex(), x, y);
+ spriteBatch.draw(Assets.fallingSandSprite, x, y);
}
@Override
diff --git a/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java
index 2ae84db12d93926e5c2a19207937b9928609fad0..74fbf95b1bf924a8106f0c04b910b866426fa855 100644 (file)
@Override
public void render() {
- TextureRegion shade = textureRegions.get("shade");
+ TextureRegion background = textureRegions.get("background");
TextureRegion gamelogo = textureRegions.get("gamelogo");
spriter.begin();
for (int x = 0; x <= getWidth() / 16; x++) {
for (int y = 0; y <= getHeight() / 16; y++) {
-// spriter.draw(GameItems.getBlock(3).getTex(), x * 16, y * 16);
- spriter.draw(shade, x * 16, y * 16);
+ spriter.draw(background, x * 16, y * 16);
}
}
spriter.draw(gamelogo, getWidth() / 2 - (float) gamelogo.getRegionWidth() / 2, 8);
diff --git a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java
index 30c346b32e7d9fe835e557370cb9e9fa5b51b9c5..778a44d78fcae10d20957c173edd5946a28d8a6a 100644 (file)
public class Assets {
public static JsonReader jsonReader = new JsonReader();
+
+ private static GlyphLayout glyphLayout = new GlyphLayout();
+
+ static BitmapFont minecraftFont;
+
public static Sprite[][] playerSprite = new Sprite[2][4];
+ public static Sprite[][] pigSprite = new Sprite[2][2];
+ public static Sprite fallingSandSprite;
+ public static Sprite fallingGravelSprite;
public static HashMap<String, TextureRegion> textureRegions = new HashMap<>();
public static ArrayMap<String, Rectangle> guiMap = new ArrayMap<>();
- public static Sprite[][] pigSprite = new Sprite[2][2];
- static BitmapFont minecraftFont;
- private static GlyphLayout glyphLayout = new GlyphLayout();
private static TextureRegion flippedRegion(Texture texture, int x, int y, int width, int height) {
return new TextureRegion(texture, x, y + height, width, -height);
}
+ private static Sprite flippedSprite(Texture texture) {
+ Sprite sprite = new Sprite(texture);
+ sprite.flip(false, true);
+ return sprite;
+ }
+
+ private static Sprite flippedSprite(TextureRegion texture) {
+ Sprite sprite = new Sprite(texture);
+ sprite.flip(false, true);
+ return sprite;
+ }
+
private static void loadPlayer() {
Texture plTex = new Texture(Gdx.files.internal("mobs/char.png"));
//LOOK TO LEFT
//head
- playerSprite[0][0] = new Sprite(new TextureRegion(plTex, 0, 0, 12, 12));
- playerSprite[0][0].flip(false, true);
+ playerSprite[0][0] = flippedSprite(new TextureRegion(plTex, 0, 0, 12, 12));
//body
- playerSprite[0][1] = new Sprite(new TextureRegion(plTex, 0, 13, 12, 12));
- playerSprite[0][1].flip(false, true);
+ playerSprite[0][1] = flippedSprite(new TextureRegion(plTex, 0, 13, 12, 12));
//hand
- playerSprite[0][2] = new Sprite(new TextureRegion(plTex, 25, 5, 20, 20));
- playerSprite[0][2].flip(false, true);
+ playerSprite[0][2] = flippedSprite(new TextureRegion(plTex, 25, 5, 20, 20));
//leg
- playerSprite[0][3] = new Sprite(new TextureRegion(plTex, 25, 27, 20, 20));
- playerSprite[0][3].flip(false, true);
+ playerSprite[0][3] = flippedSprite(new TextureRegion(plTex, 25, 27, 20, 20));
//LOOK TO RIGHT
//head
- playerSprite[1][0] = new Sprite(new TextureRegion(plTex, 13, 0, 12, 12));
- playerSprite[1][0].flip(false, true);
+ playerSprite[1][0] = flippedSprite(new TextureRegion(plTex, 13, 0, 12, 12));
//body
- playerSprite[1][1] = new Sprite(new TextureRegion(plTex, 13, 13, 12, 12));
- playerSprite[1][1].flip(false, true);
+ playerSprite[1][1] = flippedSprite(new TextureRegion(plTex, 13, 13, 12, 12));
//hand
- playerSprite[1][2] = new Sprite(new TextureRegion(plTex, 37, 5, 20, 20));
- playerSprite[1][2].flip(false, true);
+ playerSprite[1][2] = flippedSprite(new TextureRegion(plTex, 37, 5, 20, 20));
//leg
- playerSprite[1][3] = new Sprite(new TextureRegion(plTex, 37, 27, 20, 20));
- playerSprite[1][3].flip(false, true);
+ playerSprite[1][3] = flippedSprite(new TextureRegion(plTex, 37, 27, 20, 20));
}
private static void loadPig() {
Texture pigTex = new Texture(Gdx.files.internal("mobs/pig.png"));
- pigSprite[0][0] = new Sprite(new TextureRegion(pigTex, 0, 0, 25, 12));
- pigSprite[0][0].flip(false, true);
- pigSprite[1][0] = new Sprite(new TextureRegion(pigTex, 0, 12, 25, 12));
- pigSprite[1][0].flip(false, true);
- pigSprite[0][1] = new Sprite(new TextureRegion(pigTex, 4, 26, 12, 12));
- pigSprite[0][1].flip(false, true);
- pigSprite[1][1] = new Sprite(new TextureRegion(pigTex, 16, 26, 12, 12));
- pigSprite[1][1].flip(false, true);
+ pigSprite[0][0] = flippedSprite(new TextureRegion(pigTex, 0, 0, 25, 12));
+ pigSprite[1][0] = flippedSprite(new TextureRegion(pigTex, 0, 12, 25, 12));
+ pigSprite[0][1] = flippedSprite(new TextureRegion(pigTex, 4, 26, 12, 12));
+ pigSprite[1][1] = flippedSprite(new TextureRegion(pigTex, 16, 26, 12, 12));
+ }
+
+ private static void loadFallingBlocks() {
+ fallingSandSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/sand.png"))));
+ fallingGravelSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/gravel.png"))));
}
/**
* and puts to {@link #textureRegions} HashMap
*/
private static void loadJSON() {
- JsonValue json = Assets.jsonReader.parse(Gdx.files.internal("json/texture_regions.json"));
+ JsonValue json = jsonReader.parse(Gdx.files.internal("json/texture_regions.json"));
for (JsonValue file = json.child(); file != null; file = file.next()) {
Texture texture = new Texture(Gdx.files.internal(file.name() + ".png"));
- for (JsonValue key = file.child(); key != null; key = key.next()) {
- int x = key.has("x") ? key.getInt("x") : 0;
- int y = key.has("y") ? key.getInt("y") : 0;
- int w = key.has("w") ? key.getInt("w") : texture.getWidth();
- int h = key.has("h") ? key.getInt("h") : texture.getHeight();
- textureRegions.put(key.name(), flippedRegion(texture, x, y, w, h));
+ if (file.size == 0) {
+ textureRegions.put(file.name(), flippedRegion(texture, 0, 0, texture.getWidth(), texture.getHeight()));
+ } else {
+ for (JsonValue key = file.child(); key != null; key = key.next()) {
+ int x = key.has("x") ? key.getInt("x") : 0;
+ int y = key.has("y") ? key.getInt("y") : 0;
+ int w = key.has("w") ? key.getInt("w") : texture.getWidth();
+ int h = key.has("h") ? key.getInt("h") : texture.getHeight();
+ textureRegions.put(key.name(), flippedRegion(texture, x, y, w, h));
+ }
}
}
}
minecraftFont.getData().setScale(.375f);
loadPlayer();
loadPig();
+ loadFallingBlocks();
loadJSON();
}