Fixed spacing, fixed enemy hitbox
This commit is contained in:
@@ -7,12 +7,12 @@ var speed = 3
|
|||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
||||||
look_vec = player.position - global_position
|
look_vec = player.position - global_position
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
move = Vector2.ZERO
|
move = Vector2.ZERO
|
||||||
move = move.move_toward(look_vec, delta)
|
move = move.move_toward(look_vec, delta)
|
||||||
move = move.normalized() * speed
|
move = move.normalized() * speed
|
||||||
position += move
|
position += move
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,8 +6,11 @@
|
|||||||
[sub_resource type="CircleShape2D" id=1]
|
[sub_resource type="CircleShape2D" id=1]
|
||||||
radius = 4.47823
|
radius = 4.47823
|
||||||
|
|
||||||
[node name="snowball_blue" type="Area2D" groups=["damage"]]
|
[node name="snowball_blue" type="Area2D" groups=[
|
||||||
collision_layer = 2
|
"enemy_projectile_1",
|
||||||
|
]]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 2
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
@@ -1,15 +1,19 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Sprites/Enemies/blue_snowman.png" type="Texture" id=1]
|
[ext_resource path="res://Sprites/Enemies/blue_snowman.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://Enemies/Snowman Enemy.gd" type="Script" id=2]
|
[ext_resource path="res://Enemies/Snowman Enemy.gd" type="Script" id=2]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=1]
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
radius = 6.0
|
radius = 1.5
|
||||||
height = 5.0
|
height = 3.0
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id=2]
|
[sub_resource type="CircleShape2D" id=2]
|
||||||
radius = 58.0175
|
radius = 58.0175
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape2D" id=3]
|
||||||
|
radius = 6.0
|
||||||
|
height = 5.0
|
||||||
|
|
||||||
[node name="snowmen_enemy" type="KinematicBody2D"]
|
[node name="snowmen_enemy" type="KinematicBody2D"]
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
@@ -17,8 +21,10 @@ script = ExtResource( 2 )
|
|||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2( 0.556812, 0.44545 )
|
light_mask = 0
|
||||||
|
position = Vector2( 0.618717, 6.27557 )
|
||||||
|
rotation = 1.5708
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
[node name="detection" type="Area2D" parent="."]
|
[node name="detection" type="Area2D" parent="."]
|
||||||
@@ -31,6 +37,16 @@ shape = SubResource( 2 )
|
|||||||
[node name="Timer" type="Timer" parent="."]
|
[node name="Timer" type="Timer" parent="."]
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
|
[node name="hitbox" type="Area2D" parent="." groups=[
|
||||||
|
"enemy_hitbox_1",
|
||||||
|
]]
|
||||||
|
visible = false
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="hitbox"]
|
||||||
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
[connection signal="body_entered" from="detection" to="." method="_on_Area2D_body_entered"]
|
[connection signal="body_entered" from="detection" to="." method="_on_Area2D_body_entered"]
|
||||||
[connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"]
|
[connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"]
|
||||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||||
|
@@ -1,15 +1,19 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Sprites/Enemies/pink_snowman.png" type="Texture" id=1]
|
[ext_resource path="res://Sprites/Enemies/pink_snowman.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://Enemies/Snowman Enemy.gd" type="Script" id=2]
|
[ext_resource path="res://Enemies/Snowman Enemy.gd" type="Script" id=2]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=1]
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
radius = 6.0
|
radius = 1.5
|
||||||
height = 5.0
|
height = 3.0
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id=2]
|
[sub_resource type="CircleShape2D" id=2]
|
||||||
radius = 56.0659
|
radius = 56.0659
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape2D" id=3]
|
||||||
|
radius = 6.0
|
||||||
|
height = 5.0
|
||||||
|
|
||||||
[node name="snowmen_enemy" type="KinematicBody2D"]
|
[node name="snowmen_enemy" type="KinematicBody2D"]
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
@@ -17,19 +21,34 @@ script = ExtResource( 2 )
|
|||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||||
|
light_mask = 0
|
||||||
|
position = Vector2( 0.618717, 6.27557 )
|
||||||
|
rotation = 1.5708
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
[node name="detection" type="Area2D" parent="."]
|
[node name="detection" type="Area2D" parent="."]
|
||||||
|
visible = false
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
|
|
||||||
[node name="detection" type="CollisionShape2D" parent="detection"]
|
[node name="detection" type="CollisionShape2D" parent="detection"]
|
||||||
|
visible = false
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="."]
|
[node name="Timer" type="Timer" parent="."]
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
|
[node name="hitbox" type="Area2D" parent="." groups=[
|
||||||
|
"enemy_hitbox_1",
|
||||||
|
]]
|
||||||
|
visible = false
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="hitbox"]
|
||||||
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
[connection signal="body_entered" from="detection" to="." method="_on_Area2D_body_entered"]
|
[connection signal="body_entered" from="detection" to="." method="_on_Area2D_body_entered"]
|
||||||
[connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"]
|
[connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"]
|
||||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||||
|
@@ -6,10 +6,12 @@
|
|||||||
[sub_resource type="CircleShape2D" id=1]
|
[sub_resource type="CircleShape2D" id=1]
|
||||||
radius = 4.47823
|
radius = 4.47823
|
||||||
|
|
||||||
[node name="snowball" type="Area2D" groups=["damage"]]
|
[node name="snowball" type="Area2D" groups=[
|
||||||
collision_layer = 2
|
"enemy_projectile_1",
|
||||||
collision_mask = 0
|
]]
|
||||||
monitoring = false
|
monitoring = false
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 2
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
@@ -2,5 +2,5 @@ extends Node2D
|
|||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$YSort/Player.load_hud($HUD)
|
$YSort/Player.load_hud($HUD)
|
||||||
return
|
return
|
||||||
|
@@ -4,7 +4,7 @@ signal coin_grabbed
|
|||||||
|
|
||||||
|
|
||||||
func _on_Node2D_body_entered(body: Node) -> void:
|
func _on_Node2D_body_entered(body: Node) -> void:
|
||||||
if body.get_name() == 'Player':
|
if body.get_name() == 'Player':
|
||||||
emit_signal("coin_grabbed")
|
emit_signal("coin_grabbed")
|
||||||
print("coin!")
|
print("coin!")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
@@ -10,20 +10,20 @@ var screensize
|
|||||||
var score = 0
|
var score = 0
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$YSort/Player.load_hud($HUD)
|
$YSort/Player.load_hud($HUD)
|
||||||
screensize = get_viewport_rect().size
|
screensize = get_viewport_rect().size
|
||||||
spawn_coins(5)
|
spawn_coins(5)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func spawn_coins(num):
|
func spawn_coins(num):
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
var g = coin.instance()
|
var g = coin.instance()
|
||||||
$'coin_container'.add_child(g)
|
$'coin_container'.add_child(g)
|
||||||
g.connect("coin_grabbed", self, "_on_coin_grabbed")
|
g.connect("coin_grabbed", self, "_on_coin_grabbed")
|
||||||
#g.set_pos(Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40)))
|
#g.set_pos(Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40)))
|
||||||
g.position = Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40))
|
g.position = Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40))
|
||||||
|
|
||||||
func _on_coin_grabbed():
|
func _on_coin_grabbed():
|
||||||
score+=1
|
score+=1
|
||||||
print(score)
|
print(score)
|
||||||
|
@@ -109,10 +109,10 @@ func _on_hitbox_area_entered(area: Area2D) -> void:
|
|||||||
#var timer = Timer.new()
|
#var timer = Timer.new()
|
||||||
|
|
||||||
|
|
||||||
elif body.name.begins_with("blue_snowman"):
|
#if body.name.begins_with("blue_snowman"):
|
||||||
MAX_SPEED = 20
|
# MAX_SPEED = 20
|
||||||
yield(get_tree().create_timer(3.0), "timeout")
|
# yield(get_tree().create_timer(3.0), "timeout")
|
||||||
MAX_SPEED = 120
|
# MAX_SPEED = 120
|
||||||
|
|
||||||
if health_index != 0:
|
if health_index != 0:
|
||||||
health_index -= hit
|
health_index -= hit
|
||||||
|
@@ -57,6 +57,7 @@ screenshot={
|
|||||||
player_attack={
|
player_attack={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
|
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user