You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Javidx9 edited this page Apr 16, 2020
·
2 revisions
Example olcPixelEngine "Hello World"
The code below is a starting "skeleton" for all olc::PixelGameEngine applications. It produces a colourful noisy sequence of pixels. The PGE is constructed as being a 256x240 display, where each PGE pixel is 4x4 screen pixels (providing the application is not resized - if it is, then the aspect ratio will be maintained).
#defineOLC_PGE_APPLICATION
#include"olcPixelGameEngine.h"classExample : publicolc::PixelGameEngine
{
public:Example()
{
sAppName = "Example";
}
public:boolOnUserCreate() override
{
// Called once at the start, so create things herereturntrue;
}
boolOnUserUpdate(floatfElapsedTime) override
{
// called once per framefor (int x = 0; x < ScreenWidth(); x++)
for (int y = 0; y < ScreenHeight(); y++)
Draw(x, y, olc::Pixel(rand() % 256, rand() % 256, rand()% 256));
returntrue;
}
};
intmain()
{
Example demo;
if (demo.Construct(256, 240, 4, 4))
demo.Start();
return0;
}