Introduce TTF library
This commit is contained in:
parent
ebdcba9afb
commit
4ac1d84ef6
1
README
1
README
@ -3,3 +3,4 @@ A game of Pong.
|
|||||||
Requirements
|
Requirements
|
||||||
===========
|
===========
|
||||||
* sdl2
|
* sdl2
|
||||||
|
* sdl2-ttf
|
@ -8,5 +8,5 @@ pong_SOURCES = \
|
|||||||
ball.h \
|
ball.h \
|
||||||
racket.c \
|
racket.c \
|
||||||
racket.h
|
racket.h
|
||||||
pong_CFLAGS = $(SDL_CFLAGS)
|
pong_CFLAGS = $(SDL_CFLAGS) `pkg-config --cflags SDL2_ttf`
|
||||||
pong_LDFLAGS = $(SDL_LIBS) -lm
|
pong_LDFLAGS = $(SDL_LIBS) `pkg-config --libs SDL2_ttf` -lm
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include <SDL_ttf.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "pong.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() );
|
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (TTF_Init() < 0)
|
||||||
|
{
|
||||||
|
printf( "TTF could not initialize! TTF_Error: %s\n", TTF_GetError() );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
p = Pong_init();
|
p = Pong_init();
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
printf("Pong failed to initialise!\n");
|
printf("Pong failed to initialise!\n");
|
||||||
|
TTF_Quit();
|
||||||
|
SDL_Quit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Pong_render(p);
|
Pong_render(p);
|
||||||
@ -34,6 +42,7 @@ int main (int argc, char* args[])
|
|||||||
Pong_run(p);
|
Pong_run(p);
|
||||||
Pong_free(p);
|
Pong_free(p);
|
||||||
|
|
||||||
|
TTF_Quit();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user