-
Notifications
You must be signed in to change notification settings - Fork 0
/
xor_texture.cpp
50 lines (36 loc) · 885 Bytes
/
xor_texture.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
#include <string>
class XorTexture : public olc::PixelGameEngine
{
public:
XorTexture()
{
sAppName = "XorTexture";
}
bool OnUserCreate() override
{
return true;
}
bool OnUserUpdate(float fElapsedTime) override
{
// https://lodev.org/cgtutor/xortexture.html
for (int y = 0; y < ScreenHeight(); y++)
for (int x = 0; x < ScreenWidth(); x++)
{
int c = x ^ y;
//Draw(x, y, olc::Pixel(c, c, c)); // without colors
Draw(x, y, olc::Pixel(255 - c, c, c % 128)); // with colors
}
// FPS
DrawString(10, 10, "FPS: " + std::to_string(GetFPS()));
return true;
}
};
int main()
{
XorTexture demo;
if (demo.Construct(256, 240, 4, 4))
demo.Start();
return 0;
}