GithubHelp home page GithubHelp logo

hexmagic / megatinyengine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from megakode/megatinyengine

0.0 0.0 0.0 307 KB

Mega Tiny Engine is a small work-in-progress 2D game engine written in modern C++.

License: Other

C++ 66.22% CMake 33.78%

megatinyengine's Introduction

MegaTinyEngine

Mega Tiny Engine is a small work-in-progress 2D game engine written in modern C++.

The engine is a hobby engine meant to make me more productive in making small casual indie games, rather than relying on one of the huge all-in-one engine solutions like Unreal, GoDot and Unity, and at the same time making me code in C++ as opposed to various scripting languages used in other engines. Thus the small feature-set.

I develop the engine in tandem with a couple of small example games, as this has turned out to be a great productive and fun way for me. I therefore only add features once i actually need them in a game, and many obvious and common things might therefore be missing.

example_layers

Features

  • Scene tree
  • Layers
  • Actions with chaining and easing (Fade, Rotate, Move, etc.)
  • AABB collision
  • Kinematics
  • Sprite animation
  • Bitmap text
  • JSON based resource loading

Dependencies

Basics

See: example/example_basic.cpp for a basic example of setting up a minimal game run loop, and drawing a sprite on screen.

Every game must implement the IGame interface by subclassing it. The interface has a set of basic methods:

std::shared_ptr<Scene> createScene();
void update( float deltaTime );
void draw( SDL_Renderer *renderer );
void handleInput( const InputEvent& event );

createScene must create and setup a Scene, which is the root node for a games tree of object. A Scene is a container node composed of Layers, which again contains different GameObject subclasses such as Sprite.

Once the scene is created, the core enters its main run loop, which is illustrated in pseudo code below:

while (!quit) {
    draw_scene_layers_and_objects()
    game.draw()
    game.update(time_since_last_frame)
    game.handleInput(keys_pressed)
}
  1. Scene layers are drawn, as well as all the GameObjects that are added to them.

  2. draw() is called on IGame, which is the games chance to do any additional drawing, not related to any specific GameObject.

  3. update() is called, which is where all the game logic is usually placed. Here you can move objects, spawn bullets, etc.

  4. handleInput() is called if any input event has occurred. (Mouse / keyboard)

Sprites

megatinyengine's People

Contributors

megakode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.