Selaa lähdekoodia

Merge pull request #78 from Streetwalrus/master

Re-add arrow key adjustment during drags (again)
Dalton Nell 7 vuotta sitten
vanhempi
commit
97d200f40a
1 muutettua tiedostoa jossa 17 lisäystä ja 1 poistoa
  1. 17
    1
      src/slopstates.cpp

+ 17
- 1
src/slopstates.cpp Näytä tiedosto

@@ -113,7 +113,23 @@ void slop::SlopStartDrag::update( SlopMemory& memory, double dt ) {
113 113
     if ( !mouse->getButton( 1 ) ) {
114 114
         memory.setState( (SlopState*)new SlopEndDrag() );
115 115
     }
116
-    if ( keyboard->getKey( XK_Down ) ) {
116
+    if ( keyboard ) {
117
+        int arrows[2];
118
+        arrows[0] = keyboard->getKey(XK_Down)-keyboard->getKey(XK_Up);		
119
+        arrows[1] = keyboard->getKey(XK_Right)-keyboard->getKey(XK_Left);		
120
+        if ( arrows[0] || arrows[1] ) {		
121
+            if ( repeatTimer == 0 || repeatTimer > .4 ) {		
122
+                startPoint.y += arrows[0]*multiplier;		
123
+                startPoint.x += arrows[1]*multiplier;		
124
+            }		
125
+            if ( repeatTimer > 1 ) {		
126
+                multiplier += dt*2;		
127
+            }		
128
+            repeatTimer += dt;		
129
+        } else {		
130
+            repeatTimer = 0;		
131
+            multiplier = 1;		
132
+        }
117 133
     }
118 134
 }
119 135