Giter VIP home page Giter VIP logo

pancakeengine's Introduction

Pancake Game Engine

Description

This is a lightweight 2D game engine written in C++. The engine is designed to be easy to use and highly customizable. It provides a set of basic functionalities to get you started with creating a 2D game. The engine includes a graphics renderer, audio manager, input manager and entity-component system.

Example

Demo

Dependencies

The engine requires the following dependencies:

Getting Started

To use the engine in your project, follow these steps:

  1. Clone or download the project template from here.
  2. In the root directory of the project run the following command to download all submodules.
git submodule update --init --recursive
  1. Construct your own game components by creating new classes inheriting from the Component Class.
  2. Construct a Scene Initialiser Method which will be executed on game start.
  3. In the src/main file in the template, update the template to run the game.
  4. To build the game, in the build directory in the template run the following commands.
cmake ..
make

Example

#include "pancake/pancake.hpp"
using namespace Pancake;

class MousePanHandler : public Component {
   
    public:

        MousePanHandler() : Component("MousePanHandler") {

        }

        void update(float dt) override {
            
            if (MouseListener::isMouseDragging()) {
                if (MouseListener::getDx() != 0) {Window::getScene()->getCamera()->addPosition(vec2(-MouseListener::getWorldDx(), 0.0f));}
                if (MouseListener::getDy() != 0) {Window::getScene()->getCamera()->addPosition(vec2(0.0f, -MouseListener::getWorldDy()));}
            }

        } 
        
};

// This line allows the MousePanHandler component to be loaded from a save file if necessary.
REGISTER(Component, MousePanHandler);

void TestInit(Scene* scene) {

    Entity* entity;
    MousePanHandler* mousepanhandler;
    Rigidbody* rigidbody;
    CircleCollider* circle;
    BoxCollider* box;

    // Set the scene name
    scene->setName("Test Scene");

    // Mouse Movement Handler
    entity = new Entity();
    mousepanhandler = new MousePanHandler();
    entity->addComponent(mousepanhandler);
    scene->addEntity(entity);

    // Ground
    entity = new Entity(vec2(0.0f, -5.0f), vec2(1.0f, 1.0f), 0.0f);
    rigidbody = new Rigidbody();
    box = new BoxCollider();
    box->setSize(vec2(10.0f, 1.0f));
    rigidbody->addCollider(box);
    entity->addComponent(rigidbody);
    scene->addEntity(entity);

    // Falling BoxCollider
    entity = new Entity(vec2(-1.0f, 2.0f), vec2(1.0f, 1.0f), 0.0f);
    rigidbody = new Rigidbody();
    box = new BoxCollider();
    box->setMass(1.0f);
    box->setSize(vec2(0.5f, 1.0f));
    box->setRotationOffset(0.5f);
    rigidbody->addCollider(box);
    rigidbody->setFriction(0.15f);
    rigidbody->setRestitution(0.3f);
    entity->addComponent(rigidbody);
    scene->addEntity(entity);

}

int main(int argc, char* argv[]) {
    Pancake::load(TestInit);
    Pancake::start();
}

Features

The engine provides the following features:

  • 2D graphics rendering using OpenGL.
  • 2D rigidbody physics engine supporting arbitrary collider shapes.
  • Audio playback and management using SoLoud.
  • Input management for keyboard, mouse and gamepad.
  • Entity-component system for managing game objects.
  • Resource loading from file system.
  • JSON serialization and deserialization for game data.
  • Debug drawing for collision shapes and other debugging purposes.

Contributions

Contributions are welcome! If you find any bugs or have suggestions for improvements, feel free to open an issue or submit a pull request on GitHub.

pancakeengine's People

Contributors

rohanfredriksson avatar

Stargazers

 avatar Rafael Henrique Capati avatar Juan David Barreto avatar  avatar  avatar

Watchers

 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.