-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircleVector.h
More file actions
59 lines (52 loc) · 1.06 KB
/
Copy pathCircleVector.h
File metadata and controls
59 lines (52 loc) · 1.06 KB
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
#ifndef CIRCLEVECTOR_H
#define CIRCLEVECTOR_H
#include <SDL2/SDL.h>
#include <math.h>
#include <array>
const int numOfCircles = 10;
struct Vector
{
double x, y;
public:
Vector(): x(0), y(0) {}
Vector(double x, double y): x(x), y(y) {}
Vector operator-(Vector& v);
Vector operator+(Vector& v);
double dotProduct(Vector& v);
void norm();
Vector project(Vector& n);
};
struct Circle
{
Circle():
posX(rand() % 780 + 10),
posY(rand() % 580 + 10),
velX(rand() % 2 - 1),
velY(rand() % 2 - 1),
pos(posX, posY),
vel(velX, velY)
{}
void vectorToCoordinates();
void coordinatesToVector();
int posX;
int posY;
int velX;
int velY;
Vector pos;
Vector vel;
};
class CircleVector : public std::array<Circle, numOfCircles>
{
public:
CircleVector(SDL_Renderer* renderer);
virtual ~CircleVector();
void move();
void render();
bool haveCollided(Circle* circle_1, Circle* circle_2);
protected:
private:
SDL_Texture * circleTexture;
SDL_Renderer* mRenderer;
int diameter;
};
#endif // CIRCLEVECTOR_H