generated from sigonasr2/CPlusPlusProjectTemplate
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.4 KiB
63 lines
1.4 KiB
#define OLC_PGE_APPLICATION
|
|
#include "pixelGameEngine.h"
|
|
|
|
using namespace olc;
|
|
|
|
class Hexes : public olc::PixelGameEngine
|
|
{
|
|
public:
|
|
Hexes()
|
|
{
|
|
sAppName = "Hexes";
|
|
}
|
|
|
|
public:
|
|
Decal*hexImg;
|
|
vf2d offset={100,100};
|
|
|
|
bool OnUserCreate() override
|
|
{
|
|
// Called once at the start, so create things here
|
|
hexImg = new Decal(new Sprite("hexTex.png"));
|
|
return true;
|
|
}
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override
|
|
{
|
|
if (GetKey(UP).bHeld) {
|
|
offset.y+=fElapsedTime*200;
|
|
}
|
|
if (GetKey(DOWN).bHeld) {
|
|
offset.y-=fElapsedTime*200;
|
|
}
|
|
if (GetKey(LEFT).bHeld) {
|
|
offset.x+=fElapsedTime*200;
|
|
}
|
|
if (GetKey(RIGHT).bHeld) {
|
|
offset.x-=fElapsedTime*200;
|
|
}
|
|
// called once per frame
|
|
float scale=20;
|
|
for (int x=0;x<20;x++) {
|
|
for (int y=0;y<20;y++) {
|
|
vf2d offset2={(y&1?-0.45F*scale:0)+offset.x+x*0.9F*scale,y*scale*0.7F+offset.y};
|
|
DrawPolygonDecal(hexImg,{
|
|
{0+offset2.x,0.5F*scale+offset2.y},{-0.45F*scale+offset2.x,0.25F*scale+offset2.y},{0+offset2.x,0+offset2.y},{0.45F*scale+offset2.x,0.25F*scale+offset2.y},{0.45F*scale+offset2.x,0.75F*scale+offset2.y},{0+offset2.x,1*scale+offset2.y},{-0.45F*scale+offset2.x,0.75F*scale+offset2.y},{-0.45F*scale+offset2.x,0.25F*scale+offset2.y}
|
|
},{
|
|
{1,1},{0,1},{0,0},{0,1},{0,0},{0,1},{0,0},{0,1}
|
|
});
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
|
|
|
|
int main()
|
|
{
|
|
Hexes demo;
|
|
if (demo.Construct(256, 240, 4, 4))
|
|
demo.Start();
|
|
|
|
return 0;
|
|
}
|
|
|