DEADSOFTWARE

Better creative inventory scrolling
authorfred-boy <fred-boy@protonmail.com>
Thu, 26 Apr 2018 07:35:48 +0000 (14:35 +0700)
committerfred-boy <fred-boy@protonmail.com>
Thu, 26 Apr 2018 07:35:48 +0000 (14:35 +0700)
core/src/ru/deadsoftware/cavecraft/game/GameInput.java
core/src/ru/deadsoftware/cavecraft/game/GameProc.java
core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java

index 08f6e368f0fbb067a821b962f68594412be56aa5..9aa90f2b1d335a64d16e1e49ac8bbf3f39366e80 100644 (file)
@@ -125,7 +125,7 @@ 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 = gameProc.creativeScroll*40+(ix + iy * 8);
+                int item = gameProc.creativeScroll*8+(ix + iy * 8);
                 if (ix>=8 || ix<0 || iy<0 || iy>=5) item=-1;
                 if (item >= 0 && item < Items.BLOCKS.size) {
                     for (int i = 8; i > 0; i--) {
@@ -160,9 +160,7 @@ public class GameInput {
                     screenX<gameProc.renderer.camera.viewportWidth/2+Assets.creativeInv.getRegionWidth()/2 &&
                     screenY>gameProc.renderer.camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2 &&
                     screenY<gameProc.renderer.camera.viewportHeight/2+Assets.creativeInv.getRegionHeight()/2) {
-                if (screenX<gameProc.renderer.camera.viewportWidth/2+Assets.creativeInv.getRegionWidth()/2-24)
-                    gameProc.creativeScroll -= (screenY - gameProc.touchDownY) / 16;
-                else gameProc.creativeScroll += (screenY - gameProc.touchDownY) / 16;
+                gameProc.creativeScroll -= (screenY - gameProc.touchDownY) / 16;
                 gameProc.touchDownX = screenX;
                 gameProc.touchDownY = screenY;
                 if (gameProc.creativeScroll < 0) gameProc.creativeScroll = 0;
index 5ba62a2e1307fc7dd16e0169dc0624960ce46217..4b841bd47af0fd7103b3ac70b50f9cd73e67adc4 100644 (file)
@@ -53,7 +53,7 @@ public class GameProc implements Serializable{
             renderer = new GameRenderer(this,480,
                     480*((float)GameScreen.getHeight()/GameScreen.getWidth()));
         }
-        maxCreativeScroll = Items.BLOCKS.size/40;
+        maxCreativeScroll = Items.BLOCKS.size/8;
         GameSaver.save(this);
     }
 
index 3ba99c3ec2c999dc7faa9866e3cb3bc5cc1d4430..38680f94db6ddf347491736c18872f5c80e544b1 100644 (file)
@@ -122,11 +122,11 @@ public class GameRenderer extends Renderer {
         spriteBatch.draw(Assets.creativeInv, x, y);
         spriteBatch.draw(Assets.creativeScroll, x+156,
                 y+18+(gameProc.creativeScroll*(72/gameProc.maxCreativeScroll)));
-        for (int i=gameProc.creativeScroll*40; i<(gameProc.creativeScroll+1)*40; i++) {
+        for (int i=gameProc.creativeScroll*8; i<(gameProc.creativeScroll+1)*40; i++) {
             if (i>0 && i<Items.BLOCKS.size)
                 spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.getValueAt(i).getTexture()],
-                        x+8+((i-gameProc.creativeScroll*40)%8)*18,
-                        y+18+((i-gameProc.creativeScroll*40)/8)*18);
+                        x+8+((i-gameProc.creativeScroll*8)%8)*18,
+                        y+18+((i-gameProc.creativeScroll*8)/8)*18);
         }
         for (int i=0; i<9; i++) {
             if (gameProc.player.inventory[i]>0)