51 lines
905 B
C
51 lines
905 B
C
#include <SDL.h>
|
|
#include <SDL_ttf.h>
|
|
#include <stdio.h>
|
|
|
|
#include "pong.h"
|
|
|
|
int main (int argc, char* args[])
|
|
{
|
|
Pong *p = NULL;
|
|
int start = false;
|
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
|
{
|
|
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);
|
|
|
|
while (!start) {
|
|
printf("Press any key to start...\r");
|
|
fflush(stdout);
|
|
while( SDL_PollEvent( &(p->e) ) != 0 )
|
|
{
|
|
if( p->e.type == SDL_KEYDOWN) start = true;
|
|
}
|
|
}
|
|
putc('\n', stdout);
|
|
|
|
Pong_run(p);
|
|
Pong_free(p);
|
|
|
|
TTF_Quit();
|
|
SDL_Quit();
|
|
|
|
return 0;
|
|
}
|
|
|