-
Notifications
You must be signed in to change notification settings - Fork 1
/
paddle.h
84 lines (62 loc) · 1.71 KB
/
paddle.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
Paddle module header file
@team 128
@author Ambrose Ledbrook - 79172462
@author Josh Jarvis - 28803714
@date 06-oct-2018
@brief This module header provides the functionality of the players paddle to
the game module.
*/
// Defining constants, includes and typedefs used by the module
#ifndef PADDLE_H
#define PADDLE_H
// Inlcuding modules used by the paddle
#include "system.h"
#include "tinygl.h"
#include "navswitch.h"
// Defining constants used for the edges of the board
#define MAX_LEFT 6
#define MAX_RIGHT 0
#define BOTTOM_COLUMN 4
#define PADDLE_START_LEFT 3
#define PADDLE_START_RIGHT 2
#define SHOW_PADDLE 1
#define HIDE_PADDLE 0
#define MOVEMENT_INCREMENT 1
#define PADDLE_WIDTH PADDLE_START_LEFT - PADDLE_START_RIGHT + 1
/**
This struct holds two tinygl_point_t's which hold the end points of the
paddle
*/
typedef struct paddle {
tinygl_point_t left;
tinygl_point_t right;
} Paddle;
// Defining the variable to hold the paddle
Paddle paddle;
/**
This function is used to initialize the state of the paddle.
It sets the initial postion of the paddle
*/
void paddle_init(void);
/**
This function shows the paddle in its current postion.
*/
void paddle_show(void);
/**
This function moves the paddle on a NAVSWITCH_NORTH or
NAVSWITCH_SOUTH navswitch_push_event_p.
*/
void paddle_move(void);
/**
Checking if the passed ball postion is within the paddle.
@param A tinygl_point_t which is the game balls postion
@return 1 if the ball is within the paddle, 0 otherwise
*/
uint8_t check_ball(tinygl_point_t pos);
/**
Getting the center y coordinate of the paddle
@return The center y coordinate of the paddle
*/
uint8_t get_paddle_center(void);
#endif