-
Notifications
You must be signed in to change notification settings - Fork 0
/
bubbles.cpp
75 lines (56 loc) · 1.56 KB
/
bubbles.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: buble.cpp
* Author: deboramorita
*
* Created on March 16, 2017, 11:16 PM
*/
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <cmath>
#include <iostream>
#include "bubbles.h"
using namespace std;
Bubbles::Bubbles(double time, int size, vec3 position) : Attack(time) {
for (int i = 0; i < size; i++) {
this->bubbles.push_back(Bubble(time, position));
}
}
Bubbles::~Bubbles() {
}
void Bubbles::draw() {
for (int i = 0; i < bubbles.size(); i++) {
this->bubbles[i].draw();
}
}
void Bubbles::idle() {
bool active = false;
for (int i = 0; i < bubbles.size(); i++) {
this->bubbles[i].idle();
active |= this->bubbles[i].active;
}
this->active = active;
}
void Bubbles::collisionDetection() {
}
void Bubbles::reset() {
if (!this->active) {
for (int i = 0; i < bubbles.size(); i++) {
this->bubbles[i].target = this->target;
this->bubbles[i].reset();
this->bubbles[i].size = ((rand() % 9) / 10.0) + 0.1;
this->bubbles[i].size_s = ((rand() % 9) / 10.0) + 0.1;
this->bubbles[i].velocity_i.y = (rand() % 19) + 11;
this->bubbles[i].velocity_i.x = (rand() % 19) + 11;
this->bubbles[i].velocity_i.z = ((rand() % 30) + 15) * (-1);
this->bubbles[i].active = true;
}
}
}