diff --git a/src/app/enumerations/TeamMembers.java b/src/app/enumerations/TeamMembers.java index d868110..01fc70b 100644 --- a/src/app/enumerations/TeamMembers.java +++ b/src/app/enumerations/TeamMembers.java @@ -1,6 +1,18 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: TeamMembers.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.0 File created + * Date: 26/05/20 + */ package app.enumerations; -public enum TeamMembers { +public enum TeamMembers +{ players_2, players_4 } diff --git a/src/app/game/Game.java b/src/app/game/Game.java index 97f2af1..e5132dc 100644 --- a/src/app/game/Game.java +++ b/src/app/game/Game.java @@ -1,3 +1,14 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: Game.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.2 game controls added + * Date: 14/06/20 + */ package app.game; import app.game.control.GameControls; diff --git a/src/app/game/control/GameControls.java b/src/app/game/control/GameControls.java index a4f1a53..ba5a035 100644 --- a/src/app/game/control/GameControls.java +++ b/src/app/game/control/GameControls.java @@ -1,3 +1,14 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: GameControls.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.8 speed added + * Date: 18/06/20 + */ package app.game.control; import app.utils.AppUtils; @@ -8,11 +19,7 @@ import app.utils.material.MaterialSlider; import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; public class GameControls { diff --git a/src/app/game/options/GameOptions.java b/src/app/game/options/GameOptions.java index bdfae4b..1a05e6e 100644 --- a/src/app/game/options/GameOptions.java +++ b/src/app/game/options/GameOptions.java @@ -1,17 +1,25 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: GameOptions.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.9 compass label added + * Date: 17/06/20 + */ package app.game.options; import app.enumerations.TeamMembers; -import app.game.world.GameWorld; -import app.interfaces.GameSpeed; import app.utils.AppUtils; -import app.utils.enums.*; +import app.utils.enums.Directions; import app.utils.material.MaterialButton; import app.utils.material.MaterialElements; import app.utils.material.MaterialLabel; import javax.swing.*; import java.awt.*; -import javax.swing.Timer; public class GameOptions { diff --git a/src/app/game/world/GameWorld.java b/src/app/game/world/GameWorld.java index b36a08d..1f18594 100644 --- a/src/app/game/world/GameWorld.java +++ b/src/app/game/world/GameWorld.java @@ -1,3 +1,14 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: GameWorld.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 2.3 middle wall added + * Date: 19/06/20 + */ package app.game.world; import app.enumerations.TeamMembers; @@ -15,7 +26,6 @@ import static app.utils.AssetsUtils.IMG_BRICKS; import static app.utils.AssetsUtils.IMG_WHITE_SQUARE; -import static java.lang.String.valueOf; public class GameWorld { @@ -173,8 +183,7 @@ private void moveBallTo(Directions direction) { bounceBall(); } - } - else + } else { if (isCollidingB(mPlayers.get(i).getLocation(), mBallObj.getLocation())) { @@ -315,7 +324,7 @@ private void addTeamA() Player mPlayer1 = AppUtils.getPlayer(1); MaterialLabel mPlayerLabel = materialElements.createLabel(""); - mPlayerLabel.setIcon(mPlayer1.getBabyImage()); + mPlayerLabel.setIcon(mPlayer1.getPlayerImg()); mPlayerLabel.setLocation(0, 0); JPanel mPlayerJPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); @@ -330,7 +339,7 @@ private void addTeamA() Player mPlayer3 = AppUtils.getPlayer(3); mPlayerLabel = materialElements.createLabel(""); - mPlayerLabel.setIcon(mPlayer3.getBabyImage()); + mPlayerLabel.setIcon(mPlayer3.getPlayerImg()); mPlayerLabel.setLocation(0, 0); mPlayerJPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); @@ -355,7 +364,7 @@ private void addTeamB() Player mPlayer1 = AppUtils.getPlayer(2); MaterialLabel mPlayerLabel = materialElements.createLabel(""); - mPlayerLabel.setIcon(mPlayer1.getBabyImage()); + mPlayerLabel.setIcon(mPlayer1.getPlayerImg()); mPlayerLabel.setLocation(0, 0); JPanel mPlayerJPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); @@ -370,7 +379,7 @@ private void addTeamB() Player mPlayer3 = AppUtils.getPlayer(4); mPlayerLabel = materialElements.createLabel(""); - mPlayerLabel.setIcon(mPlayer3.getBabyImage()); + mPlayerLabel.setIcon(mPlayer3.getPlayerImg()); mPlayerLabel.setLocation(0, 0); mPlayerJPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); diff --git a/src/app/interfaces/BallCallback.java b/src/app/interfaces/BallCallback.java index 3177416..3dd1518 100644 --- a/src/app/interfaces/BallCallback.java +++ b/src/app/interfaces/BallCallback.java @@ -1,10 +1,23 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: BallCallback.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.0 File created + * Date: 02/06/20 + */ package app.interfaces; import app.utils.enums.Directions; -public interface BallCallback { +public interface BallCallback +{ - interface AutoMoveBall { + interface AutoMoveBall + { void moveTo(Directions direction); } diff --git a/src/app/interfaces/GameSpeed.java b/src/app/interfaces/GameSpeed.java index e088cfd..2a8c70a 100644 --- a/src/app/interfaces/GameSpeed.java +++ b/src/app/interfaces/GameSpeed.java @@ -1,5 +1,17 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: GameSpeed.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.0 File created + * Date: 23/06/20 + */ package app.interfaces; -public interface GameSpeed { +public interface GameSpeed +{ void onSpeedChanged(); } diff --git a/src/app/interfaces/GameTimer.java b/src/app/interfaces/GameTimer.java index 39153b5..2b82e1c 100644 --- a/src/app/interfaces/GameTimer.java +++ b/src/app/interfaces/GameTimer.java @@ -1,8 +1,21 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: GameTimer.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.0 File created + * Date: 15/06/20 + */ package app.interfaces; -public interface GameTimer { +public interface GameTimer +{ - interface GameStarted { + interface GameStarted + { void isRunning(boolean running); } diff --git a/src/app/interfaces/TeamMembersNumber.java b/src/app/interfaces/TeamMembersNumber.java index fc11db8..6496bdc 100644 --- a/src/app/interfaces/TeamMembersNumber.java +++ b/src/app/interfaces/TeamMembersNumber.java @@ -1,7 +1,19 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: TeamMembersNumber.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.0 File created + * Date: 12/06/20 + */ package app.interfaces; import app.enumerations.TeamMembers; -public interface TeamMembersNumber { +public interface TeamMembersNumber +{ void onMembersChanged(TeamMembers players); } diff --git a/src/app/menu/MenuActivity.java b/src/app/menu/MenuActivity.java index 8316b69..c1b4ec8 100644 --- a/src/app/menu/MenuActivity.java +++ b/src/app/menu/MenuActivity.java @@ -1,10 +1,25 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: MenuActivity.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.3 HelpOption Menu Added + * Date: 18/05/20 + */ package app.menu; import javax.swing.*; -import java.awt.event.*; +import java.awt.event.KeyEvent; import static app.utils.AppUtils.getAppWindow; +/** + * MenuActivity Class creates the menu from the top + * of the window + */ public class MenuActivity { @@ -40,7 +55,8 @@ public void prepareMenu() } - private JMenu fileOptionMenu() { + private JMenu fileOptionMenu() + { var fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); @@ -54,7 +70,8 @@ private JMenu fileOptionMenu() { } - private JMenu scenarioOptionMenu() { + private JMenu scenarioOptionMenu() + { var scenarioMenu = new JMenu("Scenario"); scenarioMenu.setMnemonic(KeyEvent.VK_S); @@ -62,7 +79,8 @@ private JMenu scenarioOptionMenu() { } - private JMenu editOptionMenu() { + private JMenu editOptionMenu() + { var editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); @@ -70,7 +88,8 @@ private JMenu editOptionMenu() { } - private JMenu controlsOptionMenu() { + private JMenu controlsOptionMenu() + { var controlsMenu = new JMenu("Controls"); controlsMenu.setMnemonic(KeyEvent.VK_C); @@ -78,7 +97,8 @@ private JMenu controlsOptionMenu() { } - private JMenu toolsOptionMenu() { + private JMenu toolsOptionMenu() + { var controlsMenu = new JMenu("Tools"); controlsMenu.setMnemonic(KeyEvent.VK_T); @@ -86,7 +106,8 @@ private JMenu toolsOptionMenu() { } - private JMenu helpOptionMenu() { + private JMenu helpOptionMenu() + { var helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); diff --git a/src/app/menu/MenuUI.java b/src/app/menu/MenuUI.java index 3860f59..af1a867 100644 --- a/src/app/menu/MenuUI.java +++ b/src/app/menu/MenuUI.java @@ -1,13 +1,28 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: Menu UI.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.0 File created + * Date: 17/05/20 + */ package app.menu; import javax.swing.*; import java.awt.*; +/** + * MenuUI changes the style for an element + */ public class MenuUI extends JMenuBar { @Override - protected void paintComponent(Graphics g) { + protected void paintComponent(Graphics g) + { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; diff --git a/src/app/models/Ball.java b/src/app/models/Ball.java index d71b1f6..1f6a2b0 100644 --- a/src/app/models/Ball.java +++ b/src/app/models/Ball.java @@ -1,34 +1,35 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: Ball.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.3 Ball location point deleted + * Date: 18/06/20 + */ package app.models; import app.utils.enums.Directions; import javax.swing.*; -public class Ball { +/** + * Ball Class contains all the relevant details for the ball + */ +public class Ball +{ - private ImageIcon ballImage; - private int x, y; + private final ImageIcon ballImage; - public Ball(int x, int y, ImageIcon image) { - this.x = x; - this.y = y; + public Ball(ImageIcon image) + { this.ballImage = image; } - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public ImageIcon getBallImage() { - return ballImage; - } - - public void moveTo(Directions direction) + public ImageIcon getBallImage() { - this.y++; + return ballImage; } } diff --git a/src/app/models/Player.java b/src/app/models/Player.java index aad759e..d105143 100644 --- a/src/app/models/Player.java +++ b/src/app/models/Player.java @@ -1,40 +1,34 @@ +/** + * Program: Assignment 2: Application – Baby Ball Bounce + * Filename: Player.java + * + * @author: © Teodor Grigor (GitHub - TeodorHMX1) + * Course: BSc Computing Year 1 + * Module: CSY1020 Problem Solving & Programming + * Tutor: Gary Hill + * @version: 1.6 Team variable removed + * Date: 16/06/20 + */ package app.models; import javax.swing.*; -public class Player { +/** + * Player Class contains all the relevant details for the player + */ +public class Player +{ - private ImageIcon babyImage; - private int x, y; - private int team; - private int id; + private final ImageIcon playerImg; - public Player(int x, int y, ImageIcon image, int team, int id) { - this.x = x; - this.y = y; - this.babyImage = image; - this.id = id; - this.team = team; + public Player(ImageIcon image) + { + this.playerImg = image; } - public int getY() { - return y; - } - - public int getX() { - return x; - } - - public ImageIcon getBabyImage() { - return babyImage; - } - - public int getId() { - return id; - } - - public int getTeam() { - return team; + public ImageIcon getPlayerImg() + { + return playerImg; } } diff --git a/src/app/utils/AppUtils.java b/src/app/utils/AppUtils.java index 725d37e..ac4e0f6 100644 --- a/src/app/utils/AppUtils.java +++ b/src/app/utils/AppUtils.java @@ -95,13 +95,13 @@ public static void initializePlayers() imageIcon2 = new ImageIcon(newimg2); mPlayers.clear(); - Player mPlayer1 = new Player(6, 4, imageIcon1, 1, 1); + Player mPlayer1 = new Player(imageIcon1); mPlayers.add(mPlayer1); - Player mPlayer2 = new Player(6, 11, imageIcon2, 2, 2); + Player mPlayer2 = new Player(imageIcon2); mPlayers.add(mPlayer2); - Player mPlayer3 = new Player(6, 4, imageIcon1, 1, 3); + Player mPlayer3 = new Player(imageIcon1); mPlayers.add(mPlayer3); - Player mPlayer4 = new Player(6, 11, imageIcon2, 2, 4); + Player mPlayer4 = new Player(imageIcon2); mPlayers.add(mPlayer4); } @@ -133,7 +133,7 @@ public static void initializeBall() Image image = imageIcon.getImage(); Image newimg = image.getScaledInstance(23, 23, Image.SCALE_SMOOTH); imageIcon = new ImageIcon(newimg); - mBall = new Ball(6, 5, imageIcon); + mBall = new Ball(imageIcon); } public static Ball getBall()