GithubHelp home page GithubHelp logo

davdag / windows-game-engine Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 93 KB

My own Game Engine ! (called Gengine)

License: Apache License 2.0

C++ 100.00%
game-engine graphics-engine graphics-library windows-library windows-only cpp-library windows-h easy-to-use fast math

windows-game-engine's Introduction

My-Windows-Game-Engine

My own graphic engine. (Currently works for every version of Window)

What can you do ?

  • Draw circles, ellipses, rectangle, polygons.
  • Read input from keyboard and mouse (pressed, held, released, toggled).
  • Colors ! (Now RGB only but i'm working to add Alpha).
  • Lock FPS ( from 1 to 1000! ).
  • Set Window Title.
  • Run in multithreading so FASTER on multicore machines.
  • I will add Surfaces, vector2d, vector3d, some helpful math's equations and others !.

How to install it

DevCpp

  1. Create New Project (Empty Project / Console Application)
  2. Go to Project->Project Options->Parameters->Add Library or object. Browse into C:\somthing\GEngine\bin\libGEngine.a and Select it.
  3. Paste "-lgdi32 -lwinmm -lws2_32" inside Linker box (_You need to complete second before !)
  4. Go to Project->Project Options->Directories->Include Directories. Browse into C:\somthing\GEngine\src, Select it and click on "ADD".
  5. Then you can #include <GEngine.hpp> and use my library !

How to use it

Basics

#include <GEngine.hpp>

/** Create a class and inherit from GEngine
  * You must define onStart() and onUpdate(float dt)
  * otherwise it will be abstract.
  **/
class Engine: public GEngine
{

  public:
    // This function will be called when the game start or restart.
    bool onStart()
    {
      // Return true if all worked correctly
      return true;
    }
    
    // Every frame the engine will call this function
    bool onUpdate(float dt)
    {
      clear(Color::Black);                          // Clear background with black
      drawRect(400, 300, 100, 100, Color::Blue);    // Draw a simple 100px width 100px height blue rectangle
      
      if(KeyBoard::GetKeyState(KeyBoard::K_W).held) // Check if W is held
       drawRect(500, 300, 100, 100, Color::Red)     // Draw a 100px width 100px height red rectangle
      
      // Its important to return true if you dont want to close the application
      return true;
    }
    
    // optional
    bool onDestroy()
    {
      // This function is called when Game Loop is over.
      // You can return true if you want to close or false if you want to restart the game.
      return true;
    }
};

int main()
{
  // Create an instance.
  Engine demo;
  
  // Initialize the window (width, height) in pixels.
  if(demo.init(800, 600))
  
      // If all is gone correctly you can run your game !
      demo.run();
  
  return 0;
}

windows-game-engine's People

Contributors

davdag 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.