branch | hedgeroid |
changeset 6228 | 1b7d4d7d162b |
parent 6029 | 5073285b6599 |
child 6344 | cba81e10235c |
6226:3106add9a5bf | 6228:1b7d4d7d162b |
---|---|
155 var |
155 var |
156 finger, secondFinger: PTouch_Finger; |
156 finger, secondFinger: PTouch_Finger; |
157 currentPinchDelta, zoom : hwFloat; |
157 currentPinchDelta, zoom : hwFloat; |
158 tmpX, tmpY: LongInt; |
158 tmpX, tmpY: LongInt; |
159 begin |
159 begin |
160 x := x; |
|
161 y := y; |
|
162 dx := dx; |
|
163 dy := dy; |
|
160 finger:= findFinger(pointerId); |
164 finger:= findFinger(pointerId); |
161 tmpX := convertToCursor(cScreenWidth, x); |
165 tmpX := convertToCursor(cScreenWidth, x); |
162 tmpY := convertToCursor(cScreenHeight, y); |
166 tmpY := convertToCursor(cScreenHeight, y); |
163 |
167 |
164 if moveCursor then |
168 if moveCursor then |
197 end; |
201 end; |
198 end; |
202 end; |
199 |
203 |
200 procedure onTouchUp(x,y: Longword; pointerId: SDL_FingerId); |
204 procedure onTouchUp(x,y: Longword; pointerId: SDL_FingerId); |
201 begin |
205 begin |
206 x := x; |
|
207 y := y; |
|
202 aiming:= false; |
208 aiming:= false; |
203 stopFiring:= true; |
209 stopFiring:= true; |
204 deleteFinger(pointerId); |
210 deleteFinger(pointerId); |
205 |
211 |
206 if walkingLeft then |
212 if walkingLeft then |
216 end; |
222 end; |
217 end; |
223 end; |
218 |
224 |
219 procedure onTouchDoubleClick(finger: Touch_Finger); |
225 procedure onTouchDoubleClick(finger: Touch_Finger); |
220 begin |
226 begin |
227 finger := finger;//avoid compiler hint |
|
221 ParseCommand('ljump', true); |
228 ParseCommand('ljump', true); |
222 end; |
229 end; |
223 |
230 |
224 procedure onTouchClick(finger: Touch_Finger); |
231 procedure onTouchClick(finger: Touch_Finger); |
225 begin |
232 begin |
257 function addFinger(x,y: Longword; id: SDL_FingerId): PTouch_Finger; |
264 function addFinger(x,y: Longword; id: SDL_FingerId): PTouch_Finger; |
258 var |
265 var |
259 xCursor, yCursor, index : LongInt; |
266 xCursor, yCursor, index : LongInt; |
260 begin |
267 begin |
261 //Check array sizes |
268 //Check array sizes |
262 if length(fingers) < pointerCount then |
269 if length(fingers) < Integer(pointerCount) then |
263 begin |
270 begin |
264 setLength(fingers, length(fingers)*2); |
271 setLength(fingers, length(fingers)*2); |
265 for index := length(fingers) div 2 to length(fingers) do fingers[index].id := nilFingerId; |
272 for index := length(fingers) div 2 to length(fingers) do fingers[index].id := nilFingerId; |
266 end; |
273 end; |
267 |
274 |
282 inc(pointerCount); |
289 inc(pointerCount); |
283 end; |
290 end; |
284 |
291 |
285 procedure deleteFinger(id: SDL_FingerId); |
292 procedure deleteFinger(id: SDL_FingerId); |
286 var |
293 var |
287 index : Longint; |
294 index : Longword; |
288 begin |
295 begin |
289 |
296 |
290 dec(pointerCount); |
297 dec(pointerCount); |
291 for index := 0 to pointerCount do |
298 for index := 0 to pointerCount do |
292 begin |
299 begin |
382 hogX, hogY, touchX, touchY, deltaX, deltaY, tmpAngle: hwFloat; |
389 hogX, hogY, touchX, touchY, deltaX, deltaY, tmpAngle: hwFloat; |
383 tmp: ShortString; |
390 tmp: ShortString; |
384 begin |
391 begin |
385 if CurrentHedgehog^.Gear <> nil then |
392 if CurrentHedgehog^.Gear <> nil then |
386 begin |
393 begin |
394 touchX := _0;//avoid compiler hint |
|
395 touchY := _0; |
|
387 hogX := CurrentHedgehog^.Gear^.X; |
396 hogX := CurrentHedgehog^.Gear^.X; |
388 hogY := CurrentHedgehog^.Gear^.Y; |
397 hogY := CurrentHedgehog^.Gear^.Y; |
389 |
398 |
390 convertToWorldCoord(touchX, touchY, finger); |
399 convertToWorldCoord(touchX, touchY, finger); |
391 deltaX := hwAbs(TouchX-HogX); |
400 deltaX := hwAbs(TouchX-HogX); |
418 |
427 |
419 function isOnCrosshair(finger: Touch_Finger): boolean; |
428 function isOnCrosshair(finger: Touch_Finger): boolean; |
420 var |
429 var |
421 x,y : hwFloat; |
430 x,y : hwFloat; |
422 begin |
431 begin |
432 x := _0;//avoid compiler hint |
|
433 y := _0; |
|
423 convertToFingerCoord(x, y, int2hwFloat(CrosshairX), int2hwFloat(CrosshairY)); |
434 convertToFingerCoord(x, y, int2hwFloat(CrosshairX), int2hwFloat(CrosshairY)); |
424 isOnCrosshair:= Distance(int2hwFloat(finger.x)-x, int2hwFloat(finger.y)-y) < _50; |
435 isOnCrosshair:= Distance(int2hwFloat(finger.x)-x, int2hwFloat(finger.y)-y) < _50; |
425 end; |
436 end; |
426 |
437 |
427 function isOnCurrentHog(finger: Touch_Finger): boolean; |
438 function isOnCurrentHog(finger: Touch_Finger): boolean; |
428 var |
439 var |
429 x,y : hwFloat; |
440 x,y : hwFloat; |
430 begin |
441 begin |
442 x := _0; |
|
443 y := _0; |
|
431 convertToFingerCoord(x, y, CurrentHedgehog^.Gear^.X, CurrentHedgehog^.Gear^.Y); |
444 convertToFingerCoord(x, y, CurrentHedgehog^.Gear^.X, CurrentHedgehog^.Gear^.Y); |
432 isOnCurrentHog := Distance(int2hwFloat(finger.X)-x, int2hwFloat(finger.Y)-y) < _50; |
445 isOnCurrentHog := Distance(int2hwFloat(finger.X)-x, int2hwFloat(finger.Y)-y) < _50; |
433 end; |
446 end; |
434 |
447 |
435 procedure convertToFingerCoord(var x,y : hwFloat; oldX, oldY: hwFloat); |
448 procedure convertToFingerCoord(var x,y : hwFloat; oldX, oldY: hwFloat); |
470 WriteToConsole(Format('id:%d, (%d,%d), (%d,%d), time: %d', [finger.id, finger.x, finger.y, finger.historicalX, finger.historicalY, finger.timeSinceDown])); |
483 WriteToConsole(Format('id:%d, (%d,%d), (%d,%d), time: %d', [finger.id, finger.x, finger.y, finger.historicalX, finger.historicalY, finger.timeSinceDown])); |
471 end; |
484 end; |
472 |
485 |
473 procedure initModule; |
486 procedure initModule; |
474 var |
487 var |
475 index, uRenderCoordScaleX, uRenderCoordScaleY: Longword; |
488 index: Longword; |
489 //uRenderCoordScaleX, uRenderCoordScaleY: Longword; |
|
476 begin |
490 begin |
477 movingCrosshair := false; |
491 movingCrosshair := false; |
478 stopFiring:= false; |
492 stopFiring:= false; |
479 walkingLeft := false; |
493 walkingLeft := false; |
480 walkingRight := false; |
494 walkingRight := false; |
486 setLength(fingers, 4); |
500 setLength(fingers, 4); |
487 for index := 0 to High(fingers) do |
501 for index := 0 to High(fingers) do |
488 fingers[index].id := nilFingerId; |
502 fingers[index].id := nilFingerId; |
489 |
503 |
490 |
504 |
491 uRenderCoordScaleX := Round(cScreenWidth/0.8 * 2); |
505 //uRenderCoordScaleX := Round(cScreenWidth/0.8 * 2); |
492 fireButtonLeft := Round(cScreenWidth*0.01); |
506 fireButtonLeft := Round(cScreenWidth*0.01); |
493 fireButtonRight := Round(fireButtonLeft + (spritesData[sprFireButton].Width*0.4)); |
507 fireButtonRight := Round(fireButtonLeft + (spritesData[sprFireButton].Width*0.4)); |
494 fireButtonBottom := Round(cScreenHeight*0.99); |
508 fireButtonBottom := Round(cScreenHeight*0.99); |
495 fireButtonTop := fireButtonBottom - Round(spritesData[sprFireButton].Height*0.4); |
509 fireButtonTop := fireButtonBottom - Round(spritesData[sprFireButton].Height*0.4); |
496 end; |
510 end; |