Skip to content

giocld/gspengine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gspengine

A lightweight 2D game engine written in C++20 with OpenGL 3.3 Core.

Features

  • Sprite rendering -- batched instanced drawing with orthographic projection
  • Texture loading -- from files (stb_image) or procedurally generated solid colors
  • Input -- keyboard via GLFW
  • Audio -- sound loading and playback via SoLoud
  • ECS -- entity-component-system with sparse set storage, built-in components for position, velocity, sprites, gravity, colliders, and tags
  • Scripting -- Lua 5.4 integration via Sol2
  • Fixed timestep -- 60 FPS game loop

Dependencies

All fetched automatically via CMake FetchContent:

Building

cmake -B build
cmake --build build

Demos

helloworld

Minimal engine test -- draws a sprite, plays a sound, responds to keyboard input.

./build/helloworld

platformer

A Mario-inspired 2D platformer demonstrating the ECS with physics, gravity, and AABB collision. Features a procedurally generated level with ground, floating blocks, pipes, a staircase, and a flagpole.

platformer demo

./build/platformer

Controls: Arrow keys or WASD to move, Space or W or Up to jump, Escape to quit.

Project Structure

src/
  Engine.h/.cpp              -- core engine, game loop
  GraphicsManager.h/.cpp     -- OpenGL rendering, sprites, textures
  InputManager.h/.cpp        -- keyboard input
  SoundManager.h/.cpp        -- audio via SoLoud
  ScriptManager.h/.cpp       -- Lua scripting via Sol2
  ResourceManager.h/.cpp     -- asset path resolution
  Types.h                    -- common type aliases
  ECS/
    Entity.h                 -- EntityID type
    Component.h              -- component base, type IDs
    Registry.h               -- entity registry, sparse set storage
    PositionComponent.h      -- 2D position
    VelocityComponent.h      -- 2D velocity
    SpriteComponent.h        -- texture name + dimensions
    GravityComponent.h       -- gravity acceleration
    ColliderComponent.h      -- AABB dimensions
    PlayerTag.h              -- player marker
    StaticTag.h              -- static/immovable marker
demo/
  helloworld.cpp             -- basic engine demo
  platformer.cpp             -- 2D platformer demo
assets/
  shaders/                   -- vertex and fragment shaders

About

A lightweight 2D game engine written in C++20 with OpenGL 3.3 Core.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors