Implemented win/lose scenes and added fire spinner trap
This commit is contained in:
55
Levels/Traps/Fire Spinner.gd
Normal file
55
Levels/Traps/Fire Spinner.gd
Normal file
@@ -0,0 +1,55 @@
|
||||
extends StaticBody2D
|
||||
|
||||
export var glowing_fireball: PackedScene
|
||||
|
||||
var player: KinematicBody2D = null
|
||||
var center: Vector2
|
||||
var shoot_directions: Array
|
||||
var rotated_shoot_directions: Array
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
center = $Sprite.global_position
|
||||
shoot_directions = [
|
||||
Vector2(center.x - 1, center.y),
|
||||
Vector2(center.x + 1, center.y),
|
||||
Vector2(center.x, center.y - 1),
|
||||
Vector2(center.x, center.y + 1)]
|
||||
rotated_shoot_directions = [
|
||||
Vector2(center.x - 1, center.y - 1),
|
||||
Vector2(center.x + 1, center.y + 1),
|
||||
Vector2(center.x + 1, center.y - 1),
|
||||
Vector2(center.x - 1, center.y + 1)]
|
||||
return
|
||||
|
||||
|
||||
func _on_spinner_timeout():
|
||||
$Sprite.set_rotation_degrees($Sprite.get_rotation_degrees() + 45)
|
||||
return
|
||||
|
||||
|
||||
func _on_shoot_timeout():
|
||||
if player:
|
||||
var shoot_array: Array
|
||||
if int($Sprite.get_rotation_degrees()) % 90 == 0:
|
||||
shoot_array = shoot_directions
|
||||
else:
|
||||
shoot_array = rotated_shoot_directions
|
||||
|
||||
for itr in shoot_array:
|
||||
var projectile: Node = glowing_fireball.instance()
|
||||
projectile.init(center, itr)
|
||||
get_tree().get_current_scene().get_node('Projectiles').add_child(projectile)
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_exited(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
return
|
59
Levels/Traps/Fire Spinner.tscn
Normal file
59
Levels/Traps/Fire Spinner.tscn
Normal file
@@ -0,0 +1,59 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/Levels/Objects/Fire_Spinner.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Levels/Traps/Fire Spinner.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Enemies/Projectiles/Glowing Fireball.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://Sprites/Assets/Light.png" type="Texture" id=4]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 9.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
radius = 80.0
|
||||
|
||||
[node name="Fire Spinner" type="StaticBody2D"]
|
||||
light_mask = 0
|
||||
collision_mask = 0
|
||||
script = ExtResource( 2 )
|
||||
glowing_fireball = ExtResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="Collision" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
light_mask = 0
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Player Detector" type="Area2D" parent="."]
|
||||
light_mask = 0
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
input_pickable = false
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player Detector"]
|
||||
visible = false
|
||||
light_mask = 0
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Light2D" type="Light2D" parent="."]
|
||||
light_mask = 15
|
||||
texture = ExtResource( 4 )
|
||||
texture_scale = 0.3
|
||||
color = Color( 1, 0.164706, 0, 1 )
|
||||
energy = 1.5
|
||||
shadow_item_cull_mask = 0
|
||||
|
||||
[node name="Spinner" type="Timer" parent="."]
|
||||
wait_time = 2.0
|
||||
autostart = true
|
||||
|
||||
[node name="Shoot" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
autostart = true
|
||||
|
||||
[connection signal="body_entered" from="Player Detector" to="." method="_on_player_detector_body_entered"]
|
||||
[connection signal="body_exited" from="Player Detector" to="." method="_on_player_detector_body_exited"]
|
||||
[connection signal="timeout" from="Spinner" to="." method="_on_spinner_timeout"]
|
||||
[connection signal="timeout" from="Shoot" to="." method="_on_shoot_timeout"]
|
Reference in New Issue
Block a user