Explorar el Código

Merge pull request #78 from Streetwalrus/master

Re-add arrow key adjustment during drags (again)
Dalton Nell hace 7 años
padre
commit
97d200f40a
Se han modificado 1 ficheros con 17 adiciones y 1 borrados
  1. 17
    1
      src/slopstates.cpp

+ 17
- 1
src/slopstates.cpp Ver fichero

@@ -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