improved grenade collisions

This commit is contained in:
torontocaper committed 2025-10-26 13:42:53 -04:00
1 parent 1c2cb39425
commit 40d8f909e8
9 files changed
+236 -22

No files matched your search

+3
View File
@@ -15,12 +15,15 @@ func _ready() -> void:
func explode() -> void:
print("kaboom!")
set_deferred("freeze", true)
sprite_2d.visible = false
animated_sprite_2d.play("explode")
await animated_sprite_2d.animation_finished
self.queue_free()
func _on_body_entered(body: Node) -> void:
if body is Player:
print("grenade hit player")
print("grenade hit something")
if body.is_in_group("explodable"):
body.queue_free()
+3 -3
View File
@@ -3,14 +3,14 @@ class_name Player extends CharacterBody2D
## TODO: fix bullet cooldown timer
const SPEED = 200.0
const JUMP_VELOCITY = -350.0
const JUMP_VELOCITY = -500.0
enum FaceDirection{LEFT, RIGHT}
enum State{IDLE, WALK, JUMP, FALLING, SHOOT_STILL, SHOOT_RUN}
@export var BUMP_POWER := 50
@export var SHOVE_POWER := 300
@export var ACCELERATION := 4
@export var ACCELERATION := 10 ## Amount of "slide-y-ness" in side-to-side-movement
@export var HARD_GRAVITY := 2
var current_state: State = State.IDLE
@@ -122,7 +122,7 @@ func handle_collisions() -> void:
for i in get_slide_collision_count():
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
if c.get_collider() is RigidBody2D and c.get_collider() is not Grenade:
c.get_collider().apply_central_impulse(-c.get_normal() * BUMP_POWER)
if right_cast.is_colliding() and facing == FaceDirection.RIGHT:
+6
View File
@@ -31,3 +31,9 @@ func bullet_factory() -> Bullet:
my_bullet = bullet_array.pop_back()
bullet_array.push_front(my_bullet)
return my_bullet
func _on_world_boundary_body_entered(body: Node2D) -> void:
if body is Player:
var current_scene = get_tree()
current_scene.call_deferred("reload_current_scene")