瀏覽代碼

Merge pull request #78 from Streetwalrus/master

Re-add arrow key adjustment during drags (again)
Dalton Nell 7 年之前
父節點
當前提交
97d200f40a
共有 1 個檔案被更改,包括 17 行新增1 行删除
  1. 17
    1
      src/slopstates.cpp

+ 17
- 1
src/slopstates.cpp 查看文件

113
     if ( !mouse->getButton( 1 ) ) {
113
     if ( !mouse->getButton( 1 ) ) {
114
         memory.setState( (SlopState*)new SlopEndDrag() );
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