Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- class Scroller {
- public:
- float curx, cury, movx, movy;
- int timeLeft;
- Scroller(float x, float y) :
- curx(x),cury(y) {
- }
- void moveToPosInTime(float newx, float newy, int time) {
- timeLeft = time;
- movx = (newx-curx)/time;
- movy = (newy-cury)/time;
- }
- bool isMoving() {
- return timeLeft > 0;
- }
- void loop() {
- if (isMoving()) {
- curx += movx;
- cury += movy;
- timeLeft--;
- }
- }
- };
- Scroller scrollerPos(0,0);//you can set this to beginning positiion idk doesn't matter
- Vector2 getNewScrollerPos() {
- //you need to code this to return the positionn of where the scroller is going to be at, like in a regular menu.
- //so something like selectedOption * optionSize + baseMenuHeight yannow
- }
- void loopScrollerStuff() {
- if (JustPressedUpOrDownAkaMadeTheScrollerPositionChange) {
- //now update position
- Vector2 newPos = getNewScrollerPos();
- scrollerPos.moveToPosInTime(newPos.x,newPos.y,10);//might want to change time to something else
- }
- }
- void hook() {
- //this will simulate our hook
- loopScrollerStuff();
- //now use scrollerPos.x for the x position, and scrollerPos.y for the y position
- }
- int main()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement