Mix Motor is a 2D game framework inspired by the classic Flixel framework, built in Odin using Raylib for rendering.
mix_motor/
โโโ engine/ # Core framework package (reusable)
โ โโโ flx_game.odin # Game engine & loop
โ โโโ flx_state.odin # State management
โ โโโ flx_object.odin # Base game object
โ โโโ flx_text.odin # Text rendering
โโโ main.odin # Example entry point
โโโ menu_state.odin # Example menu state
โโโ play_state.odin # Example play state
โโโ docs/ # Documentation
โโโ GETTING_STARTED.md
โโโ QUICK_START.md
โโโ EXAMPLES.md
โโโ FLIXEL_COMPARISON.md
โโโ PROJECT_OVERVIEW.md
โโโ TODO.md
- Using the Engine - How to use the engine in your own projects
- Getting Started - Complete beginner's guide with examples
- Quick Start - Common patterns and recipes
- Examples - 10+ complete code examples
- Flixel Comparison - Migration guide for Flixel developers
- Project Overview - Architecture and design philosophy
- TODO - Development roadmap and feature requests
# Build
./build.sh
# Or manually
odin build . -debug
# Run
./mix_motor- State Management: Organize your game into states (menus, gameplay, game over, etc.)
- Game Objects: Base
FlxObjectclass with position, velocity, and acceleration - Text Rendering:
FlxTextfor displaying text - Simple API: Easy-to-use API similar to the original Flixel
- Odin Compiler installed
- Raylib vendor library (comes with Odin)
The engine package is self-contained and can be imported into any Odin project:
import engine "path/to/mix_motor/engine"See docs/USING_ENGINE.md for a complete guide on using the engine in your projects!
For learning the framework, see docs/GETTING_STARTED.md.
Here's a simple example that creates a "Hello, World!" text:
package main
import "core:fmt"
import rl "vendor:raylib"
import engine "engine"
// PlayState is our main game state
PlayState :: struct {
using base: engine.FlxState,
}
// Create a new PlayState
play_state_new :: proc() -> ^PlayState {
state := new(PlayState)
vtable := new(engine.FlxState_VTable)
vtable.create = play_state_create
vtable.update = play_state_update
vtable.draw = play_state_draw
vtable.destroy = play_state_destroy
state.vtable = vtable
return state
}
// Override create - this is where we set up our state
play_state_create :: proc(state: ^engine.FlxState) {
play := cast(^PlayState)state
engine.flx_state_init(&play.base)
// Add a text field at position 0,0 with width 100
text := engine.flx_text_new(0, 0, 100, "Hello, World!")
engine.flx_state_add(&play.base, &text.base)
}
// In main.odin
main :: proc() {
initial_state := play_state_new()
game := engine.flx_game_init(
800, // width
600, // height
"My Game", // title
&initial_state.base, // initial state
60, // target FPS
)
engine.flx_game_run(game)
}The main game engine that handles the game loop, state management, and rendering.
engine.flx_game_init()- Initialize the game with window size, title, and initial stateengine.flx_game_run()- Start the game loopengine.flx_game_switch_state()- Switch to a different game stateengine.flx_game_set_bg_color()- Set the background color
Represents a game state (menu, gameplay, etc.). Create your own states by embedding FlxState.
create()- Called when the state is initializedupdate()- Called every frame to update logicdraw()- Called every frame to renderdestroy()- Called when the state is being destroyedengine.flx_state_add()- Add an object to the state
The base type for all game entities. Has position, velocity, and acceleration.
x, y- Positionwidth, height- Sizevelocity- Movement speed per secondacceleration- Acceleration per secondactive- Whether the object updatesvisible- Whether the object is drawnexists- Whether the object exists
A text rendering object that inherits from FlxObject.
engine.flx_text_new(x, y, width, text, font_size)- Create a new text objectengine.flx_text_set_text()- Change the textengine.flx_text_set_color()- Change the color
The framework uses a component-based architecture with virtual function tables for polymorphism:
- Game Loop: The
FlxGamemanages the main game loop - States: Each state manages its own objects and logic
- Objects: All game entities inherit from
FlxObject - Rendering: Raylib handles low-level rendering
package {
import org.flixel.*;
public class PlayState extends FlxState {
override public function create():void {
add(new FlxText(0,0,100,"Hello, World!"));
}
}
}import engine "engine"
PlayState :: struct {
using base: engine.FlxState,
}
play_state_create :: proc(state: ^engine.FlxState) {
play := cast(^PlayState)state
engine.flx_state_init(&play.base)
text := engine.flx_text_new(0, 0, 100, "Hello, World!")
engine.flx_state_add(&play.base, &text.base)
}Version 0.1.0 (Current) โ
- Basic game loop, states, text rendering
Version 0.2.0 (Next) ๐ง
- Sprite support
- Animation system
- More examples
Future Versions
- Collision detection
- Tilemap support
- Audio system
- Camera system
- Particle effects
See docs/TODO.md for the complete roadmap!
Contributions are welcome! Check out docs/TODO.md for feature ideas.
High Priority:
- FlxSprite implementation
- Collision detection
- More examples
- Raylib: raylib.com
- Odin: odin-lang.org
- Original Flixel: flixel.org
This project is open source and available under the MIT License.
Happy Game Making! ๐ฎโจ