diff --git a/src/pong.c b/src/pong.c index 7bcd144..7352bd8 100644 --- a/src/pong.c +++ b/src/pong.c @@ -9,10 +9,12 @@ Pong_init() { // Cast away the const *(int *)&p->SCREEN_WIDTH = 640; *(int *)&p->SCREEN_HEIGHT = 480; + *(int *)&p->BALL_POSX = 100; + *(int *)&p->RACKET_POSX = 50; - p->ball = Ball_init(p->SCREEN_WIDTH, p->SCREEN_HEIGHT, 100); - p->racketL = Racket_init(p->SCREEN_WIDTH, p->SCREEN_HEIGHT, 50, p->SCREEN_HEIGHT/2, SDL_SCANCODE_E, SDL_SCANCODE_D); - p->racketR = Racket_init(p->SCREEN_WIDTH, p->SCREEN_HEIGHT, p->SCREEN_WIDTH - 50, p->SCREEN_HEIGHT/2, SDL_SCANCODE_I, SDL_SCANCODE_K); + p->ball = Ball_init(p->SCREEN_WIDTH, p->SCREEN_HEIGHT, p->BALL_POSX); + p->racketL = Racket_init(p->SCREEN_WIDTH, p->SCREEN_HEIGHT, p->RACKET_POSX, p->SCREEN_HEIGHT/2, SDL_SCANCODE_E, SDL_SCANCODE_D); + p->racketR = Racket_init(p->SCREEN_WIDTH, p->SCREEN_HEIGHT, p->SCREEN_WIDTH - p->RACKET_POSX, p->SCREEN_HEIGHT/2, SDL_SCANCODE_I, SDL_SCANCODE_K); p->window = SDL_CreateWindow( "Pong", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, p->SCREEN_WIDTH, p->SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); if( p->window == NULL ) diff --git a/src/pong.h b/src/pong.h index caf88f5..7c9cc74 100644 --- a/src/pong.h +++ b/src/pong.h @@ -14,7 +14,9 @@ typedef struct Pong { //SDL_Texture* texture; SDL_Event e; Ball *ball; + const int BALL_POSX; Racket *racketL; + const int RACKET_POSX; Racket *racketR; } Pong;