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.
HexTest/main.cpp

64 lines
1.4 KiB

2 years ago
#define OLC_PGE_APPLICATION
#include "pixelGameEngine.h"
using namespace olc;
class Hexes : public olc::PixelGameEngine
2 years ago
{
public:
Hexes()
2 years ago
{
sAppName = "Hexes";
2 years ago
}
public:
Decal*hexImg;
vf2d offset={100,100};
2 years ago
bool OnUserCreate() override
{
// Called once at the start, so create things here
hexImg = new Decal(new Sprite("hexTex.png"));
2 years ago
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;
}
2 years ago
// 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}
});
}
}
2 years ago
return true;
}
};
int main()
{
Hexes demo;
2 years ago
if (demo.Construct(256, 240, 4, 4))
demo.Start();
return 0;
}