generated from 32blit/32blit-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ball.hpp
53 lines (46 loc) · 1.23 KB
/
Ball.hpp
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
/*
* Ball.hpp - part of 32Blox (revised edition!)
*
* Copyright (C) 2020 Pete Favelle <[email protected]>
*
* This file is released under the MIT License; see LICENSE for details
*
* The Ball object is a simple encapsulation of, well, a ball.
*/
#ifndef _BALL_HPP_
#define _BALL_HPP_
typedef enum
{
BALL_NORMAL,
BALL_SMALL,
BALL_MAX
} ball_type_t;
class Ball
{
private:
blit::Vec2 location;
blit::Vec2 vector;
float speed;
ball_type_t ball_type;
blit::Rect bat_position;
const uint8_t ball_size[BALL_MAX] = { 8, 6 };
float compute_bat_angle( void );
blit::Point get_render_location( void );
public:
Ball( blit::Point, float = 1.5, ball_type_t = BALL_NORMAL );
blit::Rect get_bounds( void );
ball_type_t get_type( void );
bool moving_up( void );
bool moving_left( void );
void update( void );
void render( void );
void launch( void );
void randomise( void );
void bounce( bool );
bool bat_bounce( uint16_t, bool );
void offset( blit::Vec2 );
void move_bat( blit::Rect, float, bool );
bool stuck;
};
#endif /* _BALL_HPP_ */
/* End of Ball.hpp */