A modular 2D world-editing tool built with Python and Pygame. Designed for painting tiles, navigating with a minimap, managing terrain types, and generating random worlds.
This project is a tile-based world editor. Built using Python and Pygame. Supports painting, panning, minimap navigation, and random world generation. Includes a start menu, toolbar, minimap, and scrollable UI elements. Designed with a modular architecture for easy modification and expansion.
Fixed-size tile grid (100 × 80).
Integer-based terrain types:
Water
Grass
Dirt/Mountain
Sand
Stone
Produceral world generation using OpenSimplex noise:
Radial fallof to force islands shapes
Height thresholds for terrain assignment
Automatic sand generation on coastlines
Start screen with clickable buttons. Toolbar for selecting: Terrain types Brush sizes Scrollable toolbar for many options. Minimap showing: World overview Current camera viewport
Real-time scaled overwiew of the entire world. Color-coded by terrain type.
Left-click painting
Continuous painting while dragging.
Square brush sizes :
1 2 4 8 16
Left Click → Paint tile
Left Click + Drag → Continuous painting
Toolbar Buttons → Select terrain / brush
Time button → Play/pause time
Window Close Button → Quit the program
main.py
The primary game loop.
Handles all input (painting, panning, minimap interaction).
Controls app states (START → GAME).
Manages rendering and event flow.
config_cg.py
Stores constants, sizes, colors, button configs.
assets/loader_cg.py
Loads raw image assets.
Scales assets according to tile size.
world/world_state_cg.py
Core world class.
Holds grid, camera position, brush and terrain state.
Handles paint operations.
world/generation_cg.py
Generates a random world grid.
rendering/draw_world_cg.py
Draws every tile and world layer.
Applies camera offsets.
ui/toolbar_cg.py
Draws the toolbar.
Detects toolbar clicks.
Handles brush/terrain selection.
ui/minimap_cg.py
Renders minimap.
Processes clicks and drag for camera navigation.
ui/start_screen_cg.py
Displays the start menu.
Handles start button interactions.
Python 3.9+
Pygame
numpy
opensimplex
pip install pygame numpy opensimplex
python main.py
START → Shows start screen buttons. GAME → Active world editing mode.
Mouse position is converted into grid coordinates using: grid_x = (mouse_x + camera_x) // tile_size grid_y = (mouse_y + camera_y) // tile_size
Right-click dragging calculates delta between frames. Camera offset is clamped to stay inside world boundaries.
Handles: Click → Move camera Drag → Continuous camera movement Drag anchor (DRAG_START) for smooth scrolling
Buttons define: Terrain type Brush size Scroll offset stores toolbar position.
Save / Load world to file. Undo / redo system. Multi-layer world (background, objects, decorations). Export map as image or JSON tilemap. Add animated tiles. More advanced brushes. Add sound effects and UI animations.
This project is open for personal, educational, and non-commercial use. Feel free to modify and expand it.