Giter Site home page Giter Site logo

barrwani / dawn-engine Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 5.58 MB

A Godot-Inspired 2D OOP-based Game Engine, utilising C++ and SDL2. Key features include a node-based scene tree, quadtree for collision detection, and smart pointer utilisation for memory management.

CMake 8.44% C 8.47% C++ 18.89% Makefile 64.16% TypeScript 0.04%

dawn-engine's Introduction

Dawn Engine

Dawn Engine is a work-in-progress 2D OOP-based Game Engine, utilising C++ and SDL2. Dawn Engine is inspired by Godot.

Since this is a solo project intended for personal use, branching and versioning is not utilised.

Key features

Complete:

  • Node-based scene tree for hierarchy organisation and inheritance
  • Quadtree data structure for collision detection
  • Nodes all in a vector of std::unique_ptr owned by their parent for consistent memory management
  • Node groups

WIP:

  • Raycasting
  • Sprite animation system
  • Collision layers
  • Basic camera system

Planning:

  • Asset management system
  • Singleton
  • Tilemap System
  • Node re-parenting
  • queue_free() for abstracted node deletion

Base structure

The nodes are layed out in a hierarchical scene graph - essentially a linked tree.

  • Each node holds a pointer to its parent (Node* parent) and a vector of unique pointers of it's children (std::vector<std::unique_ptr<Node>>)
  • Nodes have update(delta) and draw(delta) methods which are called recursively on all children every delta
  • Node initialization and child node instancing (that is needed when the node is first instanced) is described in the constructor
  • Nodes who's parents are the scene root have nullptr set as their parent, and are added to the root's children vector.
    • This ensures that when the root is destroyed the children are properly managed, although this approach may be tweaked based on game state.
  • Quadtree that stores all collidable objects and checks for collisions every delta
  • Dynamic allocation occurs at the beginning of a scene instance

Nodes

Nodes are, much like in Godot, inherited from a base Node class and further derived into Node2D -> {CollisionObject2D,Sprite2D} and CollisionObject2D -> {Area2D, CharacterBody2D, StaticBody2D}.

Nodes are basically objects, and can be seen as subtrees, inheriting as many children as they want. When a node is deleted, all of it's child nodes recurisvely destroy themselves (smart pointers). Nodes can be deleted by deallocating from the parent's children vector (same in root).

Collision

Collision detection is done by a Quadtree data structure which recursively checks for collisions between objects in the same or neighbouring space quadrants.

Once collision is detected, both colliding objects are made aware of the collision as well as what they are colliding with. From there, each object can handle collision in it's own way.

dawn-engine's People

Contributors

barrwani avatar

Stargazers

Elias Benbourenane 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.