-
Notifications
You must be signed in to change notification settings - Fork 1
/
ball.h
81 lines (59 loc) · 1.77 KB
/
ball.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
/**
Ball module header file
@team 128
@author Ambrose Ledbrook - 79172462
@author Josh Jarvis - 28803714
@date 13-oct-2018
@brief This module header provides the ball functionality to the game to other
modules that require it
*/
// Defining methods and includes of the ball module if not already defined
#ifndef BALLTEST_H
#define BALLTEST_H
// Defineing constants used throughout the ball module
#define BOTTOM_COLUMN 4
#define TOP_COLUMN 0
#define ABOVE_PADDLE_COLUMN 3
#define CENTER_ROW 3
#define NUM_START_DIRS 2
#define BALL_VISIBLE 1
#define BALL_NOT_VISIBLE 0
#include "ball.h"
/**
Intialising the state and postion of the ball
*/
void ball_init(void);
/**
Updating the postion of the ball through the use of the boing_update method
*/
void ball_update(void);
/**
Sending the postion and direction of the ball to the other board over
through the use of the comms module.
*/
void send_ball_pos(void);
/**
Processing a ball that was received from the other board. Takes a y-coordinate
and a direction and updates the ball to match.
@param pos the y coordinate received for the ball
@param dir the direction received for the ball
*/
void receive_ball(uint8_t pos, uint8_t dir);
/**
Checking if the ball needs to be sent to the other board. The ball will be
sent to the other board if its x-coordinate is 0 which is the top row of the
ledmat.
@return 1 if the ball is to be sent 0 otherwise
*/
uint8_t check_send(void);
/**
Used to check if the ball has hit the paddle. Also handling the ball
bouncing off the paddle.
@return 0 if ball is on back of screen 1 otherwise
*/
uint8_t check_paddle(void);
/**
Resetting the postion of the ball to default. Used when the game is restarted
*/
void reset_ball(void);
#endif