Guest User

Untitled

a guest
Feb 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. public function onDrag(position:int):void
  2. {
  3. if (position < 1 || position > 14) // There is no land here
  4. return;
  5.  
  6. if (landscapeHeight[position] < (dragStartY - FlxG.mouse.y))
  7. {
  8. if (position != 1)
  9. landscapeHeight[position - 1] += Math.random() * 0.7;
  10. landscapeHeight[position] += 1.0;
  11. if (position != 14)
  12. landscapeHeight[position + 1] += Math.random() * 0.7;
  13. }
  14. if ((129 - landscapeHeight[position]) < FlxG.mouse.y)
  15. {
  16. if (position != 1)
  17. {
  18. landscapeHeight[position - 1] -= Math.random() * 0.7;
  19. if (landscapeHeight[position - 1] < 0)
  20. landscapeHeight[position - 1] = 0;
  21. }
  22.  
  23. landscapeHeight[position] -= 1.0;
  24. if (landscapeHeight[position] < 0)
  25. landscapeHeight[position] = 0;
  26.  
  27. if (position != 14)
  28. {
  29. landscapeHeight[position + 1] -= Math.random() * 0.7;
  30. if (landscapeHeight[position + 1] < 0)
  31. landscapeHeight[position + 1] = 0;
  32. }
  33. }
  34.  
  35. redraw();
  36. }
Add Comment
Please, Sign In to add comment