Skip to content
invoker__qq edited this page Nov 15, 2020 · 3 revisions

Quick Shortcuts

NOTE: SwitchPixelGameEngine was released recently, thus this documentation is being compiled, and therefore not completed. However, the engine is intuitively easy to use, and there will be some examples in the main repo.

How do you use it?

  1. Include the header file "SwitchPixelGameEngine.h" from a source file
  2. Implement a constructor for your derived class, and name your application
  3. Optionally override the OnUserCreate() function
  4. Override the OnUserUpdate() function
  5. Optionally override the OnUserDestroy() function
  6. Create an instance of your derived class somewhere, typically main()
  7. Call the Construct() function and specify the screen and pixel dimensions
  8. Call the GameThread() function to, well, start the engine 😂

Hello World

#include "SwitchPixelGameEngine.h"
class Demo : public SwitchPixelGameEngine
{
public:
    Demo()
    {
    }
    std::string s_str = "hello world !";
    virtual bool OnUserCreate() override
    {
        return true;
    }
    virtual bool OnUserUpdate(float fElapsedTime) override
    {
        ClearScreen();
        DrawTriangle(20,20,20,60,50,50,FG_YELLOW);
        DrawCircle(20,60,10,FG_GREEN);
        DrawString(ScreenWidth()/2, ScreenHeight()/2, s_str);
        return true;
    }
};
int main()
{
    Demo example;
    example.ConstructConsole(1,1);
    example.GameThread();
}
Clone this wiki locally