Skip to content

kanchanpoudel/0Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0Engine

0Engine is a 2D Game Engine / Framework developed using OpenGL as a graphics API

Contents

Running Using Visual Studio in Windows

  • Run the solution file s00nya.sln to open the project using Visual Studio
  • Right Click the Game project and click on Set as Start Up Project
  • Press [F5] or click the Local Windows Debugger button to run the project

Dependencies

Note that all the dependencies are readily avaible, so it is not required for installing them separately

Directory Structure

  • Root directory consists of the directories : 0Engine, Dependencies and other directories
  • All the compiled / build files are (or should be) inside of the directory bin in the root directory
  • All other directories in the root directories except above mentioned are Example game projects made using the 0Engine
  • Dependencies directory contains all the projects that 0Engine depends on
  • 0Engine directory contains the source code for the 0Engine

Directory Structure for 0Engine

Directories and files inside of 0Engine directory ::

  • Debugger : Logger class and OpenGL debugger
  • Game : Wrapper for the whole framework and Locator of all required servies
  • GameObject : Base classes for Game Objects, Cameras, Lights, etc
  • Graphics : GPU buffers, Renderer, Materials, Shaders, Sprites and Window
  • Input : Input systems and Input Manager
  • Math : Vectors, Matrices, Transformation, Dimensions and other mathematics
  • Physics : Kinematics, Collision and Collision Resolution
  • Utility : Events Manager, Resources Manager, Timer and other utilities

Directories inside of the Headers directory contain decalrations of all the classes / functions that are defined in above mentioned directories

Note that s00nya.h file inside of 0Engine/Headers/ should include all the header files whose API are to be exposed to the game developers

Building the project

  • All dependencies should be compiled to static libraries
  • 0Engine contents depend on Dependencies and should be compiled to static / dyanamic library according to the macro defined in 0Engine/Headers/s00nya_defs.h
  • Other game projects depend on 0Engine and should be linked with the 0Engine library
  • Game should output to executables

Components of the 0Engine

Game2D Locator Window Debug
Timer Input Input Manager Event Manager
Resources Renderer Vertex Vertex Buffer
Vertex Buffer 2D Shader Raw Image Sprite
Scene Game Object Camera Material
Vector2 Vector3 Vector4 Matrix3
Matrix4 Transform 2D Dimension Collider 2D
Collision 2D Rigid Body

Game2D

Information

  • Game2D is a wrapper class for different components of the 0Engine
  • Maintains relationships between all different components of the 0Engine
  • It contains Locator, Window, Timer, Input, Input Manager, Event Manager, Resources, Renderer, Shaders and Scenes
  • All the components are instanced using Locator class
  • Game2D loads an active Scene, only one scene can be active at a time
  • Tick(), FixedUpdate() and Update() method are called every second, 60 times a second and as fast as possible respectively in the game loop

API

Game2D(const Character* title, const Integer& width, const Integer& height, const Samples& sample)
  • title = Title to be displayed in the window, defaults to "s00nya Game"
  • width = Width of the window, defaults to 800
  • height = Height of the window, defaults to 600
  • sample = Sample order for multisampling. Can be { NO_SAMPLE, SAMPLE_DOUBLE, SAMPLE_FOUR, SAMPLE_EIGHT } from Samples

 void Start()

Begins the game loop


static Input& GetInput()

Returns reference to Input


static Timer& GetTimer()

Returns reference to Timer


static InputManager& GetInputManager()

Returns reference to Input Manager


static EventManager& GetEventManager()

Returns reference to Event Manager


static Resources& GetResourceManager()`

Returns reference to Resources


static void ActivateScene(const PDUInteger& id)`
  • id = ID of the Scene
  • Activates the Scene with id

static void ActivateNextScene()`

Activate Scene in next order


static PDUInteger PushScene(Scene* scene)`
  • scene = pointer to Scene
  • Adds given scene in the Game2D
  • Scene passed must be created in heap, memory is then maintained by this wrapper so cleaning is not required

static void PopSceneBack()`

Remove last placed Scene


static void PopSceneFront()`

Remove first placed Scene


static Scene& GetCurrentScene()`

Get reference to currently active Scene


Go Up

Locator

Information

API

This class is not intended to be used as a part of the Game development process

Go Up

Window

Information

  • Window class maintains Window creation, resizing, destruction and other window related functions
  • Window class automatically creates instance of Debug during window creation and shut down Debug during window destruction
  • Window class is required for creation of Input System
  • Timer must be constructed after window construction because Timer depends on window class

API

void Resize(const Integer& width, const Integer& height);
  • width = Width of the window to be resized to
  • height = Height of the window to be resized to

void ToggleFullscreen();
  • Toggles full screen mode
  • On window construction, the window will be in windowed mode by default

void ChangeCursor(const RawImage& image);
  • image = RawImage that is to be placed as cursor within the window
  • Changes the cursor within the window

void SetIcon(const RawImage& image);
  • image = RawImage that is to be placed as window icon
  • Sets / Changes the window icon

void DisableCursor() const;

Disables cursor and sets a virtual cursor in the middle of the window client area


void HideCursor() const;

Hides cursor within the window


void EnableCursor() const;

Resets cursor properties (Hidden / Disabled cursor)


const Integer& Width() const;

Returns Width of the window


const Integer& Height() const;

Returns Height of the window


Go Up

Debug

Information

  • Debug lets the debug information to be displayed in console and file
  • This class automatically finds and displays OpenGL errors & warnings
  • It is automatically constructed during Window creation and destroyed during Window destruction

API

static void Add(const std::string& logStr, Integer level)
  • logStr = string data that is to be logged
  • level = the level of the log. Can be { S00NYA_LOG_INFO, S00NYA_LOG_ERROR, S00NYA_LOG_WARNING } inside of Debug

Go Up

Timer

Information

This class records information about time and timing of the program

API

Float DeltaTime() const;

Returns the time spent between 2 sucessive frame / game loop


static Float ElaspedTime();

Returns the time spent after the program ran


Go Up

Input

Information

  • This class maintains keyboard and mouse input
  • This class is constructed using the Window class

API

Boolean Pressed(const Keys& key);

Returns true if the given key is pressed otherwise false


Boolean Held(const Keys& key);

Returns true if the given key is held otherwise false


Boolean Combined(const Keys& hold, const Keys& press);

Returns true if the hold is held and press is pressed otherwise false


Boolean Combined(const Keys& hold1, const Keys& hold2, const Keys& press);

Returns true if the hold1 and hold2 is held and press is pressed otherwise false


Boolean Pressed(const Buttons& button);

Returns true if the button Mouse button is pressed otherwise false


Boolean Held(const Buttons& button);

Returns true if the button Mouse button is held otherwise false


const Float& CursorPositionX();

Returns Horizontal position of the mouse cursor


const Float& CursorPositionY();

Returns Vertical position of the mouse cursor


const Float& HorizontalAxis();
  • Returns horizontal offset when the mouse is moved
  • Value lies between -1.0f to 1.0f

const Float& VerticalAxis();
  • Returns horizontal offset when the mouse is moved
  • Value lies between -1.0f to 1.0f

const Float& ScrollHorizontalAxis();

Returns the number of scroll wheels scrolled horizontally


const Float& ScrollVerticalAxis();

Returns the number of scroll wheels scrolled vertically


static const Character* GetName(const Keys& key);

Returns name of the given key


static const Character* GetName(const Buttons& button);

Returns name of the mouse button button


Go Up

Input Manager

Information

API

Go Up

Event Manager

Information

API

Go Up

Resources

Information

API

Go Up

Renderer

Information

API

Go Up

Vertex

Information

API

Go Up

Vertex Buffer

Information

API

Go Up

Vertex Buffer 2D

Information

API

Go Up

Shader

Information

API

Go Up

Raw Image

Information

API

Go Up

Sprite

Information

API

Go Up

Scene

Information

API

Go Up

Game Object

Information

API

Go Up

Camera

Information

API

Go Up

Material

Information

API

Go Up

Vector2

Information

API

Go Up

Vector3

Information

API

Go Up

Vector4

Information

API

Go Up

Matrix3

Information

API

Go Up

Matrix4

Information

API

Go Up

Transform 2D

Information

API

Go Up

Dimension

Information

API

Go Up

Collider 2D

Information

API

Go Up

Collision 2D

Information

API

Go Up

Rigid Body

Information

API

Go Up

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published