Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore the previous pull request #56

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
53b300e
change gc to final variable
limqiying Feb 26, 2018
22a1479
add KeyCode object type specification to inputList
limqiying Feb 26, 2018
aefb0df
added keycode object type specification to list
limqiying Feb 26, 2018
1b11675
cleaned up keyboard input handler code by replacing if/else with switch.
limqiying Feb 27, 2018
e754a29
added functionality to exploding bomb state
limqiying Mar 2, 2018
a2a72ec
added functionality to exploding bomb state
limqiying Mar 2, 2018
5fb18af
made exploding time an adjustable variable
limqiying Mar 2, 2018
e735dfd
cleaned up updateGame loop by separating entity loop into another
limqiying Mar 2, 2018
1f0a7de
changed entity to abstract class instead of interface
limqiying Mar 2, 2018
d5fd3bf
added isAlive capability only to killable entities, others have default
limqiying Mar 2, 2018
987e0a8
cleaned sprite code
limqiying Mar 2, 2018
66e2d2c
cached sprite positions with new SpriteSpecification class
limqiying Mar 2, 2018
bf56393
cached sprite specifications
limqiying Mar 16, 2018
892f72d
cleaned renderer
limqiying Mar 16, 2018
320ba21
change dying animation so that it plays through once and player
limqiying Mar 16, 2018
e9cd570
consolidated commit
limqiying Apr 9, 2018
5a1d236
consolidated commit
limqiying Apr 9, 2018
199b2a2
consolidated commit
limqiying Apr 9, 2018
392244c
Delete nblibraries.properties
limqiying Apr 9, 2018
b08d553
Delete build-impl.xml
limqiying Apr 9, 2018
749833b
Delete manifest.mf
limqiying Apr 9, 2018
daf2339
Delete build.xml
limqiying Apr 9, 2018
9991a4e
Delete README.md
limqiying Apr 9, 2018
6a75113
Delete LICENSE
limqiying Apr 9, 2018
dc12ab3
Delete CONTRIBUTING.md
limqiying Apr 9, 2018
da39417
Merge branch 'master' of https://github.com/limqiying/Aidos.git
limqiying Apr 9, 2018
0246c50
re-organized package hierarchy
limqiying Apr 9, 2018
e68b17e
added comments
limqiying Apr 9, 2018
da0545e
changed background colour to green -- for gras
limqiying Apr 9, 2018
1d84dea
changed player bounding box dimensions for easier movement
limqiying Apr 9, 2018
e5cf447
changed setED to void
limqiying Apr 11, 2018
dcbfc8c
added door sprites
limqiying Apr 11, 2018
76a2a37
created hidden door entity
limqiying Apr 11, 2018
ffd1459
added door to map
limqiying Apr 11, 2018
ae2aa2c
remove scene initial dimensions
limqiying Apr 18, 2018
2bb81c1
store stage controls in separate class from Sandbox
limqiying Apr 18, 2018
76061ba
newGame functionality to GameHandler
limqiying Apr 18, 2018
d5c9fba
added newGame and PauseGame Buttons
limqiying Apr 18, 2018
5fb9286
add pause and play functionality
limqiying Apr 18, 2018
012ef94
moved windowManager
limqiying Apr 18, 2018
c7345e3
create level indicator
limqiying Apr 19, 2018
7663ab0
change pause to ToggleButton
limqiying Apr 19, 2018
15ef740
remove keyboard control of buttons
limqiying Apr 19, 2018
d00fad5
added new level
limqiying Apr 19, 2018
899f6a6
moved door to futher position
limqiying Apr 19, 2018
b53f702
removed unneeded modules
limqiying Apr 19, 2018
b583129
changed root from Group to Pane for resizability
limqiying Apr 19, 2018
1efc851
moved cleaning up entities to Sandbox as method
limqiying Apr 19, 2018
614c339
consolidate sandbox method, add obervable pattern to detect game win
limqiying Apr 19, 2018
2cfda36
loads next map if hidden door is found
limqiying Apr 19, 2018
1e21582
update all entity lists in sandbox
limqiying Apr 19, 2018
c2ecb6c
fixed issue with wrong level labels
limqiying Apr 19, 2018
f84a1e8
add level adjust buttons
limqiying Apr 19, 2018
402c469
remove unneeded controls
limqiying Apr 19, 2018
88f815b
moved configurations to separate package
limqiying Apr 20, 2018
eaaf84f
changed balloon animations
limqiying Apr 20, 2018
acb5c5c
added new random map maker for testing purposes
limqiying Apr 20, 2018
05bfce9
fixed issue with incorrect pause/play labels when levels are switched
limqiying Apr 20, 2018
8f407ac
added hidden door to level3 map
limqiying Apr 20, 2018
d78dbc2
added descriptor
limqiying Apr 20, 2018
e137251
updated readme gif to most current
limqiying Apr 20, 2018
ac6167b
changed to MVC model
limqiying Apr 25, 2018
4ffc10b
observer pattern for MVC
limqiying Apr 25, 2018
be03da4
refactored game status to be kept in game handler
limqiying Apr 25, 2018
a8e027e
add life count
limqiying Apr 25, 2018
31cec26
cleaned update function
limqiying Apr 26, 2018
8d23472
DS_Store to gitignore
limqiying Oct 23, 2019
d71f28e
fixed missing gif
limqiying Oct 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

