-
Notifications
You must be signed in to change notification settings - Fork 0
/
ThreatsObject.cpp
61 lines (42 loc) · 1.03 KB
/
ThreatsObject.cpp
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
#include "ThreatsObject.h"
#include<ctime>
int a[30]={-400,-390,-380,-370,-360,-350,-340,-330,-320,-310,-300,-280,-270,-260,-250,-240,-230,-220,-210,-200,-190,-180,-170,-160,-150,-140,-130,-120,-110};
int temp;
ThreatObject::ThreatObject()
{
rect_.x = SCREEN_WIDTH;
rect_.y = 0;
rect_.w = WIDTH_THREAT;
rect_.h = HEIGHT_THREAT;
x_val_ = 0;
y_val_ = 0;
}
ThreatObject::~ThreatObject()
{
;
}
void ThreatObject::HandleMove1(const int&x_bordr1, const int& y_bordr1)
{
rect_.x -= x_val_;
if(rect_.x < -100)
{
rect_.x = SCREEN_WIDTH;
srand(time(0));
rect_.y = a[rand() % 29];
temp = rect_.y;
}
}
void ThreatObject::HandleMove2(const int&x_bordr2, const int& y_bordr2)
{
rect_.x -= x_val_;
if(rect_.x < -100)
{
rect_.x = SCREEN_WIDTH;
rect_.y = temp + 600+GAP_THREAT;
}
}
void ThreatObject::Show_1(SDL_Renderer*des)
{
SDL_Rect renderquad = {rect_.x, rect_.y, rect_.w, rect_.h};
SDL_RenderCopy(des,p_object_,NULL, &renderquad);
}