Guest User

Untitled

a guest
Nov 4th, 2018
6,240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. extends KinematicBody2D
  2.  
  3. const MOVE_SPEED = 300
  4.  
  5. onready var raycast = $RayCast2D
  6.  
  7. func _ready():
  8. yield(get_tree(), "idle_frame")
  9. get_tree().call_group("zombies", "set_player", self)
  10.  
  11. func _physics_process(delta):
  12. var move_vec = Vector2()
  13. if Input.is_action_pressed("move_up"):
  14. move_vec.y -= 1
  15. if Input.is_action_pressed("move_down"):
  16. move_vec.y += 1
  17. if Input.is_action_pressed("move_left"):
  18. move_vec.x -= 1
  19. if Input.is_action_pressed("move_right"):
  20. move_vec.x += 1
  21. move_vec = move_vec.normalized()
  22. move_and_collide(move_vec * MOVE_SPEED * delta)
  23.  
  24. var look_vec = get_global_mouse_position() - global_position
  25. global_rotation = atan2(look_vec.y, look_vec.x)
  26.  
  27. if Input.is_action_just_pressed("shoot"):
  28. var coll = raycast.get_collider()
  29. if raycast.is_colliding() and coll.has_method("kill"):
  30. coll.kill()
  31.  
  32. func kill():
  33. get_tree().reload_current_scene()
Add Comment
Please, Sign In to add comment