aboutsummaryrefslogtreecommitdiffstats
path: root/KinematicBody2D.gd
diff options
context:
space:
mode:
authorfreddie-a <57713959+freddie-a@users.noreply.github.com>2022-10-30 09:21:08 +0000
committerfreddie-a <57713959+freddie-a@users.noreply.github.com>2022-10-30 09:21:08 +0000
commitd532570052901e9e956fab4809228a6b742ee233 (patch)
tree6161dbaedf0ed172a3ceced9abce68c2f72f667c /KinematicBody2D.gd
parentf3ac42262d09514040a7c48a2fd320c23a16a950 (diff)
Rotate player to mouse and rename
Diffstat (limited to 'KinematicBody2D.gd')
-rw-r--r--KinematicBody2D.gd42
1 files changed, 0 insertions, 42 deletions
diff --git a/KinematicBody2D.gd b/KinematicBody2D.gd
deleted file mode 100644
index 22f7db1..0000000
--- a/KinematicBody2D.gd
+++ /dev/null
@@ -1,42 +0,0 @@
-extends Area2D
-
-signal hit
-signal coin
-var screen_size
-export (int) var speed = 500
-var spawn_object = load("res://Bullet.tscn")
-var velocity = Vector2()
-onready var globals = get_node("/root/Global")
-
-func get_input():
- velocity = Vector2()
- if Input.is_action_pressed("right"):
- velocity.x += 1
- if Input.is_action_pressed("left"):
- velocity.x -= 1
- if Input.is_action_pressed("down"):
- velocity.y += 1
- if Input.is_action_pressed("up"):
- velocity.y -= 1
- velocity = velocity.normalized() * speed
-
-func _ready():
- screen_size = get_viewport_rect().size
-
-func _physics_process(delta):
- get_input()
- globals.playerPos = global_position
- position += velocity * delta
- position.x = clamp(position.x, 0, screen_size.x)
- position.y = clamp(position.y, 0, screen_size.y)
- if Input.is_action_just_pressed("click"):
- var obj = spawn_object.instance()
- obj.position = get_position()
- get_parent().add_child(obj)
- var bodies = get_overlapping_bodies()
- for body in bodies:
- if "Coin" in body.get_name():
- emit_signal("coin")
- body.free()
- elif "Enemy" in body.get_name():
- emit_signal("hit", delta)