A repository that sets up a C++ Project with the olcPixelGameEngine already loaded.
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.
 
 
 

59 lines
1.5 KiB

#define OLC_PGE_APPLICATION
#include "pixelGameEngine.h"
using namespace olc;
class BoxBorder : public olc::PixelGameEngine
{
public:
BoxBorder()
{
sAppName = "Box Border";
}
public:
Decal*box;
void DrawBorderBox(const vd2d&pos,const vd2d&size) {
DrawPartialDecal(pos,box,{0,0},{13,13}); //Upper-Left Corner
vd2d ULOffset={13,0};
DrawPartialDecal(pos+ULOffset,{(float)size.x-26,13},box,{13,0},{91,13}); //Top
vd2d UROffset={size.x-13,0};
DrawPartialDecal(pos+UROffset,box,{104,0},{13,13}); //Upper-Right Corner
vd2d ULBottomOffset={0,13};
DrawPartialDecal(pos+ULBottomOffset,{13,(float)size.y-25},box,{0,13},{13,73});//Left
vd2d BLOffset={0,size.y-13};
DrawPartialDecal(pos+BLOffset,box,{0,86},{13,13}); //Bottom-Left Corner
vd2d BLLeftOffset={13,size.y-13+0.05};
DrawPartialDecal(pos+BLLeftOffset,{(float)size.x-26,13},box,{13,86},{91,13}); //Bottom
vd2d BROffset={size.x-13,size.y-13};
DrawPartialDecal(pos+BROffset,box,{104,86},{13,13}); //Bottom-Right Corner
vd2d TROffset={size.x-13,13};
DrawPartialDecal(pos+TROffset,{13,(float)size.y-25},box,{104,13},{13,73});//Right
}
bool OnUserCreate() override
{
box = new Decal(new Sprite("border.png"),false,true);
return true;
}
bool OnUserUpdate(float fElapsedTime) override
{
vd2d boxPos={24,24};
vd2d boxSize=GetMousePos()-boxPos;
FillRectDecal(boxPos,boxSize,GREY);
DrawBorderBox(boxPos,boxSize);
return true;
}
};
int main()
{
BoxBorder demo;
if (demo.Construct(256, 240, 4, 4))
demo.Start();
return 0;
}