just_game_engine 1.0.0
just_game_engine: ^1.0.0 copied to clipboard
A comprehensive 2D game engine for Flutter. Includes rendering, physics, collision detection, animations, particles, sprite sheets, scene graph, ECS, input management, audio, asset management, and networking.
Changelog #
All notable changes to the Just Game Engine will be documented in this file.
1.0.0 - 2026-02-16 #
Added - Core Systems #
-
Engine Core
- Main
Enginesingleton class for orchestrating all subsystems GameLoopwith fixed timestep (60 UPS) and variable renderingTimeManagerfor delta time tracking and FPS calculationSystemManagerfor coordinating subsystems- Full lifecycle management (initialize, start, pause, resume, stop, dispose)
- Engine state machine with 6 states (uninitialized, initializing, initialized, running, paused, error)
- Main
-
Rendering Engine
- Canvas-based 2D rendering system
Cameraclass with pan, zoom, rotation, and lookAt functionality- Layer-based rendering with Z-order sorting
- Built-in renderables:
CircleRenderable,RectangleRenderable,LineRenderable,TextRenderable,CustomRenderable GameWidgetfor Flutter integration with CustomPainter- Debug mode with bounding boxes and coordinate grids
- Background color support
- FPS display overlay
Added - Advanced Features #
-
Sprite System
Spriteclass for image rendering with source rectanglesSpriteSheetfor managing sprite atlasesNineSliceSpritefor scalable UI elements- Horizontal and vertical flipping support
- Static
fromAssetmethod for easy loading
-
Animation System
- Base
Animationclass with play, pause, stop, reset controls SpriteAnimationfor frame-based sprite animations:- Automatic frame cycling based on normalized time
fromSpriteSheet()factory method for easy creation- Support for variable frame counts (any number of frames)
- Configurable frame dimensions (width/height)
- Manual frame list support via
List<Rect>frames parameter
- Generic
TweenAnimation<T>with custom lerp functions - Property tweens:
PositionTween,RotationTween,ScaleTween,OpacityTween,ColorTween AnimationSequencefor chaining animationsAnimationGroupfor parallel animationsEasingsclass with 15+ easing functions:- Linear
- Quadratic (in, out, in-out)
- Cubic (in, out, in-out)
- Quartic (in, out, in-out)
- Sine (in, out, in-out)
- Exponential (in, out, in-out)
- Elastic (in, out, in-out)
- Bounce (in, out, in-out)
- Loop and ping-pong support
- Speed control (0.1x - 5.0x) with dynamic adjustment
- Normalized time (0.0 - 1.0) for progress tracking
- Completion callbacks
- Base
-
Particle Effects
ParticleEmitterwith configurable emission rate and lifetime- Individual
Particleclass with full lifecycle - Size gradient support (start → end)
- Color gradient support with smooth transitions
- Gravity and velocity simulation
- Multiple particle shapes: circle, square, star
- Built-in effect presets:
- Explosion (burst of orange/yellow particles)
- Fire (rising orange flames with flicker)
- Smoke (upward gray particles with fade)
- Sparkle (twinkling yellow/white particles)
- Rain (falling blue droplets)
- Snow (gentle falling white flakes)
- Custom particle system creation
-
Physics Engine
PhysicsBodyrigid body class- Circular collision detection
- Elastic collision resolution with restitution
- Mass, velocity, drag, and radius properties
- Gravity simulation (configurable)
- Debug rendering with:
- Body visualization (green = active, red = inactive)
- Velocity vector arrows
- Collision boundary circles
- Broad-phase and narrow-phase collision optimization
-
Scene Graph
- Hierarchical
SceneNodestructure - Parent-child transform relationships
- Local and world-space coordinate systems
- Transform propagation (position, rotation, scale)
SceneEditorfor scene managementScenecontainer class- Node finding by name (recursive search)
- Active/inactive state per node
- Depth calculation
- Custom update callbacks per node
- Renderable attachment to nodes
- Hierarchical
-
Entity-Component System (ECS)
Worldclass for managing all entities and systemsEntityclass representing game objects with componentsComponentbase class for pure data containersSystembase class for processing logic- Entity lifecycle management (create, destroy, query)
- Component filtering and queries
- System priority and ordering
- Entity statistics and debugging
- 13 built-in components:
TransformComponent- Position, rotation, scale with transform methodsVelocityComponent- Velocity vector with max speed and angle utilitiesRenderableComponent- Links to renderable objects with sync optionsPhysicsBodyComponent- Radius, mass, restitution, drag, collision layersTagComponent- Simple string tagging for entity identificationLifetimeComponent- Time-based entity expirationHealthComponent- HP system with damage, heal, and invulnerabilityParentComponent- Parent reference with local offset and rotationChildrenComponent- Child entity list managementInputComponent- Movement direction and button stateAnimationStateComponent- Current animation state trackingSpriteComponent- Sprite path, frame, flip flags, and tint color
- 9 built-in systems:
MovementSystem- Applies velocity to transform with max speed clampingRenderSystem- Renders entities with transform syncLifetimeSystem- Updates lifetime and destroys expired entitiesPhysicsSystemECS- Full physics with gravity, drag, collision detection/resolution, layer-based filteringHierarchySystem- Propagates parent transforms to childrenHealthSystem- Health regeneration and death handlingAnimationSystemECS- Animation time updatesBoundarySystem- World boundary enforcement with 4 behaviors (clamp, bounce, wrap, destroy)
- Data-oriented architecture for performance
- Composition over inheritance design
- Query system for finding entities by components
- Example implementation in
ecs_example.dart
Added - Supporting Systems #
-
Input Management
InputManagermain coordinator with subsystem accessKeyboardInputwith key press/hold/release detection- Key state tracking with previous frame comparison
- Horizontal and vertical axis support for WASD/Arrow keys
MouseInputwith position, button, and scroll tracking- Mouse delta and scroll delta calculation
- Support for left, right, and middle mouse buttons
- Screen-to-world coordinate conversion support
TouchInputwith multi-touch support- Touch point tracking with pressure and size
- Touch start/end events per frame
ControllerInputwith gamepad support- Analog stick support (left/right sticks)
- Trigger and button detection
- Configurable dead zone for analog inputs
- Event callback system for custom input handling
- Automatic integration with
GameWidgetvia Focus and Listener - Input state updates each frame in game loop
-
Audio Engine
AudioEnginemain coordinator with multi-channel mixingAudioClipwrapper for individual audio playback controlSoundEffectManagerfor managing sound effectsMusicManagerfor background music with fade effectsAudioMixerfor volume and mute control- 5 audio channels: Master, Music, SFX, Voice, Ambient
- Per-channel volume control with independent mute/unmute
- Sound effect pooling with 10 concurrent players
- Automatic cleanup of finished audio clips
- Music fade in/out support (configurable duration)
- Looping support for music and ambient sounds
- Built on
audioplayerspackage (^6.1.0) - Supports MP3, WAV, OGG, FLAC audio formats
- State tracking (stopped, playing, paused)
- Integration methods:
playSfx(),playMusic(),stopMusic(),setMasterVolume()
-
Asset Management
AssetManagerfor loading and caching game resourcesAssetbase class with load/unload lifecycleImageAssetfor loading PNG/JPG images withui.ImageAudioAssetfor loading audio files as binary dataTextAssetfor loading plain text filesJsonAssetfor loading and parsing JSON configurationBinaryAssetfor loading raw binary dataAssetBundlefor grouping related assets- Automatic caching system to prevent duplicate loads
- Memory usage tracking per asset (in bytes)
- Cache statistics: total assets, images, audio, text, JSON, binary counts
- Total memory usage calculation
- Async loading with futures
- Integration with Flutter's rootBundle
- Support for atlas/sprite sheet metadata
- Unload functionality to free memory
- Type-safe asset retrieval methods
-
Networking (Placeholder)
- Structure for multiplayer support
- Client-server communication
Examples #
core_system_example.dart- Complete engine setup exampleecs_example.dart- Entity-Component System with physics and collisionsinput_test_example.dart- Comprehensive input system demo with keyboard, mouse, and touch
Technical Details #
- Minimum Flutter SDK: 3.11.0
- Minimum Dart SDK: 3.0.0
- External dependencies:
audioplayers: ^6.1.0(for Audio Engine)
- Singleton pattern for Engine
- Observer pattern for lifecycle events
- Component-based architecture
- Fixed timestep game loop (60 UPS)
- Variable rendering for smooth visuals
- Efficient collision detection with spatial awareness
Performance #
- Maintains 60 FPS with 20+ objects
- Handles 100+ particles simultaneously
- Real-time collision detection for multiple bodies
- Optimized rendering pipeline
- Low memory footprint