revo-jailbreak/objects/environment/rock/rock.gd
Hazel Snider a2974d8dd3 the damage system refactor!
killing is now done based on groups, the same way enemies already killed
the player.

these groups go on the entity's hitbox, not the entity itself.
enemies' hitboxes have all been put in "enemy_hitbox"

the arrow_projectile has a variable for the target group, so it could
easily be simply set to "player" for arrows shot by enemies

blocking is also done with groups. any hitbox with "blocks_arrow"
will block arrows, same with "blocks_sword" and "blocks_squash"
2023-01-20 00:06:34 -05:00

23 lines
581 B
GDScript

extends KinematicBody2D
var velocity = Vector2.ZERO
onready var bottom = $Bottom
func _physics_process(delta):
if !is_on_floor():
#Gravity
velocity.y = 100
velocity.x = 0
else:
velocity.y = 0
move_and_slide(velocity,Vector2.UP)
velocity.x = 0
func push(direction):
velocity -= direction * 32
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"):
var enemy = area.get_parent()
if enemy.global_position.y > global_position.y && velocity.y > 0:
enemy.die()