Skip to content
Antumbra edited this page Oct 15, 2023 · 8 revisions

Pages

  1. Quick start

Icosahedron

What is it? An icosahedron is a solid with twenty faces, but here it is also a game engine. You can compile a project made using this library via gcc on VSCode, but I don't know if you can do the same on Visual Code. Anyways, this was created mainly to help Emanuel G make applications faster.

How do you use it?

  1. Include the header <Icosahedron/Core.h> inside your project;
  2. Inherit an ic::Application instance, naming it in the process;
  3. Write program logic, like updating, handling events, or ultimately, disposing the app when no longer needed;
  4. Have an instance of the engine somewhere inside a function (commonly the main loop);
  5. Call the application's construct function, specifying both the width and height in physical pixels;
  6. Call the start method, pretty self-explanatory.
// Shows an empty blue window on startup
#include <Icosahedron/Core.h>

class Example : public ic::Application {
    public:
        bool init() override {
            // Use this to set up window settings, although this can also be done in the constructor
            displayName = "Example window";
            
            return true;
        }
        
        bool load() override {
            // This function is called after init() and after setting up the window

            return true;
        }

        void window_size_changed(int w, int h) override {
            // Called when the window is resized, and also if it is changed to fullscreen mode
            
        }

        bool handle_event(ic::Event event, float dt) override { 
            // Called when events are retrieved and polled 

            return true;
        }

        bool update(float dt) override {
            // This is called once every frame
        
            clear_color(ic::Colors::blue);
            return true; 
        }

        void dispose() override {
            // Occurs when the application has to close

        }
};

int main(int argc, char *argv[]) {
    Example application;

    // Constructs a window that is 640 pixels wide and 480 pixels tall
    if (application.construct(640, 480)) {
        application.start();
    }

    return 0;
}
Clone this wiki locally