diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..555872d Binary files /dev/null and b/.DS_Store differ diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..8fd17d8 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..78f6692 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + MoveTheSquare + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/MoveTheSquare/.DS_Store b/MoveTheSquare/.DS_Store new file mode 100644 index 0000000..13a80c4 Binary files /dev/null and b/MoveTheSquare/.DS_Store differ diff --git a/MoveTheSquare/.project b/MoveTheSquare/.project index 7fad32a..176a43e 100644 --- a/MoveTheSquare/.project +++ b/MoveTheSquare/.project @@ -14,4 +14,15 @@ org.eclipse.jdt.core.javanature + + + 1612931757265 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/MoveTheSquare/src/.DS_Store b/MoveTheSquare/src/.DS_Store new file mode 100644 index 0000000..47f223d Binary files /dev/null and b/MoveTheSquare/src/.DS_Store differ diff --git a/MoveTheSquare/src/edu/.DS_Store b/MoveTheSquare/src/edu/.DS_Store new file mode 100644 index 0000000..d858320 Binary files /dev/null and b/MoveTheSquare/src/edu/.DS_Store differ diff --git a/MoveTheSquare/src/edu/ycp/.DS_Store b/MoveTheSquare/src/edu/ycp/.DS_Store new file mode 100644 index 0000000..23ebe8a Binary files /dev/null and b/MoveTheSquare/src/edu/ycp/.DS_Store differ diff --git a/MoveTheSquare/src/edu/ycp/cs320/.DS_Store b/MoveTheSquare/src/edu/ycp/cs320/.DS_Store new file mode 100644 index 0000000..0f64959 Binary files /dev/null and b/MoveTheSquare/src/edu/ycp/cs320/.DS_Store differ diff --git a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.DS_Store b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.DS_Store new file mode 100644 index 0000000..cc5ec49 Binary files /dev/null and b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.DS_Store differ diff --git a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.classpath b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.classpath new file mode 100644 index 0000000..ac37fb2 --- /dev/null +++ b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.classpath @@ -0,0 +1,5 @@ + + + + + diff --git a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.project b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.project new file mode 100644 index 0000000..0091fc6 --- /dev/null +++ b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/.project @@ -0,0 +1,17 @@ + + + movethesquare + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/controllers/GameController.java b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/controllers/GameController.java index 9c20be9..ead4331 100644 --- a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/controllers/GameController.java +++ b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/controllers/GameController.java @@ -21,13 +21,24 @@ public void computeSquareMoveDirection(Game game, Square square, double mouseX, moveY = -Game.MOVE_DIST; } - game.setSquareDx(moveX); + game.setSquareDx(moveX); game.setSquareDy(moveY); } } public void moveSquare(Game model, Square square) { + if (((square.getX() + square.getWidth()) + model.getSquareDx() > model.getWidth()) || + ((square.getX() + model.getSquareDx() < 0))) { + square.setX(model.getWidth()/2); + } + square.setX(square.getX() + model.getSquareDx()); + + if (((square.getY() + square.getHeight()) + model.getSquareDy() > model.getHeight()) || + ((square.getY() + model.getSquareDy() < 0))) { + square.setY(model.getHeight()/2); + } + square.setY(square.getY() + model.getSquareDy()); } } diff --git a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/model/Game.java b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/model/Game.java index d0e3f25..2dbb944 100644 --- a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/model/Game.java +++ b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/model/Game.java @@ -1,7 +1,9 @@ package edu.ycp.cs320.movethesquare.model; public class Game { - public static final double MOVE_DIST = 2.0; // x/y distance square moves each tick + + public static final double MOVE_DIST = 6.0; // x/y distance square moves each tick + private double width, height; private Square square; private double squareDx; diff --git a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/ui/GameView.java b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/ui/GameView.java index 674d86b..d9f0e75 100644 --- a/MoveTheSquare/src/edu/ycp/cs320/movethesquare/ui/GameView.java +++ b/MoveTheSquare/src/edu/ycp/cs320/movethesquare/ui/GameView.java @@ -17,7 +17,15 @@ import edu.ycp.cs320.movethesquare.model.Square; public class GameView extends JPanel { - private static final Color MIDNIGHT_BLUE = new Color(25, 25, 112); + + + private static final Color MIDNIGHT_BLUE = new Color(212, 112, 112); + + private static final Color GRAY = new Color(105, 110, 115); + + private static final Color Sunset_Red = new Color(220, 49, 11); + private static final Color RED = new Color(100, 0, 0); + private Game model; private GameController controller; @@ -26,8 +34,13 @@ public class GameView extends JPanel { public GameView(Game model) { this.model = model; setPreferredSize(new Dimension((int) model.getWidth(), (int)model.getHeight())); - setBackground(MIDNIGHT_BLUE); + setBackground(GRAY); + + + + + // djh2-KEC119-21: changed from 30 to 45 // djh2-YCPlaptop: change from 45 to 100 this.timer = new Timer(1000 / 100, new ActionListener() { @@ -66,11 +79,18 @@ protected void paintComponent(Graphics g) { // djh2-KEC110-21: changed from GREEN to RED // djh2-YCPlaptop: change from RED to YELLOW - g.setColor(Color.YELLOW); + g.setColor(Color.GREEN); + + //g.setColor(Color.GREEN); + + + // lbradley1: change from YELLOW to BLUE + //setColor(Color.BLUE); Square square = model.getSquare(); - g.fillRect((int) square.getX(), (int) square.getY(), (int) square.getWidth(), (int) square.getHeight()); + g.fillOval((int) square.getX(), (int) square.getY(), (int) square.getWidth(), (int) square.getHeight()); + } public static void main(String[] args) { @@ -84,8 +104,10 @@ public void run() { Square square = new Square(); square.setX(300.0); square.setY(220.0); - square.setWidth(40.0); - square.setHeight(40.0); + + square.setWidth(80.0); + square.setHeight(80.0); + model.setSquare(square); GameController controller = new GameController(); @@ -103,4 +125,4 @@ public void run() { } }); } -} +} \ No newline at end of file diff --git a/README.md b/README.md index ac8163e..c561c9a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ MoveTheSquare -============= The game engine for the next great indie game. diff --git a/bin/edu/ycp/cs320/movethesquare/controllers/GameController.class b/bin/edu/ycp/cs320/movethesquare/controllers/GameController.class new file mode 100644 index 0000000..21d176f Binary files /dev/null and b/bin/edu/ycp/cs320/movethesquare/controllers/GameController.class differ diff --git a/bin/edu/ycp/cs320/movethesquare/model/Game.class b/bin/edu/ycp/cs320/movethesquare/model/Game.class new file mode 100644 index 0000000..ae060aa Binary files /dev/null and b/bin/edu/ycp/cs320/movethesquare/model/Game.class differ diff --git a/bin/edu/ycp/cs320/movethesquare/model/Square.class b/bin/edu/ycp/cs320/movethesquare/model/Square.class new file mode 100644 index 0000000..f761b8d Binary files /dev/null and b/bin/edu/ycp/cs320/movethesquare/model/Square.class differ diff --git a/bin/edu/ycp/cs320/movethesquare/ui/GameView$1.class b/bin/edu/ycp/cs320/movethesquare/ui/GameView$1.class new file mode 100644 index 0000000..2f79d48 Binary files /dev/null and b/bin/edu/ycp/cs320/movethesquare/ui/GameView$1.class differ diff --git a/bin/edu/ycp/cs320/movethesquare/ui/GameView$2.class b/bin/edu/ycp/cs320/movethesquare/ui/GameView$2.class new file mode 100644 index 0000000..678b4bb Binary files /dev/null and b/bin/edu/ycp/cs320/movethesquare/ui/GameView$2.class differ diff --git a/bin/edu/ycp/cs320/movethesquare/ui/GameView.class b/bin/edu/ycp/cs320/movethesquare/ui/GameView.class new file mode 100644 index 0000000..96ff3a8 Binary files /dev/null and b/bin/edu/ycp/cs320/movethesquare/ui/GameView.class differ