forked from team-sg/hero-mark-2
sg pushin' shovin' squishin' some snails n' skeles with rocks
This commit is contained in:
parent
56fb173a24
commit
3ba9afd2be
4 changed files with 117 additions and 17 deletions
|
@ -1,23 +1,23 @@
|
|||
extends KinematicBody2D
|
||||
var velocity = Vector2.ZERO
|
||||
onready var bottom = $Bottom
|
||||
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
|
||||
func _physics_process(delta):
|
||||
if !is_on_floor():
|
||||
if not is_on_floor():
|
||||
#Gravity
|
||||
velocity.y = 100
|
||||
velocity.x = 0
|
||||
velocity.y = 100.0
|
||||
velocity.x = 0.0
|
||||
else:
|
||||
velocity.y = 0
|
||||
velocity.y = 0.0
|
||||
move_and_slide(velocity,Vector2.UP)
|
||||
velocity.x = 0
|
||||
velocity.x = 0.0
|
||||
|
||||
func push(direction):
|
||||
velocity -= direction * 32
|
||||
func push(amount: float):
|
||||
velocity.x = amount
|
||||
|
||||
func _on_Hitbox_area_entered(area):
|
||||
# do not squish if in "blocks_squash" group
|
||||
if area.is_in_group("enemy_hitbox") && !area.is_in_group("blocks_squash"):
|
||||
if area.is_in_group("enemy_hitbox") and not area.is_in_group("blocks_squash"):
|
||||
var enemy = area.get_parent()
|
||||
if enemy.global_position.y > global_position.y && velocity.y > 0:
|
||||
if enemy.global_position.y > global_position.y and velocity.y > 0:
|
||||
enemy.die()
|
||||
|
|
|
@ -10,7 +10,7 @@ shader_param/border_color = Color( 0, 0, 0, 1 )
|
|||
shader_param/border_corners = false
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 3.7, 4 )
|
||||
extents = Vector2( 3.75, 4 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 4, 4 )
|
||||
|
@ -37,7 +37,4 @@ collision_layer = 5
|
|||
position = Vector2( 5, 4 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Bottom" type="Position2D" parent="."]
|
||||
position = Vector2( 4, 8 )
|
||||
|
||||
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue