-
Notifications
You must be signed in to change notification settings - Fork 4
/
power_up.h
160 lines (135 loc) · 2.4 KB
/
power_up.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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#pragma once
#include <windows.h>
#include <gl/gl.h>
#include <gl/glut.h>
#include <ctime>
#include <cstdio>
#include<synchapi.h>
#include<iostream>
#include<sstream>
#include"cars.h"
using namespace std;
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glut32.lib")
class power_up
{
public:
int x , y , z = 1;
boolean draw = false;
float speed = 2.8;
char identifier;
power_up(int x, int y) {
this->x = x;
this->y = y;
}
void struct_power_up_invincible() {
if (draw) {
glPushMatrix();
glTranslatef(x, y, 0);
glBegin(GL_POLYGON);
glColor3f(1, 0, 0);
glVertex2f(0, 5);
glVertex2f(10, -1);
glVertex2f(7, -15);
glColor3f(0, 1, 0);
glVertex2f(0, -23);
glVertex2f(-7, -15);
glColor3f(0, 0, 1);
glVertex2f(-10, -1);
glVertex2f(0, 5);
glEnd();
y -= speed;
if (y < -290)
{
draw = false;
y = 400;
}
if (z == 1) {
if (rand() % 2 == 0)
{
x = -50;
}
else if (rand() % 3 == 0)
{
x = 0;
}
else
{
x = 50;
}
glTranslatef(x, y, 0);
z = 0;
}
glPopMatrix();
}
};
void draw_power_up_invincible(int score) {
if (score != 0) {
if (score % 15 == 0 | draw ) {
draw = true;
struct_power_up_invincible();
if (!draw) {
z = 1;
}
}
}
}
void struct_power_up_double_score() {
if (draw) {
glPushMatrix();
glColor3f(1,1,1);
glTranslatef(x, y, 0);
glLineWidth(4);
glBegin(GL_LINE_STRIP);
glVertex2f(-5, 10);
glVertex2f(0, 15);
glVertex2f(5, 5);
glVertex2f(-5, -5);
glVertex2f(5, -5);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(5, 0);
glVertex2f(15, 15);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(15, 0);
glVertex2f(5, 15);
glEnd();
y -= speed;
if (y < -290)
{
draw = false;
y = 400;
}
if (z == 1) {
if (rand() % 2 == 0)
{
x = -50;
}
else if (rand() % 3 == 0)
{
x = 0;
}
else
{
x = 50;
}
glTranslatef(x, y, 0);
z = 0;
}
glPopMatrix();
}
};
void draw_power_up_double_score(int score) {
if (score != 0) {
if (score % 25 == 0 | draw) {
draw = true;
struct_power_up_double_score();
if (!draw) {
z = 1;
}
}
}
}
};