summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3e2a11e)
raw | patch | inline | side by side (parent: 3e2a11e)
author | fred-boy <fred-boy@protonmail.com> | |
Wed, 25 Apr 2018 10:37:48 +0000 (17:37 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Wed, 25 Apr 2018 13:09:02 +0000 (20:09 +0700) |
diff --git a/core/src/ru/deadsoftware/cavecraft/CaveGame.java b/core/src/ru/deadsoftware/cavecraft/CaveGame.java
index 88fb85036f68e72b79f3041ec721cd305611b2a0..d95c4774ab3587a8f852fa1f7245f146bd2e8d32 100644 (file)
default:
Gdx.app.exit();
}
- Gdx.app.log("CaveGame", "Folder: "+GAME_FOLDER);
+ Gdx.app.log("CaveGame", GAME_FOLDER);
Gdx.files.absolute(GAME_FOLDER).mkdirs();
setScreen(new GameScreen());
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java
index c0fc292329e7af3909ed7ea52a9d9c5d38ce1854..e177f40cf043e410458884c8b316650f99a56638 100644 (file)
import com.badlogic.gdx.Input;
import com.badlogic.gdx.utils.TimeUtils;
+import ru.deadsoftware.cavecraft.CaveGame;
import ru.deadsoftware.cavecraft.game.mobs.Pig;
import ru.deadsoftware.cavecraft.misc.AppState;
import ru.deadsoftware.cavecraft.misc.Assets;
-import ru.deadsoftware.cavecraft.CaveGame;
public class GameInput {
screenY<gameProc.renderer.camera.viewportHeight/2+Assets.creativeInv.getRegionHeight()/2) {
int ix = (int) (screenX - (gameProc.renderer.camera.viewportWidth / 2 - Assets.creativeInv.getRegionWidth() / 2 + 8)) / 18;
int iy = (int) (screenY - (gameProc.renderer.camera.viewportHeight / 2 - Assets.creativeInv.getRegionHeight() / 2 + 18)) / 18;
- int item = ix + iy * 8;
+ int item = gameProc.creativeScroll*40+(ix + iy * 8);
if (item >= 0 && item < Items.BLOCKS.size) {
for (int i = 8; i > 0; i--) {
gameProc.player.inventory[i] = gameProc.player.inventory[i - 1];
}
} else if (CaveGame.STATE == AppState.GAME_CREATIVE_INV) {
CaveGame.STATE = AppState.GAME_PLAY;
- } else {
- gameProc.touchDownX = screenX;
- gameProc.touchDownY = screenY;
- gameProc.touchDownTime = TimeUtils.millis();
- gameProc.isTouchDown = true;
- gameProc.touchDownButton = button;
}
+ gameProc.touchDownX = screenX;
+ gameProc.touchDownY = screenY;
+ gameProc.touchDownTime = TimeUtils.millis();
+ gameProc.isTouchDown = true;
+ gameProc.touchDownButton = button;
}
public void touchUp(int screenX, int screenY, int button) {
}
public void touchDragged(int screenX, int screenY) {
+ if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && Math.abs(screenY-gameProc.touchDownY)>16) {
+ gameProc.creativeScroll+=(screenY-gameProc.touchDownY)/16;
+ gameProc.touchDownX = screenX;
+ gameProc.touchDownY = screenY;
+ if (gameProc.creativeScroll<0) gameProc.creativeScroll=0;
+ if (gameProc.creativeScroll>gameProc.maxCreativeScroll)
+ gameProc.creativeScroll=gameProc.maxCreativeScroll;
+ }
}
public void scrolled(int amount) {
- gameProc.invSlot += amount;
- if (gameProc.invSlot < 0) gameProc.invSlot = 8;
- if (gameProc.invSlot > 8) gameProc.invSlot = 0;
+ switch (CaveGame.STATE) {
+ case GAME_PLAY:
+ gameProc.invSlot += amount;
+ if (gameProc.invSlot < 0) gameProc.invSlot = 8;
+ if (gameProc.invSlot > 8) gameProc.invSlot = 0;
+ break;
+ case GAME_CREATIVE_INV:
+ gameProc.creativeScroll+=amount;
+ if (gameProc.creativeScroll<0) gameProc.creativeScroll=0;
+ if (gameProc.creativeScroll>gameProc.maxCreativeScroll)
+ gameProc.creativeScroll=gameProc.maxCreativeScroll;
+ break;
+ }
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index ce88856ca4d4c086c93a92464e5b5525ab7eb323..8f5dca275d9b6c3fd3c8e3402cf5212f09cbbdb8 100644 (file)
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.utils.TimeUtils;
-import ru.deadsoftware.cavecraft.*;
+import ru.deadsoftware.cavecraft.CaveGame;
+import ru.deadsoftware.cavecraft.GameScreen;
import ru.deadsoftware.cavecraft.game.mobs.Mob;
import ru.deadsoftware.cavecraft.game.mobs.Pig;
import ru.deadsoftware.cavecraft.game.objects.Player;
public int cursorX, cursorY;
public int invSlot;
public int ctrlMode;
+ public int creativeScroll, maxCreativeScroll;
public boolean isTouchDown, isKeyDown;
public int touchDownX, touchDownY, keyDownCode;
mobs.add(new Pig(i*256, 196*16));
}
physics = new GamePhysics(this);
- if (!CaveGame.TOUCH) ctrlMode = 1;
if (CaveGame.TOUCH) {
renderer = new GameRenderer(this,320,
320*((float)GameScreen.getHeight()/GameScreen.getWidth()));
} else {
+ ctrlMode = 1;
renderer = new GameRenderer(this,480,
480*((float)GameScreen.getHeight()/GameScreen.getWidth()));
}
+ maxCreativeScroll = Items.BLOCKS.size/40;
GameSaver.save(this);
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
index 7f693c4b20f587776da84664e021bb7d9385ebc2..3ffc0aed78dda0c7914330a13d91c098cffc9037 100644 (file)
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavecraft.misc.Assets;
import ru.deadsoftware.cavecraft.CaveGame;
-import ru.deadsoftware.cavecraft.misc.Renderer;
import ru.deadsoftware.cavecraft.game.mobs.Mob;
import ru.deadsoftware.cavecraft.game.objects.Player;
+import ru.deadsoftware.cavecraft.misc.Assets;
+import ru.deadsoftware.cavecraft.misc.Renderer;
public class GameRenderer extends Renderer {
float x = camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2;
float y = camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2;
spriteBatch.draw(Assets.creativeInv, x, y);
- spriteBatch.draw(Assets.creativeScroll, x+156, y+18);
- for (int i=1; i<Items.BLOCKS.size; i++) {
- spriteBatch.draw(Items.BLOCKS.getValueAt(i).getTexture(),x+8+(i%8)*18,
- y+18+(i/8)*18);
+ spriteBatch.draw(Assets.creativeScroll, x+156,
+ y+18+(gameProc.creativeScroll*(72/(gameProc.maxCreativeScroll+1))));
+ for (int i=gameProc.creativeScroll*40; i<(gameProc.creativeScroll+1)*40; i++) {
+ if (i>0 && i<Items.BLOCKS.size)
+ spriteBatch.draw(Items.BLOCKS.getValueAt(i).getTexture(),
+ x+8+((i-gameProc.creativeScroll*40)%8)*18,
+ y+18+((i-gameProc.creativeScroll*40)/8)*18);
}
for (int i=0; i<9; i++) {
if (gameProc.player.inventory[i]>0)