-
Notifications
You must be signed in to change notification settings - Fork 0
/
pong3d.c
32 lines (26 loc) · 814 Bytes
/
pong3d.c
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
/**
@file pong3d.c
@author Alejandro Ambroa
@date 1 Oct 2017
@brief General data and utils for game.
*/
#include "pong3d.h"
#include "geometry.h"
GAME_STATE gameState, prevGameState;
void change_state(GAME_STATE state)
{
prevGameState = gameState;
gameState = state;
}
int ball_in_player_stick()
{
return ball_in_stick(ball.x, ball.y, ball.width, &player_stick);
}
int ball_in_opponent_stick()
{
return ball_in_stick(ball.x, ball.y, ball.width, &opponent_stick);
}
int ball_in_stick(float ball_x, float ball_y, float ball_width, PONG_ELEMENT* stick)
{
return ((ball_x - ball_width) < (stick->x + stick->width2) && (ball_x + ball_width) > (stick->x - stick->width2) && (ball_y - ball_width) < (stick->y + stick->height2) && (ball_y + ball_width) > (stick->y - stick->height2));
}