Introduce TTF library

This commit is contained in:
Pradana AUMARS 2021-06-28 21:34:48 +02:00
parent ebdcba9afb
commit 4ac1d84ef6
3 changed files with 13 additions and 3 deletions

3
README
View File

@ -2,4 +2,5 @@ A game of Pong.
Requirements
===========
* sdl2
* sdl2
* sdl2-ttf

View File

@ -8,5 +8,5 @@ pong_SOURCES = \
ball.h \
racket.c \
racket.h
pong_CFLAGS = $(SDL_CFLAGS)
pong_LDFLAGS = $(SDL_LIBS) -lm
pong_CFLAGS = $(SDL_CFLAGS) `pkg-config --cflags SDL2_ttf`
pong_LDFLAGS = $(SDL_LIBS) `pkg-config --libs SDL2_ttf` -lm

View File

@ -1,4 +1,5 @@
#include <SDL.h>
#include <SDL_ttf.h>
#include <stdio.h>
#include "pong.h"
@ -13,10 +14,17 @@ int main (int argc, char* args[])
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
return 1;
}
if (TTF_Init() < 0)
{
printf( "TTF could not initialize! TTF_Error: %s\n", TTF_GetError() );
return 1;
}
p = Pong_init();
if (p == NULL) {
printf("Pong failed to initialise!\n");
TTF_Quit();
SDL_Quit();
return 1;
}
Pong_render(p);
@ -34,6 +42,7 @@ int main (int argc, char* args[])
Pong_run(p);
Pong_free(p);
TTF_Quit();
SDL_Quit();
return 0;