Advertisement
Huniverse

Untitled

Apr 19th, 2021
2,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends KinematicBody2D
  2.  
  3. export (int) var velocity = 0
  4. export (int) var velocity_sideways = 0
  5. export (float) var rotation_speed = 1.5
  6. var acceleration = 10
  7. var topspeed = 25
  8. var team = rand_range(0,1) # 1 = red  //  0 =blue
  9.  
  10. var now_position = Vector2()
  11. var rotation_dir = 0
  12.  
  13. var red_points = 0
  14. var blue_points = 0
  15. var personal_points = 0
  16.  
  17. var red_area1_points = 0
  18. var blue_area1_points = 0
  19. var area1_hp = 0 # 100 = blue // -100 = red // 99-(-99) = gray
  20.  
  21. var area_time_point_gain = 7.5
  22. var kill_point_gain = 100
  23. var assist_point_gain = (kill_point_gain * 0.5)
  24.  
  25. onready var timer = get_node("timer")
  26. var wait = 2
  27. var timeout = false
  28. var Hunor_zseni = true
  29.  
  30. var longness = 1
  31.  
  32. func get_input():
  33.     rotation_dir = 0
  34.     now_position = Vector2()
  35.     if Input.is_action_pressed("ui_right"):
  36.         rotation_dir += rotation_speed
  37.         if not Input.is_action_pressed("ui_right"):
  38.             wait = 0.5
  39.             timer.start()
  40.             if (timeout == true):
  41.                 timeout = false
  42.                 if Input.is_action_pressed("ui_right"):
  43.                     for i in range(500):
  44.                         if (longness < 0.25):
  45.                             rotation_dir += 90
  46.                             velocity_sideways += (acceleration * longness)
  47.                             longness -= (longness * 0.9)
  48.                             rotation_dir -= 90
  49.                             pass
  50.                 if Input.is_action_pressed("ui_left"):
  51.                     timer.start()
  52.                     if (timeout == true):
  53.                         timeout = false
  54.                         if Input.is_action_pressed("ui_right"):
  55.                             pass
  56.     if Input.is_action_pressed("ui_left"):
  57.         rotation_dir -= rotation_speed
  58.         if not Input.is_action_pressed("ui_left"):
  59.             wait = 0.5
  60.             timer.start()
  61.             if (timeout == true):
  62.                 timeout = false
  63.                 if Input.is_action_pressed("ui_left"):
  64.                     for i in range(500):
  65.                         if (longness < 0.25):
  66.                             rotation_dir -= 90
  67.                             velocity_sideways += (acceleration * longness)
  68.                             longness -= (longness * 0.9)
  69.                             rotation_dir += 90
  70.                             pass
  71.                 if Input.is_action_pressed("ui_right"):
  72.                     timer.start()
  73.                     if (timeout == true):
  74.                         timeout = false
  75.                         if Input.is_action_pressed("ui_left"):
  76.                             pass
  77.  
  78.     if Input.is_action_pressed("ui_down"):
  79.         if (velocity == -topspeed):
  80.             return
  81.         velocity -= (acceleration/1.5)
  82.      
  83.     if Input.is_action_pressed("ui_up"):
  84.         if (velocity == topspeed):
  85.             return
  86.         velocity += acceleration
  87.  
  88.  
  89.  
  90.     now_position = Vector2( velocity , velocity_sideways ).rotated(rotation)
  91.  
  92.  
  93.  
  94. func _physics_process(delta):
  95.     get_input()
  96.     rotation += (rotation_dir * rotation_speed * delta)
  97.     move_and_slide(now_position)
  98.     if (velocity != 0):
  99.         if (velocity < 0):
  100.             velocity += (acceleration/5)
  101.         if (velocity > 0):
  102.             velocity -= (acceleration/5)
  103.     if _on_Area2D_area_entered(Area2D):
  104.         area1_hp = (blue_area1_points - red_area1_points)
  105.         if (team == 0):
  106.             if (blue_area1_points < 100):
  107.                 wait = 0.1
  108.                 timer.start()
  109.                 if (timeout == true):
  110.                     blue_area1_points += 1
  111.                     blue_points += 0.1
  112.                     personal_points += area_time_point_gain
  113.                     return
  114.             if (team == 1):
  115.                 if (red_area1_points < 100):
  116.                     wait = 0.1
  117.                     timer.start()
  118.                     if (timeout == true):
  119.                         red_area1_points += 1
  120.                         red_points += 0.1
  121.                         personal_points += area_time_point_gain
  122.                         return
  123.  
  124. func _on_Timer_timeout():
  125.     timer = true
  126.  
  127. func _ready():
  128.     timer.set_wait_time(wait)
  129.     timer.start
  130.  
  131. func _on_Area2D_area_entered(area):
  132.     pass
  133.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement