This is the sixth project in my Godot learning journey. This project is a classic Sokoban implementation that focuses on Grid-based movement, JSON data parsing, and Level Management in Godot 4.
In this project, I shifted focus from physics to logic and data structures:
- Data-Driven Level Loading: Implemented a system to read and parse JSON files to dynamically generate puzzle layouts, separating game logic from level data.
- Tile-Based Grid Movement: Developed a precise movement system where the player and boxes interact within a strict grid, handling collision checks before any movement occurs.
- Level Manager Pattern: Created a centralized manager to track game states (moves, boxes on targets, level completion) and handle scene transitions.
- Resource & Data Organization: Structured the project to manage various tile types and puzzle configurations efficiently using Godot's resource system.
- Signal-Driven HUD: Used signals to update the UI (move counter, level name) in real-time as the player interacts with the grid.
- Engine: Godot 4.5
- Language: GDScript
- Format: JSON for Level Data
- Key Concepts: Grid Logic, Data Parsing, Singleton (Globals), and Signal-driven UI.
The core of this project is the ability to load complex levels from external data. This approach allows for easy level creation without modifying the core game scene:
# Professional approach to loading level data from JSON
func load_level_data(level_index: int) -> Dictionary:
var file_path = "res://Data/level_%d.json" % level_index
if not FileAccess.file_exists(file_path):
return {}
var file = FileAccess.open(file_path, FileAccess.READ)
var json_string = file.get_as_text()
file.close()
var json = JSON.new()
var error = json.parse(json_string)
if error == OK:
return json.data
else:
print("JSON Parse Error: ", json.get_error_message())
return {}- Course: Developed as part of the "Jumpstart to 2D Game Development" course by Richard Allbert and Martyna Olivares.
- Assets: Game assets provided by the course instructor.