-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcue.cpp
More file actions
76 lines (59 loc) · 1.39 KB
/
cue.cpp
File metadata and controls
76 lines (59 loc) · 1.39 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
/*
* cue.cpp
* Stepilicious
*
* Created by Magnus Selin on 4/29/13.
* Copyright 2013 __MyCompanyName__. All rights reserved.
*
*/
#include "cue.h"
sf::Image Cue::cue_img;
Cue::Cue(){
clock.Reset();
bpm = 120;
pos = 0;
for (int i = 0; i < LENGTH; i++){
img_col[i][0] = 100;
img_col[i][1] = 100;
img_col[i][2] = 100;
img_pos[i][0] = i * 70 + 100;
img_pos[i][1] = 380;
}
}
// Static functions
// ********************************************************
bool Cue::init(){
if (!cue_img.LoadFromFile("button.jpg")){
std::cerr << "Couldn't load cue image!";
return false;
}
std::cerr << "Succesfully loaded image!\n";
return true;
}
// ********************************************************
bool Cue::update(){
float min_ela = clock.GetElapsedTime() / (60 / 4);
if(min_ela * bpm > 1){
clock.Reset();
img_col[pos][0] = 100;
img_col[pos][1] = 100;
img_col[pos][2] = 100;
pos++;
pos = pos % LENGTH;
img_col[pos][0] = 200;
img_col[pos][1] = 200;
img_col[pos][2] = 100;
return true;
}
return false;
}
void Cue::draw(sf::RenderWindow * window){
for(int i = 0; i < LENGTH; i++){
sf::Sprite tmp_img(cue_img);
tmp_img.SetPosition(img_pos[i][0], img_pos[i][1]);
tmp_img.SetColor(sf::Color(img_col[i][0], img_col[i][1], img_col[i][2], 200));
tmp_img.Scale(1, 0.5);
window->Draw(tmp_img);
}
}
int Cue::get_pos(){ return pos; }