pong/src/ball.h

33 lines
749 B
C

#ifndef BALL_H
#define BALL_H
#include <SDL.h>
#include <stdbool.h>
#include "racket.h"
static const int BALL_WIDTH = 20;
static const int BALL_HEIGHT = 20;
static const int BALL_VELOCITY = 7;
static const int BALL_ANGLE_MIN_OFFSET = 10;
static const int BALL_ANGLE_MAX_OFFSET = 60;
typedef struct Ball {
const int SCREEN_WIDTH;
const int SCREEN_HEIGHT;
const int BALL_POSX_START;
int posX;
int posY;
int velX;
int velY;
} Ball;
Ball* Ball_init(int screen_width, int screen_height, int posX_start);
void Ball_reset(Ball *b, int direction);
void Ball_free(Ball *b);
//void Ball_handle_event(Ball *b, SDL_Event *e);
int Ball_collision(const Ball *b, const Racket *r);
int Ball_render(const Ball *b, SDL_Renderer *renderer);
#endif