sg pushin' shovin' squishin' some snails n' skeles with rocks

This commit is contained in:
Haze Weathers 2023-05-10 18:25:26 -04:00
parent 56fb173a24
commit 3ba9afd2be
4 changed files with 117 additions and 17 deletions

View file

@ -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()