minor adjustments

This commit is contained in:
h4570
2023-05-28 22:55:42 +02:00
parent 20d2291a88
commit cab934763f
10 changed files with 299 additions and 271 deletions
@@ -1,35 +0,0 @@
/*
# _____ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022-2023, tyra - https://github.com/h4570/tyra
# Licensed under Apache License 2.0
# Guido Diego Quispe Robles
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <tyra>
namespace Tyra{
extern const int charSize;
extern const int font_char[96];
extern const int font_charWidth[96];
class Font{
public:
Font();
void LoadFont(TextureRepository& repository, Renderer2D* renderer);
void FreeFont(TextureRepository& repository);
void DrawText(const char* text, int x, int y, Color color);
void DrawText(const std::string& text, int x, int y, Color color);
private:
Renderer2D* renderer2D;
Sprite all_font;
std::array<Sprite,96> font;
};
} // namespace Tyra
@@ -0,0 +1,37 @@
/*
# _____ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022-2023, tyra - https://github.com/h4570/tyra
# Licensed under Apache License 2.0
# Guido Diego Quispe Robles
*/
#pragma once
#include <tyra>
#define FONT_CHAR_SIZE 96
namespace Tyra {
class Font {
public:
Font();
void load(TextureRepository& repository, Renderer2D* renderer);
void free(TextureRepository& repository);
void drawText(const char* text, const int& x, const int& y, Color color);
void drawText(const std::string& text, const int& x, const int& y,
Color color);
private:
const static int chars[FONT_CHAR_SIZE];
const static int charWidths[FONT_CHAR_SIZE];
Renderer2D* renderer2D;
Sprite allFont;
std::array<Sprite, FONT_CHAR_SIZE> font;
};
} // namespace Tyra
@@ -6,19 +6,18 @@
# Copyright 2022-2023, tyra - https://github.com/h4570/tyra
# Licensed under Apache License 2.0
# Guido Diego Quispe Robles
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <tyra>
#include "fontSprite.hpp"
#include "font_sprite.hpp"
namespace Tyra {
class Tutorial10 : public Game {
public:
Tutorial10(Engine* engine);
explicit Tutorial10(Engine* engine);
~Tutorial10();
void init();
@@ -27,7 +26,9 @@ class Tutorial10 : public Game {
private:
void loadTexture();
void loadSprite();
void handlePad();
int padTimer;
Engine* engine;
Pad* pad;
Font font;
@@ -35,8 +36,8 @@ class Tutorial10 : public Game {
Sprite sprite;
Sprite spriteFlip;
Sprite spriteScale;
Sprite spriteStrech;
std::string str_filter;
Sprite spriteStretch;
std::string strFilter;
PipelineTextureMappingType textureFilter;
};