diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-05-03 09:32:22 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-05-03 09:32:22 +0200 |
commit | 516d22c1737a9c94026b5ff0c9856bc5549aa416 (patch) | |
tree | cd9ef3089d1c8bdfc440b5673f7ad0d0dce787a9 /Scenes/Entities/Bombs | |
parent | d192b1546ab39180cdc28d2621c117539e3d26d6 (diff) |
update
Diffstat (limited to 'Scenes/Entities/Bombs')
-rw-r--r-- | Scenes/Entities/Bombs/Bomb.gd | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Scenes/Entities/Bombs/Bomb.gd b/Scenes/Entities/Bombs/Bomb.gd index 4256fc5..97fbf4f 100644 --- a/Scenes/Entities/Bombs/Bomb.gd +++ b/Scenes/Entities/Bombs/Bomb.gd @@ -16,7 +16,7 @@ enum COMPONENT_TYPE { } -var Explosion = preload("res://Scenes/Entities/Bombs/Explosion.tscn") +var ExplosionScene = preload("res://Scenes/Entities/Bombs/Explosion.tscn") var power: int = 2 var components: Array[COMPONENT_TYPE] = [] @@ -60,17 +60,21 @@ func explode(): var direction = directions[j] for i in range(self.get_power()): + var from = Utilities.from_grid_to_position( + Utilities.from_position_to_grid(self.global_position) + (direction * i) + ) var to = Utilities.from_grid_to_position( Utilities.from_position_to_grid(self.global_position) + (direction * (i + 1)) ) - var query = PhysicsPointQueryParameters2D.new() - query.set_position(to) + var query = PhysicsRayQueryParameters2D.new() + query.set_from(from) + query.set_to(to) query.set_collision_mask(explosion.collision_mask) - var explosion_intersection = get_world_2d().direct_space_state.intersect_point(query) + var explosion_intersection = get_world_2d().direct_space_state.intersect_ray(query) if explosion_intersection: - var collider = explosion_intersection[0].collider + var collider = explosion_intersection.collider # call collision function and get collision type var collision_type @@ -120,7 +124,7 @@ func get_power(): func spawn_explosion(spawn_position: Vector2): - var explosion = Explosion.instantiate() + var explosion = ExplosionScene.instantiate() explosion.position = spawn_position get_tree().get_current_scene().add_child(explosion) |