Skip to content

OsmanerdemDutar/Tank_Game-2025-JavaFX-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Tank 2025: 2D JavaFX Combat Simulator

This repository contains a fully functional 2D arcade tank combat game developed as part of the BBM 104: Introduction to Programming Laboratory II course at Hacettepe University.The gameplay involves a player-controlled tank and enemy tanks trying to destroy the player tank.

Designed with a strict engineering constraint: No visual layout tools (SceneBuilder) or markup languages (FXML/CSS) were used. The entire Graphical User Interface (GUI) and game rendering loop are programmatically constructed using pure JavaFX 8 code.

๐Ÿš€ Technical Highlights & Core Mechanics

This project acts as a lightweight 2D game engine, implementing core systems required for real-time interactive simulations:

  • Custom Game Loop & Event Handling: Utilizes key listeners to capture real-time input. The player can move in 4 cardinal directions with arrow keys and fires a bullet with the "x" key. Each time a tank moves, an animation displays the thread movement.
  • Dynamic Enemy AI: Enemy entities operate on autonomous logic. With specific intervals, the enemy chooses a random direction and moves continuously until it decides to change its path. They also constantly fire projectiles at random intervals, creating a dynamic challenge.
  • Physics & Collision Detection: Custom collision algorithms govern the map logic. The game takes place in an arena surrounded by indestructible walls. It is impossible for tanks to pass through the walls. Bullets travel at a constant speed until they hit a wall or tank.
  • State Machine Management: Handles complex application states (Play, Pause, Game Over). The player starts with three lives. Pressing the "P" key brings up a pause menu, halting the game loop. Upon losing all lives, a game-over screen allows restarting via the "R" key or exiting via the "Escape" key.
  • Advanced Viewport Camera (Bonus Feature): Implements vertical and horizontal scrolling to render dynamic map environments larger than the initial window size.

๐ŸŽฌ Rendering & Visual Effects

  • Explosion Animations: Bullets hitting indestructible walls or enemy tanks trigger a temporary explosion effect before the entities are removed from the DOM[cite: 681, 683].
  • Entity Respawning: If the player is hit, an explosion occurs, a life is lost, and the player respawns at the original starting coordinates after a brief delay[cite: 684, 685].

๐Ÿ› ๏ธ Tech Stack & Constraints

  • Language: Java 8 (Oracle)
  • Framework: JavaFX (Pure Code Implementation)
  • Prohibited Tools: FXML, SceneBuilder, CSS, Swing, AWT, external JSON libraries
  • Documentation: Extensively documented using JavaDoc style.

๐ŸŽฎ Controls

  • Movement: Up, Down, Left, Right Arrow Keys
  • Fire/Shoot: X
  • Pause Game: P
  • Restart (Game Over/Pause): R
  • Exit Game: Escape

โš™๏ธ Execution

The application is designed to be compiled and executed via the Command-Line Interface (CLI).

  1. Clone the repository:
    git clone [https://github.com/OsmanerdemDutar/Tank-2025-JavaFX-Engine.git](https://github.com/OsmanerdemDutar/Tank-2025-JavaFX-Engine.git)
    cd Tank-2025-JavaFX-Engine
  2. Compile the engine:
     javac Tank2025.java    
  3. Run the simulation:
     java Tank2025    

Developed with a focus on Clean Code, custom 2D rendering mathematics, and strict architectural constraints.

About

A 2D arcade combat simulator built from scratch using pure JavaFX. Features custom collision detection, dynamic enemy AI, and state-driven rendering without external layout engines.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages