This is a 2D game created using Java Swing. The game features a player that can move using the arrow keys, and obstacles that the player cannot cross.
This is a 2D game created using Java Swing. The game features a player that can move using the arrow keys, and obstacles that the player cannot cross. The player must navigate through the obstacles to reach the end of the level. The game uses a custom GameComponent
class to manage the game state and draw the graphics, and a Player
class to manage the player's movement and collision detection.
The GameComponent
class uses BufferedImage
to load and draw textures for the obstacles. The Box
class extends Rectangle and holds a reference to its texture, which is a BufferedImage
. The GameComponent
class creates instances of the Box
class to generate the obstacles for the level. The GameComponent
class also has a draw method that draws the player and obstacles onto the screen.
The Player
class handles keyboard events for moving the player, and collision detection with the obstacles. The Player
class also has a draw
method that draws the player onto the screen.
This project is intended as an educational resource for learning about game development in Java. It demonstrates how to use Java Swing to create a 2D game, and covers topics such as collision detection, keyboard input, and level design.
- Java Swing
- Java 2D Graphics
- BufferedImage
To run the game, you will need to have Java installed on your computer.
- Java Development Kit (JDK) version 8 or later
- Download source code or pre-compiled JAR file from the GitHub repository
Run the game using pre-compiled JAR file. In the project directory run following command:
java -jar ./dist/java-labyrinth-game.jar
Distributed under the MIT License. See LICESNE for more information.