fixed merge with compass

This commit is contained in:
Ralusama19 2017-01-21 01:07:31 +01:00
commit 98506b1121
5 changed files with 20 additions and 12 deletions

View file

@ -10,6 +10,9 @@
const int SCENE_NUM = 4;
#define MARGEERR 0.30f
#define BLACKVALUE 0.00025f
#define ASSERT(expression) do \
{ \
if(!(expression)) { \

View file

@ -1,7 +1,7 @@
#include "compas.hpp"
Compas::Compas() {
spaceTime = 0;
spaceTime = 1;
isPress = false;
}
@ -9,7 +9,7 @@ void Compas::start() {
if (not isPress) {
std::cout << "start" << std::endl;
isPress = true;
spaceTime = 0;
spaceTime = 1;
notes = std::vector<int>();
}
}
@ -17,7 +17,7 @@ void Compas::start() {
void Compas::add() {
if (isPress) {
notes.push_back(spaceTime);
spaceTime = 0;
spaceTime = 1;
std::cout << "add" << std::endl;
}
}
@ -32,7 +32,7 @@ void Compas::end() {
}
}
void Compas::incriseTime() {
void Compas::incraeseTime() {
++spaceTime;
}
@ -40,11 +40,16 @@ int Compas::get (int i) const {
return notes[i];
}
int Compas::size() const {
return notes.size();
}
bool Compas::operator ==(const Compas& d) const{
int n = notes.size();
if (n != d.size()) return false;
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;
if (diff > MARGEERR) return false;
}
return true;
}

View file

@ -4,23 +4,22 @@
#include <vector>
#include <iostream>
#include <cmath>
#include <commons.hpp>
static const float margeErr = 0.80f;
class Compas{
class Compas {
private:
bool isPress;
int spaceTime;
std::vector<int> notes;
int get(int i) const;
int size() const;
public:
Compas();
void start();
void add();
void end();
void incriseTime();
int get(int i) const;
void incraeseTime();
bool operator ==(const Compas& d) const;
};

View file

@ -5,7 +5,6 @@ MyGame::MyGame() {
_scenes = std::vector<Scene*>(SCENE_NUM);
_scenes[GameScene::menu] = &_menu;
std::cout << "in menu" << std::endl;
}
MyGame::~MyGame() {
@ -21,6 +20,7 @@ void MyGame::changeScene(GameScene::gameScene n){
// Main game loop
void MyGame::update(float deltaTime, sf::RenderWindow*window) {
// std::cout << deltaTime << std::endl;
sf::Event event;
while(window->pollEvent(event)){
switch (event.type) {

View file

@ -1,6 +1,7 @@
#ifndef MYGAME_HPP
#define MYGAME_HPP
#include "game.hpp"
#include "menu.hpp"
class MyGame : public Game{