Merge branch 'master' of github.com:ralucado/WaveGGJ17
This commit is contained in:
commit
3ba7354efe
4 changed files with 83 additions and 3 deletions
|
@ -8,11 +8,13 @@ SOURCES += main.cpp \
|
|||
game.cpp \
|
||||
mygame.cpp \
|
||||
button.cpp \
|
||||
character.cpp
|
||||
character.cpp \
|
||||
compas.cpp
|
||||
|
||||
HEADERS += \
|
||||
game.hpp \
|
||||
mygame.hpp \
|
||||
commons.hpp \
|
||||
button.hpp \
|
||||
character.hpp
|
||||
character.hpp \
|
||||
compas.hpp
|
||||
|
|
50
VaporWaveWars/compas.cpp
Normal file
50
VaporWaveWars/compas.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include "compas.hpp"
|
||||
|
||||
Compas::Compas() {
|
||||
spaceTime = 0;
|
||||
isPress = false;
|
||||
}
|
||||
|
||||
void Compas::start() {
|
||||
if (not isPress) {
|
||||
std::cout << "start" << std::endl;
|
||||
isPress = true;
|
||||
spaceTime = 0;
|
||||
notes = std::vector<int>();
|
||||
}
|
||||
}
|
||||
|
||||
void Compas::add() {
|
||||
if (isPress) {
|
||||
notes.push_back(spaceTime);
|
||||
spaceTime = 0;
|
||||
std::cout << "add" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Compas::end() {
|
||||
if (isPress) {
|
||||
isPress = false;
|
||||
std::cout << "end" << std::endl;
|
||||
for (int i = 0; i < notes.size(); ++i) {
|
||||
std::cout << notes[i] << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Compas::incriseTime() {
|
||||
++spaceTime;
|
||||
}
|
||||
|
||||
int Compas::get (int i) const {
|
||||
return notes[i];
|
||||
}
|
||||
|
||||
bool Compas::operator ==(const Compas& d) const{
|
||||
int n = notes.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
float diff = ((float) (std::abs(notes[i] - d.get(i))))/((float) (notes[i]));
|
||||
if (diff > margeErr) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
28
VaporWaveWars/compas.hpp
Normal file
28
VaporWaveWars/compas.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef COMPAS_HPP
|
||||
#define COMPAS_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
static const float margeErr = 0.80f;
|
||||
|
||||
class Compas
|
||||
{
|
||||
|
||||
private:
|
||||
bool isPress;
|
||||
int spaceTime;
|
||||
std::vector<int> notes;
|
||||
|
||||
public:
|
||||
Compas();
|
||||
void start();
|
||||
void add();
|
||||
void end();
|
||||
void incriseTime();
|
||||
int get(int i) const;
|
||||
bool operator ==(const Compas& d) const;
|
||||
};
|
||||
|
||||
#endif // COMPAS_HPP
|
|
@ -1,5 +1,5 @@
|
|||
#include "mygame.hpp"
|
||||
|
||||
#include "compas.hpp"
|
||||
int main() {
|
||||
MyGame game = MyGame();
|
||||
game.run();
|
||||
|
|
Reference in a new issue