X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameInput.java;h=e177f40cf043e410458884c8b316650f99a56638;hb=c217099d21a0703347236f2d83e4d20c266f9be1;hp=bded5818b071d57a703cba3a9dc7a4af1fec2bba;hpb=e7be8067d83f2a39c237ec7afbe115a846a74f3d;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index bded581..e177f40 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -2,9 +2,10 @@ package ru.deadsoftware.cavecraft.game; 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 { @@ -78,6 +79,10 @@ public class GameInput { else CaveGame.STATE = AppState.GAME_PLAY; break; + case Input.Keys.G: + gameProc.mobs.add(new Pig(gameProc.cursorX*16, gameProc.cursorY*16)); + break; + case Input.Keys.ESCAPE: case Input.Keys.BACK: CaveGame.STATE = AppState.GOTO_MENU; break; @@ -107,7 +112,7 @@ public class GameInput { screenY= 0 && item < Items.BLOCKS.size) { for (int i = 8; i > 0; i--) { gameProc.player.inventory[i] = gameProc.player.inventory[i - 1]; @@ -116,13 +121,12 @@ public class GameInput { } } 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) { @@ -151,12 +155,30 @@ public class GameInput { } 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; + } } }