view SequenceController.h @ 28:953db6518738

leap version more or less there, needs btter results feedback but thats detail. "no movement" bit is stupid cos peopel can move their hand. light flash not work.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 30 Oct 2014 18:35:00 +0000
parents 27cdf475aa4b
children e7af34b1af83
line wrap: on
line source
//
//  SequenceGenerator.h
//  riftathon
//
//  Created by Robert Tubb on 21/10/2014.
//
//

#ifndef __riftathon__SequenceGenerator__
#define __riftathon__SequenceGenerator__

#include <iostream>
#include "ofMain.h"

#define MIN_TARGETS_IN_SEQUENCE 2
#define MAX_TARGETS_IN_SEQUENCE 5
#define MIN_TEMPO   60
#define MAX_TEMPO   300
#define NUM_TEMPO_STEPS 12
#define NUM_PRESETS 8
#define NO_GUIDES_LEVEL true
class AnimStep{

    
public:
    
    AnimStep();
    typedef enum {PREVIEW_NEUTRAL_COUNT,
                MATCHING_NEUTRAL_COUNT,
                PREVIEW_MOVE,
                PREVIEW_HIT,
                MATCHING_MOVE,
                MATCHING_HIT}
                stepType;
    
    stepType type;
    
    float getTimeBetweenTicks(){
        return 1000* (60.0/tempo);
    }
    int presetIndex;
    int whichInSequence;
    bool isLastOfAll;

    int tempo;
    int seqNumber;
    int runNumber;
    bool isLastOfSeq;
    bool isLastOfRun;
    
    bool showsGuides; // depends on 'level'
    
    vector<int> thisSequence; // so that we can show the whole sequence at the top?
};

class Step{
public:
    typedef enum {COUNT_IN, PREVIEW_PREPARER, PREVIEW_DISPLAYER, MATCHING_PREPARER, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes;
    
    Step();
    
// gui display
    bool showsTargetIcon;
    bool showsControlSettings;
    bool showsControlGuides;
    bool showsMatchResults;
// gui input
    bool allowsCandidateControl;
// sound
    bool playsTarget;
    bool playsCandidate;
// control flow
    stepTypes type;
    bool isPreview;
    
    int seqNumber;
    int runNumber;
    bool isLastOfSeq;
    bool isLastOfRun;
    bool showsCountDown;
    bool hidesSliders;
    int tempo;
// preset info
    int presetIndex;
    int numInSequence;
    bool isLastOfAll;

    void setAsBlankCounter();
    void setAsPreviewPreparer();
    void setAsPreviewPlayer();
    void setAsMatchingPreparer();
    void setAsMatchingInteraction();
    void setAsMatchingFeedback();
    
    float getTimeBetweenTicks(){
        return 1000. * (60.0/tempo);
    }
};

class SequenceController{
public:
    SequenceController();
    AnimStep getNextStep();
    void setToStart();
    void stepForward();
    float getStartTickTime();
private:
    void generateSteps();
    void generateCountIn(int countInLength);
    void generateARun(int run, int numInSequence);
    vector<int> randomSequence(int numInSequence);
    
    int getRandomButNot(int max, vector<int> notThese);
protected:
    vector<AnimStep> steps;
    vector<AnimStep>::iterator currentStep;
    float tempoInc;
};

#endif /* defined(__riftathon__SequenceGenerator__) */