-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCoin.cpp
More file actions
52 lines (49 loc) · 2.17 KB
/
Coin.cpp
File metadata and controls
52 lines (49 loc) · 2.17 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
#include"Object.h"
#include "Coin.hpp"
Coin::Coin(const char* texturename, SDL_Renderer* ren, int x, int y, int r, float mass,int coinscore) : Object( texturename, ren, x, y){
this->radius = r;
this->mass = mass;
this->vel.set(0 ,0);
this->acc.set(0, 0);
this->coinID = id++;
this->coinScore = coinscore;
}
void Coin:: move(){
/*if ((this->vel.getX() > 0.0000002) && (this->vel.getY() > 0.0000002))
{
this->vel.set(this->vel.getX() - 0.0000002, this->vel.getY() - 0.0000002);
this->pos = this->pos.add(this->vel);
this->pos = this->pos.add(this->vel);
}
else if(this->vel.getX() < -0.0000002 && this->vel.getY() < -0.0000002)
{
this->vel.set(this->vel.getX() + 0.0000002, this->vel.getY() + 0.0000002);
this->pos = this->pos.add(this->vel);
this->pos = this->pos.add(this->vel);
}
else if(this->vel.getX() < -0.0000002 && this->vel.getY() > 0.0000002)
{
this->vel.set(this->vel.getX() + 0.0000002, this->vel.getY() - 0.0000002);
this->pos = this->pos.add(this->vel);
this->pos = this->pos.add(this->vel);
}
else if(this->vel.getX() > 0.0000002 && this->vel.getY() < -0.0000002)
{
this->vel.set(this->vel.getX() - 0.0000002, this->vel.getY() + 0.0000002);
this->pos = this->pos.add(this->vel);
this->pos = this->pos.add(this->vel);
}
else
{
this->vel.set(0, 0);
}*/
if (this->vel.getMagnitute() < 0.005) this->vel.set(0,0);
this->pos = this->pos.add(this->vel);
this->pos = this->pos.add(this->vel);
//this->vel.set(this->vel.getX() - 0.1, this->vel.getY() - 0.1);
if(this->vel.getMagnitute() > 0.01)
this->vel = this->vel.multiply(0.9998);
else
this->vel = this->vel.multiply(0.998);
}
int Coin:: Coin:: id = 0;