Fonts and debug information.
This commit is contained in:
parent
f3f1402755
commit
0817b2e600
Binary file not shown.
10
src/main.c
10
src/main.c
|
@ -25,7 +25,7 @@ static void handleCommandLine(int argc, const char *argv[]);
|
|||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
long then, nextSecond;
|
||||
long then, nextSecond, frames;
|
||||
|
||||
atexit(cleanup);
|
||||
|
||||
|
@ -39,6 +39,8 @@ int main(int argc, const char *argv[])
|
|||
|
||||
handleCommandLine(argc, argv);
|
||||
|
||||
frames = 0;
|
||||
|
||||
nextSecond = SDL_GetTicks() + 1000;
|
||||
|
||||
while (1)
|
||||
|
@ -57,8 +59,14 @@ int main(int argc, const char *argv[])
|
|||
|
||||
then = capFrameRate(then);
|
||||
|
||||
frames++;
|
||||
|
||||
if (SDL_GetTicks() >= nextSecond)
|
||||
{
|
||||
dev.fps = frames;
|
||||
|
||||
frames = 0;
|
||||
|
||||
game.timePlayed++;
|
||||
|
||||
nextSecond = SDL_GetTicks() + 1000;
|
||||
|
|
|
@ -36,6 +36,8 @@ void initAtlas(void)
|
|||
loadAtlasTexture();
|
||||
|
||||
loadAtlasData();
|
||||
|
||||
dev.debug = dev.showFPS = 1;
|
||||
}
|
||||
|
||||
Atlas *getImageFromAtlas(char *filename)
|
||||
|
|
|
@ -23,3 +23,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern Texture *getTexture(const char *filename);
|
||||
extern char *readFile(const char *filename);
|
||||
|
||||
extern Dev dev;
|
||||
|
|
|
@ -48,6 +48,15 @@ void prepareScene(void)
|
|||
|
||||
void presentScene(void)
|
||||
{
|
||||
if (dev.debug)
|
||||
{
|
||||
drawText(5, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "DEBUG MODE");
|
||||
if (dev.showFPS)
|
||||
{
|
||||
drawText(SCREEN_WIDTH - 5, SCREEN_HEIGHT - 25, 14, TA_RIGHT, colors.white, "FPS: %d", dev.fps);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetRenderTarget(app.renderer, NULL);
|
||||
SDL_RenderCopy(app.renderer, app.backBuffer, NULL, NULL);
|
||||
SDL_RenderPresent(app.renderer);
|
||||
|
|
|
@ -20,5 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "../common.h"
|
||||
|
||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
|
|
|
@ -297,7 +297,7 @@ static void loadFont(int size)
|
|||
{
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "loadFonts(%d)", size);
|
||||
|
||||
font[size] = TTF_OpenFont(getFileLocation("data/fonts/LiberationMono-Regular.ttf"), size);
|
||||
font[size] = TTF_OpenFont(getFileLocation("gfx/fonts/Roboto-Medium.ttf"), size);
|
||||
}
|
||||
|
||||
void destroyFonts(void)
|
||||
|
|
Loading…
Reference in New Issue