Advertisement
gopro2027

Untitled

Jul 19th, 2018
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Scroller {
  5. public:
  6.     float curx, cury, movx, movy;
  7.     int timeLeft;
  8.     Scroller(float x, float y) :
  9.     curx(x),cury(y) {
  10.        
  11.     }
  12.    
  13.     void moveToPosInTime(float newx, float newy, int time) {
  14.         timeLeft = time;
  15.         movx = (newx-curx)/time;
  16.         movy = (newy-cury)/time;
  17.     }
  18.    
  19.     bool isMoving() {
  20.         return timeLeft > 0;
  21.     }
  22.    
  23.     void loop() {
  24.         if (isMoving()) {
  25.             curx += movx;
  26.             cury += movy;
  27.             timeLeft--;  
  28.         }
  29.     }
  30.    
  31. };
  32.  
  33. Scroller scrollerPos(0,0);//you can set this to beginning positiion idk doesn't matter
  34.  
  35. Vector2 getNewScrollerPos() {
  36.     //you need to code this to return the positionn of where the scroller is going to be at, like in a regular menu.
  37.     //so something like selectedOption * optionSize + baseMenuHeight yannow
  38. }
  39.  
  40. void loopScrollerStuff() {
  41.     if (JustPressedUpOrDownAkaMadeTheScrollerPositionChange) {
  42.         //now update position
  43.         Vector2 newPos = getNewScrollerPos();
  44.         scrollerPos.moveToPosInTime(newPos.x,newPos.y,10);//might want to change time to something else
  45.     }
  46. }
  47.  
  48. void hook() {
  49.     //this will simulate our hook
  50.     loopScrollerStuff();
  51.    
  52.     //now use scrollerPos.x for the x position, and scrollerPos.y for the y position
  53. }
  54.  
  55. int main()
  56. {
  57.    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement