summaryrefslogtreecommitdiff
path: root/pong.h
blob: 377c37ce3dc1955a73262d6a89ca406358a9ae02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef PONG_H
#define PONG_H

#include <stdint.h>
#include <stdbool.h>

#define PADDLE_WIDTH	16
#define PADDLE_HEIGHT	128
#define BALL_WIDTH	16
#define BALL_HEIGHT	16

typedef struct vector_t {
    int32_t x;
    int32_t y;
} vector_t;

/* paddles have a fixed x position and velocity */
struct moveable_t {
    vector_t position;
    vector_t velocity;
    uint8_t width;
    uint8_t height;
};

typedef struct moveable_t ball_t;
typedef struct moveable_t paddle_t;

void UpdatePosition(vector_t * const position, const vector_t velocity);
bool CheckMoveableCollision(const struct moveable_t m1, const struct moveable_t m2);
bool CheckLeftWallCollision(const struct moveable_t m);
bool CheckRightWallCollision(const struct moveable_t m);
bool CheckGroundCollision(const struct moveable_t m);
bool CheckCeilingCollision(const struct moveable_t m);
void Reset(ball_t * const ball);

#endif //PONG_H