Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.30 KB | None | 0 0
  1. extends RigidBody
  2.  
  3. # controls
  4. var go_right
  5. var go_left
  6. var go_up
  7. var go_down
  8. var go_backward
  9.  
  10. var delay_start = .42
  11. var speed = 80
  12. var force = Vector3(0,0,-1)
  13. var tail
  14. var x_axis_count = 0
  15. var up_axis_count = 0
  16. var down_axis_count = 0
  17.  
  18. var up_locked = false
  19. var down_locked = false
  20. # Set at the beginning in order to make the snake automatically start moving forward
  21. var go_forward = true
  22. var array = []
  23. var right
  24. var right_prev = false
  25.  
  26. func _input(ev):
  27. #   set_rotation(Vector3(.05, 0, 0))
  28. #   right = ev.is_action("ui_right")
  29.  
  30. #   right_prev = right
  31. #       print(str(rad2deg(get_rotation().y)) + "  " + str(deg2rad(90)) )
  32. #       set_rotation(Vector3(0,1,0))
  33. #       go_right = true
  34. #       go_left = false
  35. #       go_up = false
  36. #       go_down = false
  37. #       go_forward = false
  38. #       up_locked = false
  39. #       down_locked = false
  40. #       x_axis_count += 1
  41.  
  42.     if (Input.is_action_pressed("ui_left")):
  43.         go_right = false
  44.         go_left = true
  45.         go_up = false
  46.         go_down = false
  47.         go_forward = false
  48.         up_locked = false
  49.         down_locked = false
  50.         x_axis_count += -1
  51.     if (Input.is_action_pressed("ui_down") and up_locked == false):
  52.         go_up = false
  53.         go_down = true
  54.         down_locked = true
  55.  
  56.         up_axis_count = 0
  57.         down_axis_count += 1
  58.     if (Input.is_action_pressed("ui_up") and down_locked == false):
  59.         go_up = true
  60.         go_down = false
  61.         up_locked = true
  62.         up_axis_count += 1
  63.         down_axis_count = 0
  64.    
  65. func _fixed_process(delta):
  66. #   print(get_rotation().y)
  67.     right = Input.is_action_pressed("ui_right")
  68.     if (right and not right_prev):
  69.         rotate_y(PI/2)
  70.     right_prev = right
  71.    
  72.    
  73.     set_linear_velocity(force*speed*delta)
  74. #   array.push_back(get_global_transform())
  75. #   if delay_start < 0:
  76. #       get_node("Tail").set_global_transform(array[0])
  77. #       array.remove(0)
  78. #
  79. #   delay_start += -delta
  80. #   if(!(go_up or go_down)):
  81. #       if(go_right == true):
  82. #           if(x_axis_count == 1):
  83. #               set_rotation(Vector3(0, -1.571, 0))
  84. #               move_snake(speed, 0, 0)
  85. #           elif(x_axis_count == 2):
  86. #               set_rotation(Vector3(0, 3.142, 0))
  87. #               move_snake(0, 0, speed)
  88. #           elif(x_axis_count == 3):
  89. #               set_rotation(Vector3(0, 1.571, 0))
  90. #               move_snake(-speed, 0, 0)
  91. #           elif(x_axis_count == 4):
  92. #               move_snake(0, 0, -speed)
  93. #           else:
  94. #               x_axis_count = 1
  95. #          
  96. #       elif(go_left == true):
  97. #           if(x_axis_count == 1):
  98. #               set_rotation(Vector3(0, -1.571, 0))
  99. #               move_snake(speed, 0, 0)
  100. #           elif(x_axis_count == 2):
  101. #               set_rotation(Vector3(0, 3.142, 0))
  102. #               move_snake(0, 0, speed)
  103. #           elif(x_axis_count == 3):
  104. #               set_rotation(Vector3(0, 1.571, 0))
  105. #               move_snake(-speed, 0, 0)
  106. #           elif(x_axis_count == 4):
  107. #               move_snake(0, 0, -speed)
  108. #           else:
  109. #               x_axis_count = 4
  110. #   elif (go_up == true):
  111. #       set_rotation(Vector3(1.571, 0, 0))
  112. #       move_snake(0, speed, 0)
  113. #       if(up_axis_count > 1):
  114. #           go_up = false
  115. #           up_axis_count = 0
  116. #           up_locked = false
  117. #
  118. #   elif(go_down == true):
  119. #       set_rotation(Vector3(-1.571, 0, 0))
  120. #       move_snake(0, -speed, 0)
  121. #       if(down_axis_count > 1):
  122. #           go_down = false
  123. #           down_axis_count = 0
  124. #           down_locked = false
  125. #   if((go_forward == true) and !(go_down or go_up)):
  126. #       move_snake(0, 0, -speed)
  127. #
  128. #
  129. #
  130. #func move_snake(variable_z, variable_y, variable_x):
  131. #   move( Vector3( variable_z, variable_y, variable_x))
  132. #  
  133.  
  134. func _ready():
  135.     # Initialization here
  136. #   set_collide_with_rigid_bodies(true)
  137.     set_fixed_process(true)
  138.     set_process_input(true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement