From 56b2346e5c68f6ed4c112abce46eb1cbb614de2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 11 Feb 2021 12:02:22 +0100 Subject: code analysis --- src/se/liu/gusso230/tetris/Board.java | 8 ++++---- src/se/liu/gusso230/tetris/Poly.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/se') diff --git a/src/se/liu/gusso230/tetris/Board.java b/src/se/liu/gusso230/tetris/Board.java index c730958..da5606c 100644 --- a/src/se/liu/gusso230/tetris/Board.java +++ b/src/se/liu/gusso230/tetris/Board.java @@ -40,7 +40,7 @@ public class Board { System.out.println("tick"); if (state == GameState.RUNNING) { if (falling == null) { - newFalling(); + createFalling(); } else { moveFalling(); } @@ -49,7 +49,7 @@ public class Board { private void moveFalling() { fallingY += 1; - if (hasFallingCollision() || !falling.inside(fallingX, fallingY, 0, width - 1, 0, height - 1)) { + if (hasFallingCollision() || !falling.isInside(fallingX, fallingY, 0, width - 1, 0, height - 1)) { fallingY -= 1; placeAt(falling, fallingX, fallingY); falling = null; @@ -57,7 +57,7 @@ public class Board { notifyListeners(); } - private void newFalling() { + private void createFalling() { falling = tetrominoMaker.getRandomPoly(RND); fallingX = (width - falling.getBoundingBoxSize()) / 2; fallingY = -1; @@ -85,7 +85,7 @@ public class Board { break; } fallingX += dx; - if (!falling.inside(fallingX, fallingY, 0, width - 1, 0, height - 1) + if (!falling.isInside(fallingX, fallingY, 0, width - 1, 0, height - 1) || hasFallingCollision()) { fallingX -= dx; diff --git a/src/se/liu/gusso230/tetris/Poly.java b/src/se/liu/gusso230/tetris/Poly.java index 6f8bece..734b25e 100644 --- a/src/se/liu/gusso230/tetris/Poly.java +++ b/src/se/liu/gusso230/tetris/Poly.java @@ -53,7 +53,7 @@ public class Poly { * @param minY The y position of the "minimum" corner. * @param maxY The y position of the "maximum" corner. */ - public boolean inside(int posX, int posY, int minX, int maxX, int minY, int maxY) { + public boolean isInside(int posX, int posY, int minX, int maxX, int minY, int maxY) { if (minX > maxX) { throw new IllegalArgumentException("minX has to be smaller than or equal to maxX"); } -- cgit v1.2.1