diff --git a/TiledCollisionEditor/font.png b/TiledCollisionEditor/font.png new file mode 100644 index 0000000..a29f329 Binary files /dev/null and b/TiledCollisionEditor/font.png differ diff --git a/TiledCollisionEditor/main.cpp b/TiledCollisionEditor/main.cpp index e6c4e22..2b00d44 100644 --- a/TiledCollisionEditor/main.cpp +++ b/TiledCollisionEditor/main.cpp @@ -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; } }; diff --git a/TiledCollisionEditor/pixelGameEngine.h b/TiledCollisionEditor/pixelGameEngine.h index bb9ad71..1c9561c 100644 --- a/TiledCollisionEditor/pixelGameEngine.h +++ b/TiledCollisionEditor/pixelGameEngine.h @@ -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 });