Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. class Timeline {
  2. private:
  3.     RectangleShape rect;
  4.     RectangleShape tLine;
  5.     float songBPM;
  6.     int songMS;
  7.     float songOffset;
  8.     int songDuration;
  9.     float songMultiplier;
  10.     int songSnapMultiplier;
  11.     float MSBB;
  12.  
  13. public:
  14.     Timeline(int positionX, int positionY, Vector2f size) {
  15.         rect.setPosition(positionX,positionY);
  16.         rect.setSize(size);
  17.         tLine.setPosition(0,positionY);
  18.         tLine.setSize(Vector2f(1,size.y));
  19.     }
  20.  
  21.     void updateTiming(float beatsPerMinute, int currentMS, float offset, int duration, float multiplier, int snapMultiplier) {
  22.         songBPM = beatsPerMinute;
  23.         songMS = currentMS;
  24.         songOffset = offset;
  25.         songDuration = duration;
  26.         songMultiplier = multiplier;
  27.         songSnapMultiplier = snapMultiplier;
  28.     }
  29.  
  30.     void draw(RenderWindow *renderWindow) {
  31.         renderWindow->draw(rect);
  32.  
  33.         MSBB = (60/songBPM)*1000;
  34.         songMS-=songOffset;
  35.         float increment = ((MSBB/songMultiplier)/songSnapMultiplier);
  36.         float move = songMS-songMultiplier;
  37.  
  38.         for(int draw = 0; draw < 1024; draw+=increment) {
  39.             tLine.setPosition(512+(draw-move),tLine.getPosition().y);
  40.             renderWindow->draw(tLine);
  41.         }
  42.     }
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement