forked from henriquevital00/pong-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ball.h
40 lines (31 loc) · 754 Bytes
/
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
#pragma once
#include "SDL/SDL.h"
#include "Utils.h"
#include "Paddle.h"
class Ball
{
public:
Ball(
Vector2 position = Vector2::Zero(),
float radius = 15.f,
float speed = 1.f,
Vector2 velocity = Vector2::Zero(),
Vector2 acceleration = Vector2::Zero(),
Vector4 color = Vector4(255, 255, 0, 255)
);
void Draw(SDL_Renderer* renderer);
bool DidCollideWithPaddle(Paddle* paddle);
void CheckCollisionWithAnotherBall(Ball* ball);
void InvertVelocityOnPaddleCollide(Paddle* paddle, bool hasToUpdateSpeed);
Vector2 position;
float radius;
float speed;
Vector2 velocity;
Vector2 acceleration;
Vector4 color;
bool isTouchingPaddle[2] = {false, false};
Uint32 start = 0;
Uint32 end = 0;
Vector2 topLeft;
Vector2 bottomRight;
};