forked from shivankar-p/game
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrow.cpp
More file actions
81 lines (76 loc) · 1.63 KB
/
Arrow.cpp
File metadata and controls
81 lines (76 loc) · 1.63 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "Arrow.h"
#include "TexManager.h"
#include "Gameboard.h"
Arrow::Arrow(const char* texsheet, int inx, int iny)
{
obtex = TexManager::Load(texsheet);
x = inx;
y = iny;
src.h = 64;
src.w = 64;
src.x = 0;src.y = 0;
dst.x = x;
dst.y = y;
dst.w = src.w*2;
dst.h = src.h*2;
}
void Arrow::update(int pos, int* miss, int* scr, int* cnt)
{
if(x+15 < 1140)
{
x += 15;
if(x == 65) *cnt = *cnt+1;
cout << *cnt << endl;
}
else
{
//if(x >= 1140) return;
int brdpos = pos;
if(brdpos < 308 || brdpos > 410)
{
cout << "miss" << endl;
if(x < 1140)
{
*miss = *miss+1;
x = 1140;
}
x += 1;
}
else if(brdpos <= 320 || brdpos >= 398)
{
cout << "Black" << endl;
if(x < 1173) *scr += 4;
x = 1173;
}
else if(brdpos <= 336 || brdpos >= 382)
{
cout << "Blue" << endl;
if(x < 1162) *scr += 6;
x = 1162;
}
else if(brdpos <= 348 || brdpos >= 366)
{
cout << "Red" << endl;
if(x < 1151) *scr += 8;
x = 1151;
}
else
{
cout << "Yellow" << endl;
if(x < 1140) *scr += 10;
x = 1140;
}
}
//y+=3;
src.h = 64;
src.w = 64;
src.x = 0;src.y = 0;
dst.x = x;
dst.y = y;
dst.w = src.w*2;
dst.h = src.h*2;
}
void Arrow::render()
{
SDL_RenderCopy(Game::renderer, obtex,nullptr, &dst);
}