Classic Super Mario Bros. game implemented with Java for CS319-Object-Oriented Software Engineering course.
You can visit wikipedia page or Super Mario wiki page for detailed information about the game.
This version contains the following intentional Bugs:
Enemies do not turn at collision with objects (easy to see on Map 2 - the Gumba at the start).
Mario has evolved, he can jump infinitly often in the air now, atleast while on the upwards movement. He still can't jump while falling. But he shouldn't be able to do multiple jumps at all.
Whenever Mario gets a Coin from the ?-Blocks, he does get the Points for it BUT the Coin counter in the upper right corner does not increase. Mario really needs the counter to work to get a 1UP! when hitting 100 Coins!
This Bug is pretty straightforward. Can be found/solved on a very short path, if the structure of the program ist known, or a slightly longer path.
Potential paths to Problem:
- GameEngine.init() -> MapManager() -> checkCollision() -> checkEnemyCollision
- GameEnige.init() -> start() -> run() -> gameLoop() -> checkCollision() -> mapManager.checkCollision() -> checkEnemyCollision()
Inside MapManager.checkEnemyCollision():
if (enemyBounds.intersects(brickBounds)) {
enemy.setVelX(enemy.getVelX());
}
should be corrected to
if (enemyBounds.intersects(brickBounds)) {
enemy.setVelX(-enemy.getVelX());
}
To find the second bug is pretty easy aswell, to solve it is a bit harder. The bug is located in Mario.jump(), but it is probably necessary to look at GameObject.updateLocation() aswell.
- GameEngine.receiveInput() -> Mario.jump()
- GameEngine.updateLocations() -> MapManager.updateLocations() -> Map.updateLocations() -> GameObject.updateLocations()
Inside Mario.jump():
public void jump(GameEngine engine) {
if(!isFalling()){
setJumping(true);
setVelY(10);
engine.playJump();
}
}
should be changed to:
public void jump(GameEngine engine) {
if(!isJumping() && !isFalling()){
setJumping(true);
setVelY(10);
engine.playJump();
}
}
Path to the Bug - not that easy to find, unless you directly navigate to the Coin class. The Bug is located in Coin.onTouch().
- GameEngine.run() -> GameEngine.gameLoop() -> GameEngine.checkCollisions() -> MapManager.checkCollisions() -> MapManager.checkPrizeContact() -> Prize.onTouch() - interface is implemented in Coin - Coin.onTouch() Additionally the Mario class has to be checked for the Method
- Mario.acquireCoin()
Inside Coin.onTouch():
public void onTouch(Mario mario, GameEngine engine) {
if(!acquired){
acquired = true;
mario.acquirePoints(point);
engine.playCoin();
}
}
the following line should be addded:
mario.acquireCoin();