forked from team-sg/hero-mark-2
enemies can be squashed by rocks
This commit is contained in:
parent
20fa885736
commit
4790b2b2a4
9 changed files with 34 additions and 26 deletions
|
@ -1,6 +1,7 @@
|
|||
extends Node2D
|
||||
|
||||
export var can_be_killed_by_sword = true
|
||||
export var can_be_squashed = true
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
#Kill player
|
||||
|
@ -10,4 +11,8 @@ func _on_Area2D_area_entered(area):
|
|||
if area.is_in_group("sword"):
|
||||
if can_be_killed_by_sword:
|
||||
queue_free()
|
||||
|
||||
#Die from rock/ get squashed
|
||||
if area.is_in_group("squash"):
|
||||
var squasher = area.get_parent()
|
||||
if squasher.position.y + squasher.bottom.position.y < global_position.y:
|
||||
queue_free()
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
extends "res://objects/enemy/enemy.gd"
|
||||
|
||||
func _process(delta):
|
||||
scale.x = -1
|
|
@ -3,7 +3,7 @@
|
|||
[ext_resource path="res://graphics/enemy/slime.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/recolor_border.shader" type="Shader" id=2]
|
||||
[ext_resource path="res://graphics/enemy/slime_purple.png" type="Texture" id=3]
|
||||
[ext_resource path="res://objects/enemy/enemy_stationary.gd" type="Script" id=4]
|
||||
[ext_resource path="res://objects/enemy/enemy.gd" type="Script" id=4]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 2 )
|
||||
|
@ -35,15 +35,14 @@ script = ExtResource( 4 )
|
|||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
position = Vector2( 5, -5 )
|
||||
position = Vector2( 5, 3 )
|
||||
frames = SubResource( 4 )
|
||||
playing = true
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 4.5, -4.5 )
|
||||
position = Vector2( 4.5, 3.5 )
|
||||
shape = SubResource( 5 )
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
extends KinematicBody2D
|
||||
var velocity = Vector2.ZERO
|
||||
onready var bottom = $Bottom
|
||||
|
||||
func _physics_process(delta):
|
||||
if !is_on_floor():
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/rock/rock.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=2]
|
||||
|
@ -12,6 +12,9 @@ shader_param/border_corners = false
|
|||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 5, 4.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 5, 4.5 )
|
||||
|
||||
[node name="Rock" type="KinematicBody2D" groups=["pushable"]]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
|
@ -24,3 +27,12 @@ centered = false
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 5, 3.5 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["squash"]]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 5, 3.5 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Bottom" type="Position2D" parent="."]
|
||||
position = Vector2( 5, 8 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue