Incorporate game font.

master
sigonasr2 9 months ago
parent 25a798cf7e
commit b3434e9fad
  1. BIN
      TiledCollisionEditor/font.png
  2. 9
      TiledCollisionEditor/main.cpp
  3. 8
      TiledCollisionEditor/pixelGameEngine.h

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

@ -23,6 +23,8 @@ public:
public:
bool OnUserCreate() override
{
SetFontSprite("font.png");
std::string tilesetFilename=TILESET_DIR+"Basic Tileset.tsx";
Tileset&tileset=tilesets[tilesetFilename]=TSXParser{tilesetFilename}.GetData();
@ -75,6 +77,13 @@ public:
}
}
/* Font test.
DrawStringDecal({0,0},"the quick brown fox jumps over the lazy dog",WHITE,{1.5f,1.5f});
DrawStringDecal({0,18},"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG",WHITE,{1.5f,1.5f});
DrawStringPropDecal({0,36},"the quick brown fox jumps over the lazy dog",WHITE,{1.5f,1.5f});
DrawStringPropDecal({0,54},"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG",WHITE,{1.5f,1.5f});
*/
return true;
}
};

@ -1154,6 +1154,7 @@ namespace olc
void ClearBuffer(Pixel p, bool bDepth = true);
// Returns the font image
olc::Sprite* GetFontSprite();
void SetFontSprite(std::string_view newFontFile);
// Clip a line segment to visible area
bool ClipLineToScreen(olc::vi2d& in_p1, olc::vi2d& in_p2);
@ -2377,6 +2378,9 @@ namespace olc
olc::Sprite* PixelGameEngine::GetFontSprite()
{ return fontRenderable.Sprite(); }
void PixelGameEngine::SetFontSprite(std::string_view newFontFile)
{ fontRenderable.Load(std::string(newFontFile)); }
bool PixelGameEngine::ClipLineToScreen(olc::vi2d& in_p1, olc::vi2d& in_p2)
{
// https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm
@ -4071,8 +4075,8 @@ namespace olc
0x08,0x17,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x24,0x15,0x06,0x07,0x16,0x17,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x17,0x08,0x08,0x17,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x17,0x08,0x08,0x08,0x08,0x17,0x08,0x15,0x08,0x15,0x08,0x08,
0x24,0x18,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x33,0x17,0x17,0x33,0x18,0x17,0x17,
0x17,0x17,0x17,0x17,0x07,0x17,0x17,0x18,0x18,0x17,0x17,0x07,0x33,0x07,0x08,0x00, } };
0x24,0x16,0x16,0x17,0x16,0x16,0x15,0x17,0x17,0x33,0x15,0x17,0x23,0x08,0x17,0x16,
0x07,0x07,0x24,0x17,0x06,0x17,0x16,0x08,0x23,0x17,0x17,0x07,0x33,0x07,0x08,0x00, } };
for (auto c : vSpacing) vFontSpacing.push_back({ c >> 4, c & 15 });

Loading…
Cancel
Save