Chess 2D Game
3 weeks | Solo Project | Completed
Designed and built a complete 2D Chess game in Java, featuring a custom rendering system using AWT and Swing, full rule implementation (castling, check, checkmate, pawn promotion), and a turn-based game loop — all without any external game engine. Includes an intuitive player interface and a basic AI opponent driven by handcrafted decision rules.
View Github Contact to build a similar gameProject Overview
This project is a fully handcrafted 2D Chess game developed during my second year of university as a way to explore core programming concepts.
Built entirely in pure Java without any game engine, it uses Java AWT and Swing for rendering and user interaction. The game supports complete chess rules—including castling, check, checkmate, and pawn promotion—and features a simple AI opponent based on self-defined move evaluation logic.
It was an important step in my journey to understanding OOP, game state management, and user input handling in desktop applications.
Key Features
- Frame-Based Game Loop
- Built with Pure Java
- Turn-Based System
- Manual 2D Rendering
- Mouse Interaction
- Complete Chess Logic
- AI with Situational Awareness
- Encoded Asset Protection
- Self-Tested
Challenges & Solutions
Challenge: Creating a smooth and consistent game loop
Creating a smooth and consistent game loop for a turn-based 2D game without using any game engine or built-in game framework.
Solution: Built a custom frame-based loop using System.nanoTime() to calculate frame timing and dynamically adjust Thread.sleep() to maintain a stable 144 FPS. Separated logic into tick() and render() methods, allowing real-time updates, rendering, and frame tracking using minimal Java tools.
Challenge: Creating a responsive 2D interface
Creating a responsive 2D interface using only Java AWT and Swing, without relying on any modern GUI/game frameworks.
Solution: Manually rendered all graphics using Java2D and handled user input through low-level mouse listeners, achieving smooth interactivity with minimal dependencies.
Challenge: Implementing full chess rules
Implementing full chess rules, including complex mechanics like castling, checkmate, and pawn promotion, without using a game engine or reference libraries.
Solution: Built a custom rule engine using a 2D array to represent the board, combined with object-oriented logic for each piece to validate legal moves and enforce special rules.
Challenge: Preventing asset extraction
Preventing users from accessing and extracting image assets directly from the game files.
Solution: Encoded all image assets using Base64 and stored them in .dat files, then decoded them at runtime, making asset scraping significantly harder.
Challenge: Creating a chess AI
Creating a chess AI that behaves logically under various scenarios (attack, defense, promotion, castling) without any help from standard AI techniques or libraries.
Solution: Implemented a condition-based decision tree that checks for safe kill moves, possible promotions, and fallback options. The AI also evaluates threat levels before confirming a move, making decisions that resemble beginner-level human reasoning.
Challenge: Maintaining game state and turn logic
Maintaining game state and turn logic consistently across all moves and special cases.
Solution: Used a centralized 2D board array and clearly defined turn-switching logic to manage player flow, track piece positions, and update game outcomes accurately.
Project Highlights
Frame-Based Game Loop: Implemented a frame-timed game loop targeting 144 FPS using System.nanoTime(), with real-time rendering, game updates, and FPS tracking.
Custom Chess Logic: Implemented full chess rules including castling, check, checkmate, and pawn promotion using manually written movement validation logic.
AWT/Swing-Based GUI: Built a responsive 2D interface using Java AWT and Swing, managing rendering, mouse input, and real-time feedback without any GUI libraries.
Rule-Based AI Decision System: Designed an AI that simulates strategic decision-making by checking kill potential, avoiding threats, performing castling, and promoting pawns. It mimics basic human playstyle without algorithms like Minimax.
Runtime Asset Decoding System: Implemented a custom asset protection mechanism by encoding all image assets in Base64, storing them in .dat files, and decoding only during runtime to prevent direct access.
Turn-based & Game State Control: Developed a robust turn system handling alternating moves, rule enforcement, win/loss conditions, and invalid move prevention.
Project Info
Category: Game 2D Application
My Role: Game Developer
Duration: 3 weeks
Team Size: Solo Project
Technologies: Java, Java AWT, Java Swing
Core Implementations: Custom Game Loop, 2D Chessboard Engine, Object-Oriented Chess Pieces, Turn-Based Game System, Rule-Based AI System, Encoded Asset Handling, AWT/Swing UI
Architecture & Design: OOP Modular Design, Separation of Concerns, Reusable Component System, Inheritance & Composition
Quick Stats: Dev Time: 3 weeks, Type: 2D Chess Game, Systems: 20+, Built By: 100% Solo, Graphics: Custom Java2D, Engine: None (Pure Java), Architecture: OOP-based, Codebase: Medium-scale, Audio: No, Asset Handling: Encoded Image