-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Antumbra edited this page Jan 17, 2024
·
8 revisions
-
Sokoban example
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.
- Include the headers, in this case,
Application.h
andColors.h
; - Inherit an
ic::Application
instance, naming it in the process; - Write program logic, like updating, handling events, or ultimately, disposing the app when no longer needed;
- Have an instance of the engine somewhere inside a function (commonly the main loop);
- Call the application's
construct
function, specifying both the width and height in physical pixels; - Call the
start
method, pretty self-explanatory.
/* A prime example: Displays a blue window on startup. */
#include <Icosahedron/Application.h>
#include <Icosahedron/graphics/Colors.h>
class FirstProject : 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
}
};
// A simpler main function declaration.
// You can use int argc and char *argv[] as parameters, though.
int main() {
FirstProject application;
// Constructs a window that is 640 pixels wide and 480 pixels tall
if (application.construct(640, 480)) {
application.start();
}
return 0;
}