generated from sigonasr2/CPlusPlusProjectTemplate
checkerboard boxes for players
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
8fabcf624f
commit
67453b3d89
Binary file not shown.
21
main.cpp
21
main.cpp
@ -48,9 +48,6 @@ public:
|
|||||||
if (GetKey(olc::LEFT).bPressed) {
|
if (GetKey(olc::LEFT).bPressed) {
|
||||||
partyMemberCount=max(partyMemberCount-1,1);
|
partyMemberCount=max(partyMemberCount-1,1);
|
||||||
}
|
}
|
||||||
if (GetMouse(0).bPressed) {
|
|
||||||
engine.PlayWaveform(&se1);
|
|
||||||
}
|
|
||||||
|
|
||||||
drawGame();
|
drawGame();
|
||||||
// called once per frame
|
// called once per frame
|
||||||
@ -61,19 +58,31 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drawBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) {
|
void drawBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) {
|
||||||
|
FillRectDecal({pos.x+3,pos.y+3},{size.x-5,size.y-5},p);
|
||||||
DrawRect({pos.x,pos.y},size,p2);
|
DrawRect({pos.x,pos.y},size,p2);
|
||||||
DrawRect({pos.x+2,pos.y+2},{size.x-4,size.y-4},p3);
|
DrawRect({pos.x+2,pos.y+2},{size.x-4,size.y-4},p3);
|
||||||
DrawRect({pos.x+1,pos.y+1},{size.x-2,size.y-2});
|
DrawRect({pos.x+1,pos.y+1},{size.x-2,size.y-2},p);
|
||||||
Draw({pos.x,pos.y},olc::BLACK);
|
Draw({pos.x,pos.y},olc::BLACK);
|
||||||
Draw({pos.x+size.x,pos.y+size.y},olc::BLACK);
|
Draw({pos.x+size.x,pos.y+size.y},olc::BLACK);
|
||||||
Draw({pos.x+size.x,pos.y},olc::BLACK);
|
Draw({pos.x+size.x,pos.y},olc::BLACK);
|
||||||
Draw({pos.x,pos.y+size.y},olc::BLACK);
|
Draw({pos.x,pos.y+size.y},olc::BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawCheckerboardBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel alternatingCol = olc::WHITE, const olc::vi2d &checkerboardSize = {3,3}, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) {
|
||||||
|
drawBox(pos,size,p,p2,p3);
|
||||||
|
for (int x=3;x<size.x;x+=checkerboardSize.x*2) {
|
||||||
|
for (int y=3;y<size.y;y+=checkerboardSize.y*2) {
|
||||||
|
if (x+checkerboardSize.x<size.x&&y+checkerboardSize.y<size.y) {
|
||||||
|
FillRectDecal({x+pos.x,y+pos.y},{checkerboardSize.x,checkerboardSize.y},alternatingCol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void drawGame(){
|
void drawGame(){
|
||||||
drawBox({0,0},{128,32});
|
drawBox({0,0},{128,48},olc::BLACK);
|
||||||
for (int i=0;i<partyMemberCount;i++) {
|
for (int i=0;i<partyMemberCount;i++) {
|
||||||
drawBox({(128-32*partyMemberCount)+i*64,160},{64,64});
|
drawCheckerboardBox({(128-32*partyMemberCount)+i*64,160},{59,59},olc::Pixel(180,159,194),olc::Pixel(200,179,214),{6,6});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user