# Created by https://www.gitignore.io/api/git,netbeans,intellij,intellij+iml,intellij+all,eclipse,java

.DS_Store
### Eclipse ###

.metadata
bin/
tmp/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Aidos
A beginner friendly project with aim of creating our own version of Bomberman.

![Alt Text](https://media.giphy.com/media/xUOxf8uHAc2OIclI9a/giphy.gif)
![Alt Text](assets/img/ezgif-6-e0f2fc739fb7.gif)

## Getting Started

Expand Down
Binary file added assets/img/bomberman.mov
Binary file not shown.
Binary file added assets/img/ezgif-6-e0f2fc739fb7.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="Bomberman" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<project name="Bomberman" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<description>Builds, tests, and runs the project Bomberman.</description>
<import file="nbproject/build-impl.xml"/>
<!--
Expand Down
11 changes: 7 additions & 4 deletions src/bomberman/Bomberman.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bomberman;

import bomberman.constants.GlobalConstants;
import bomberman.scenes.Sandbox;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
Expand All @@ -11,12 +10,16 @@ public class Bomberman extends Application {
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle(GlobalConstants.GAME_NAME + GlobalConstants.GAME_VERSION);
Sandbox.setupScene();
Scene s = Sandbox.getScene();
GameHandler gh = new GameHandler();
GameController controller = new GameController(gh);
GameView view = new GameView(controller);
controller.setView(view);
controller.newGame();
Scene s = view.getScene();
primaryStage.setScene(s);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}
Expand Down
71 changes: 71 additions & 0 deletions src/bomberman/GameController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package bomberman;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class GameController implements GameObserver {

private GameHandler game;
private GameView view;
private StringProperty level, state, lives;

public GameController(GameHandler gh) {
game = gh;
gh.addObserver(this);
level = new SimpleStringProperty("");
state = new SimpleStringProperty("");
lives = new SimpleStringProperty("");
}

StringProperty levelLabel() {
return level;
}

StringProperty stateLabel() {
return state;
}

StringProperty livesLabel() {
return lives;
}

void setView(GameView view) {
this.view = view;
}

void newGame() {
game.newGame();
updateLabels();
}

void pause() {
game.stopGame();
updateLabels();
}

void play() {
game.resumeGame();
updateLabels();
}

void loadLevel(int newLevel) {
game.loadLevel(newLevel);
updateLabels();
}

public void update() {
updateLabels();
}

public void newLevel(double width, double height) {
view.resetCanvas(width, height);
updateLabels();
}

private void updateLabels() {
level.setValue("Level: " + game.getLCurrentLevel());
state.setValue("Game Status: " + game.getGameStatus());
lives.setValue("Lives: " + game.getLives());
}

}
114 changes: 114 additions & 0 deletions src/bomberman/GameHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package bomberman;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Observable;
import java.util.Observer;

import bomberman.constants.GlobalConstants;
import bomberman.constants.GlobalConstants.GameStatus;

import static bomberman.constants.GlobalConstants.GameStatus.*;
import static bomberman.constants.GlobalConstants.NUM_LEVELS;

/**
* Manages the game at the highest level, and holds information such as the
* current level, etc. When a player has won a map, it is responsible for
* loading the second map onto the window.
*
* @author tialim
*
*/

public class GameHandler implements Observer {

private MapLoader mapL;
private Sandbox sb;
private GameLoop loop;
private GameStatus state;
private Collection<GameObserver> observers;
private int lives, level = 1;

public GameHandler() {
lives = GlobalConstants.LIVES;
mapL = new MapLoader();
loop = new GameLoop();
observers = new ArrayList<GameObserver>();
}

public void update(Observable o, Object arg) {
if (sb.gameWon()) {
nextLevel();
} else if (sb.playerDead()) {
if (lives > 0) { // still have lives left
lives--;
mapL.getPlayers()
.forEach(p -> {
p.reset(); // reset player
sb.addEntityToGame(p); // reinitialize player
});
} else { // no more lives left
state = GameOver;
}
}
observers.forEach(GameObserver::update);
}

public void addObserver(GameObserver ob) {
observers.add(ob);
}

// -------- Methods for buttons and screen controls---------

void newGame() {
lives = GlobalConstants.LIVES;
loadLevel(1);
}

void stopGame() {
state = Paused;
loop.stop();
}

void resumeGame() {
state = Running;
loop.start();
}

// -------- Getters and Setters---------

int getLives() {
return lives;
}

int getLCurrentLevel() {
return level;
}

GameStatus getGameStatus() {
return state;
}

// -------- Private Methods -----------

private void nextLevel() {
if ((level) < NUM_LEVELS) {
loadLevel(++level);
}
}

void loadLevel(int newLevel) { // TODO change to private later; kept open for dev.
this.level = newLevel;

mapL.loadLevel(level);
double sceneW = mapL.getSceneWidth();
double sceneH = mapL.getSceneHeight();
observers.forEach(ob -> ob.newLevel(sceneW, sceneH));

sb = new Sandbox(this, mapL.getEntities());
stopGame();
loop.init(sb, sceneW, sceneH);
resumeGame();
}

}
104 changes: 51 additions & 53 deletions src/bomberman/GameLoop.java
Original file line number Diff line number Diff line change
@@ -1,66 +1,64 @@
package bomberman;

import bomberman.constants.GlobalConstants;
import bomberman.entity.Entity;
import bomberman.entity.staticobjects.BlackBomb;
import bomberman.gamecontroller.InputManager;
import bomberman.scenes.Sandbox;
import java.util.Iterator;
import java.util.Vector;
import javafx.animation.AnimationTimer;
import javafx.scene.canvas.GraphicsContext;

public class GameLoop {

static double currentGameTime;
static double oldGameTime;
static double deltaTime;
final static long startNanoTime = System.nanoTime();
private static double currentGameTime, oldGameTime, deltaTime, width, height;
private final long startNanoTime = System.nanoTime();
private boolean isStopped;
private AnimationTimer animationT;
private Sandbox sb;

public static double getCurrentGameTime() {
return currentGameTime;
}
public GameLoop() {
isStopped = true;
};

public static void start(GraphicsContext gc) {
GameState.gameStatus=GlobalConstants.GameStatus.Running;
new AnimationTimer() {
public void handle(long currentNanoTime) {
oldGameTime = currentGameTime;
currentGameTime = (currentNanoTime - startNanoTime) / 1000000000.0;
deltaTime = currentGameTime - oldGameTime;
gc.clearRect(0, 0, GlobalConstants.CANVAS_WIDTH, GlobalConstants.CANVAS_WIDTH);
//TODO This will have to be something like, currentScene.getEntities()
updateGame();
renderGame();
}
}.start();
}
public GameLoop( Sandbox sandbox, double w, double h) {
isStopped = true;
init(sandbox, w, h);
}

public static double getDeltaTime() {
return deltaTime * 100;
}
public void init(Sandbox sandbox, double w, double h) {
width = w;
height = h;
sb = sandbox;
animationT = new AnimationTimer() {
public void handle(long currentNanoTime) {
oldGameTime = currentGameTime;
currentGameTime = (currentNanoTime - startNanoTime) / 1000000000.0;
deltaTime = currentGameTime - oldGameTime;
Renderer.gc.clearRect(0, 0, width, height);
sb.update();
renderGame(sb);
}
};
}

public static void updateGame() {
InputManager.handlePlayerMovements();
Vector<Entity> entities = Sandbox.getEntities();
Iterator<Entity> it = entities.iterator();
//remove the current bomb
while (it.hasNext()) {
Entity entity = it.next();
if(entity instanceof BlackBomb){
boolean alive = ((BlackBomb) entity).isAlive();
if(!alive){
// not removig directly from list to prevent ConcurrentModification
it.remove();
}
}
}
}
public static double getCurrentGameTime() {
return currentGameTime;
}

public static void renderGame() {
for (Entity e : Sandbox.getEntities()) {
e.draw();
}
}
public void start() {
if (isStopped) {
animationT.start();
isStopped = false;
}
}

public void stop() {
if (!isStopped) {
animationT.stop();
isStopped = true;
}
}

public double getDeltaTime() {
return deltaTime * 100;
}

public static void renderGame(Sandbox sb) {
sb.forEach(e -> e.draw(sb));
}

}
6 changes: 6 additions & 0 deletions src/bomberman/GameObserver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package bomberman;

public interface GameObserver {
void newLevel(double width, double height);
void update();
}
2 changes: 1 addition & 1 deletion src/bomberman/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public class GameState {
public static int level;
public static Date lastSaved;
public static boolean hasUnsavedChanges;
public static GlobalConstants.GameStatus gameStatus;
public static GlobalConstants.GameStatus gameStatus = GlobalConstants.GameStatus.Running;
}
Loading