Skip to content

2D dungeon game is written in Java, UI components made with JavaFx. The project follows major OOP concepts in it's implementation.

Notifications You must be signed in to change notification settings

mukulRajSharma/dungeonGame

Repository files navigation

Project

Dungeon game in Java using JavaFx platform.

Aims

  • Appreciate issues in user interface design

  • Learn practical aspects of graphical user interface programming

  • Learn more about the Java class libraries

  • Learn the application of design patterns.

The client desires an application that lets the user move a player around a dungeon and try to overcome various challenges in order to "complete" the dungeon by reaching some goal. The simplest form of such a puzzle is a maze, where the player must find their way from the starting point to the exit.

Maze

More advanced puzzles may contain things like boulders that need to be pushed onto floor switches,

Boulders

enemies that need to be fought with weapons, or collectables like potions and treasure.

Advanced dungeon

Dungeon layout

To be specific, the layout of each dungeon is defined by a grid of squares, each of which may contain one or more entities. The different types of entities are as follows:

Entity Example Description
Player Player Can be moved up, down, left, and right into adjacent squares, provided another entity doesn't stop them (e.g. a wall).
Wall Wall Blocks the movement of the player, enemies and boulders.
Exit Exit If the player goes through it the puzzle is complete.
Treasure Treasure Can be collected by the player.
Door Door Door Exists in conjunction with a single key that can open it. If the player holds the key, they can open the door by moving through it. Once open it remains so. The client will be satisfied if dungeons can be made with up to 3 doors.
Key Key Can be picked up by the player when they move into the square containing it. The player can carry only one key at a time, and only one door has a lock that fits the key. It disappears once it is used to open its corresponding door.
Boulder Boulder Acts like a wall in most cases. The only difference being that it can be pushed by the player into adjacent squares. The player is only strong enough to push one boulder at a time.
Floor switch Floor switch Switches behave like empty squares, so other entities can appear on top of them. When a boulder is pushed onto a floor switch, it is triggered. Pushing a boulder off the floor switch untriggers it.
Portal Portal Teleports entities to a corresponding portal.
Enemy Enemy Constantly moves toward the player, stopping if it cannot move any closer. The player dies upon collision with an enemy.
Sword Sword This can be picked up the player and used to kill enemies. Only one sword can be carried at once. Each sword is only capable of 5 hits and disappears after that. One hit of the sword is sufficient to destroy any enemy.
Invincibility potion Invincibility If the player picks this up they become invincible to enemies. Colliding with an enemy should result in their immediate destruction. Because of this, all enemies will run away from the player when they are invincible. The effect of the potion only lasts a limited time.

Goals

In addition to its layout, each dungeon also has a goal that defines what must be achieved by the player for the dungeon to be considered complete. Basic goals are:

  • Getting to an exit.
  • Destroying all enemies.
  • Having a boulder on all floor switches.
  • Collecting all treasure.
  • Destroying all enemies AND getting to an exit
  • Collecting all treasure OR having a boulder on all floor switches
  • Getting to an exit AND (destroying all enemies OR collecting all treasure)

If getting to an exit is one of a conjunction of conditions, it must be done last. For example, if the condition is to destroy all enemies AND get to an exit, the player must destroy the enemies then get to the exit.

Input

Your application will read from a JSON file containing a complete specification of the dungeon (the initial position of entities, goal, etc.). Example dungeons are included in the dungeons directory and the starter code contains an incomplete dungeon loader.

The dungeon files have the following format:

{ "width": width in squares, "height": height in squares, "entities": list of entities, "goal-condition": goal condition }

Each entity in the list of entities is structured as:

{ "type": type, "x": x-position, "y": y-position }

where type is one of

["player", "wall", "exit", "treasure", "door", "key", "boulder", "switch", "portal", "enemy", "sword", "invincibility"]

The door, key, and portal entities include an additional field id containing a number. Keys open the door with the same id (e.g. the key with id 0 opens the door with id 0). Portals will teleport entities to the one other portal with the same ID.

The goal condition is a JSON object representing the logical statement that defines the goal. Basic goals are:

{ "goal": goal }

where goal is one of

["exit", "enemies", "boulders", "treasure"]

In the case of a more complex goal, goal is the logical operator and the additional subgoals field is a JSON array containing subgoals, which themselves are goal conditions. For example,

{ "goal": "AND", "subgoals":
  [ { "goal": "exit" },
    { "goal": "OR", "subgoals":
      [ {"goal": "enemies" },
        {"goal": "treasure" }
      ]
    }
  ]
}

Note that the same basic goal can appear more than once in a statement.

You can extend this format to include additional information if you wish, but your application should still work with files in the original format.

User interface

The UI component of this project will be implemented in JavaFX. The starter code contains a very basic UI showing how a player can be moved around with the arrow keys, but it is missing many features (the player can walk through walls for one).

The client has given you free reign over the visual design of the program. Included in the starter code are some example assets, but you are free to use different ones. You can find them elsewhere or even create your own. The examples above came from here.

Domain modelling and backend implementation

Based on your requirements analysis, and all feedback you have received, you will produce a domain model for the backend component of your project in the form of a conceptual UML class diagram, implement it in Java and write JUnit tests to test its functionality.

The JUnit tests should be placed into the "src/test" directory, using package "test". The dryrun will check your tests pass. It is important you follow this structure, since we will run automated coverage checking on your program.

About

2D dungeon game is written in Java, UI components made with JavaFx. The project follows major OOP concepts in it's implementation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages