Skip to content

Commit

Permalink
Laser Boxes (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
Woahsea authored Apr 1, 2023
1 parent 8e6ffce commit cc298b2
Show file tree
Hide file tree
Showing 17 changed files with 545 additions and 69 deletions.
160 changes: 91 additions & 69 deletions scenes/levels/Stardepths/0_stardepths_test.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=2]
[gd_scene load_steps=19 format=2]

[ext_resource path="res://scripts/resources/stardepths_tileset.tres" type="TileSet" id=1]
[ext_resource path="res://scenes/SpawnPoint.tscn" type="PackedScene" id=2]
Expand All @@ -14,6 +14,7 @@
[ext_resource path="res://scenes/objects/LimitSetArea.tscn" type="PackedScene" id=12]
[ext_resource path="res://scenes/enemies/Ombsti.tscn" type="PackedScene" id=13]
[ext_resource path="res://scenes/enemies/OmbstiEcho.tscn" type="PackedScene" id=14]
[ext_resource path="res://scenes/objects/LaserBox.tscn" type="PackedScene" id=15]

[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 13, 128 )
Expand All @@ -35,6 +36,80 @@ __meta__ = {
"_edit_lock_": true
}

[node name="Decorations" type="Node" parent="."]

[node name="BasicDecoration" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1168, -288 )
frame = 0

[node name="BasicDecoration6" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1392, -384 )
frame = 4

[node name="BasicDecoration8" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1872, -352 )
animation = "rainbow"
frame = 0

[node name="BasicDecoration9" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1152, -224 )
animation = "rainbow"
frame = 0

[node name="BasicDecoration10" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 640, 352 )
animation = "rainbow_stack"
frame = 0

[node name="BasicDecoration12" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 104, 8 )
animation = "float_star"
frame = 3

[node name="BasicDecoration13" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 784, 112 )
animation = "float_star"
frame = 3

[node name="BasicDecoration14" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 2648, -448 )
animation = "float_star"
frame = 3

[node name="BasicDecoration15" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 752, -352 )
animation = "float_star"
frame = 3

[node name="BasicDecoration11" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 2320, -352 )
animation = "rainbow_stack"
frame = 0

[node name="BasicDecoration7" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1120, -416 )
frame = 3

[node name="BasicDecoration2" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1328, -224 )
animation = "star_tree_t"
frame = 0

[node name="BasicDecoration3" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1728, -352 )
animation = "star_tree_s"
frame = 0

[node name="BasicDecoration4" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1792, -352 )
animation = "star_tree_2b"
frame = 0

[node name="BasicDecoration5" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 2064, -352 )
animation = "star_tree_2a"
frame = 0

[node name="Camera" type="Node" parent="."]

[node name="CameraFollow" parent="Camera" instance=ExtResource( 3 )]
Expand Down Expand Up @@ -146,74 +221,21 @@ position = Vector2( 312, 0 )
[node name="HealPoint" parent="Objects" instance=ExtResource( 8 )]
position = Vector2( 2496, -352 )

[node name="Decorations" type="Node" parent="."]

[node name="BasicDecoration" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1168, -288 )

[node name="BasicDecoration6" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1392, -384 )
frame = 0

[node name="BasicDecoration8" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1872, -352 )
animation = "rainbow"
frame = 0

[node name="BasicDecoration9" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1152, -224 )
animation = "rainbow"
frame = 0

[node name="BasicDecoration10" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 560, 352 )
animation = "rainbow_stack"
frame = 0

[node name="BasicDecoration12" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 104, 8 )
animation = "float_star"

[node name="BasicDecoration13" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 784, 112 )
animation = "float_star"

[node name="BasicDecoration14" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 2648, -448 )
animation = "float_star"

[node name="BasicDecoration15" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 752, -352 )
animation = "float_star"

[node name="BasicDecoration11" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 2320, -352 )
animation = "rainbow_stack"
frame = 0

[node name="BasicDecoration7" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1120, -416 )
frame = 4

[node name="BasicDecoration2" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1328, -224 )
animation = "star_tree_t"
frame = 0

[node name="BasicDecoration3" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1728, -352 )
animation = "star_tree_s"
frame = 0

[node name="BasicDecoration4" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 1792, -352 )
animation = "star_tree_2b"
frame = 0

[node name="BasicDecoration5" parent="Decorations" instance=ExtResource( 5 )]
position = Vector2( 2064, -352 )
animation = "star_tree_2a"
frame = 0
[node name="LaserBox" parent="Objects" instance=ExtResource( 15 )]
position = Vector2( 512, 384 )
enableBottom = false
enableLeft = false
deactivate = 30
loop = 120

[node name="LaserBox2" parent="Objects" instance=ExtResource( 15 )]
position = Vector2( 1504, -192 )
enableTop = false
enableRight = false
enableBottom = false
activate = 60
deactivate = 90
loop = 120

[editable path="Camera/LimitSetArea"]
[editable path="Camera/LimitSetArea2"]
Expand Down
40 changes: 40 additions & 0 deletions scenes/objects/LaserBox.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[gd_scene load_steps=5 format=2]

[ext_resource path="res://sprites/objects/LaserBox.png" type="Texture" id=1]
[ext_resource path="res://scenes/objects/LaserBoxPart.tscn" type="PackedScene" id=2]
[ext_resource path="res://scripts/objects/LaserBox.gd" type="Script" id=3]

[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 32, 32 )

[node name="LaserBox" type="StaticBody2D"]
collision_layer = 2
collision_mask = 0
script = ExtResource( 3 )
enableTop = true
enableRight = true
enableBottom = true
enableLeft = true
deactivate = 20

[node name="Sprite" type="Sprite" parent="."]
scale = Vector2( 2, 2 )
texture = ExtResource( 1 )

[node name="Collision" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )

[node name="TopPart" parent="." instance=ExtResource( 2 )]
position = Vector2( 0, -30 )
rotation = -1.5708

[node name="RightPart" parent="." instance=ExtResource( 2 )]
position = Vector2( 30, 1 )

[node name="BottomPart" parent="." instance=ExtResource( 2 )]
position = Vector2( 0, 30 )
rotation = 1.5708

[node name="LeftPart" parent="." instance=ExtResource( 2 )]
position = Vector2( -30, 0 )
rotation = -3.14159
61 changes: 61 additions & 0 deletions scenes/objects/LaserBoxPart.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[gd_scene load_steps=10 format=2]

[ext_resource path="res://sprites/objects/LaserBoxPart.png" type="Texture" id=1]
[ext_resource path="res://scripts/objects/LaserBoxPart.gd" type="Script" id=2]
[ext_resource path="res://scripts/enemies/SetDamage.gd" type="Script" id=3]
[ext_resource path="res://sprites/objects/LaserBoxDot2.png" type="Texture" id=4]
[ext_resource path="res://sprites/objects/LaserBoxDot4.png" type="Texture" id=5]
[ext_resource path="res://sprites/objects/LaserBoxDot3.png" type="Texture" id=6]
[ext_resource path="res://sprites/objects/LaserBoxDot1.png" type="Texture" id=7]

[sub_resource type="AnimatedTexture" id=2]
flags = 2
frames = 4
fps = 12.0
frame_0/texture = ExtResource( 7 )
frame_1/texture = ExtResource( 4 )
frame_1/delay_sec = 0.0
frame_2/texture = ExtResource( 6 )
frame_2/delay_sec = 0.0
frame_3/texture = ExtResource( 5 )
frame_3/delay_sec = 0.0

[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 1, 10 )

[node name="LaserBoxPart" type="RayCast2D"]
enabled = true
cast_to = Vector2( 1500, 0 )
collision_mask = 2
script = ExtResource( 2 )

[node name="Line" type="Line2D" parent="."]
points = PoolVector2Array( 0, 0, 1500, 0 )
width = 0.0
default_color = Color( 1, 1, 1, 1 )

[node name="DotLine" type="Line2D" parent="."]
self_modulate = Color( 1, 1, 1, 0.121569 )
points = PoolVector2Array( 0, 0, 1500, 0 )
width = 4.0
default_color = Color( 1, 1, 1, 1 )
texture = SubResource( 2 )
texture_mode = 1

[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 6, 0 )
scale = Vector2( 2, 2 )
texture = ExtResource( 1 )

[node name="Hitbox" type="Area2D" parent="."]
collision_layer = 16
collision_mask = 0
monitoring = false
script = ExtResource( 3 )
damage = 2

[node name="Collision" type="CollisionShape2D" parent="Hitbox"]
position = Vector2( 750, 0 )
scale = Vector2( 750, 1 )
shape = SubResource( 1 )
disabled = true
59 changes: 59 additions & 0 deletions scripts/objects/LaserBox.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
tool
extends StaticBody2D


var timer = -1

export var enableTop = false
export var enableRight = false
export var enableBottom = false
export var enableLeft = false

export var activate = 0
export var deactivate = 30
export var loop = 60


onready var _top = $TopPart
onready var _right = $RightPart
onready var _bottom = $BottomPart
onready var _left = $LeftPart


func _physics_process(delta):
show_parts()
do_loop()


func show_parts():
_top.visible = enableTop
_bottom.visible = enableBottom
_left.visible = enableLeft
_right.visible = enableRight



func do_loop():
timer += 1
if timer >= loop:
timer = 0

if timer == activate:
if enableTop:
_top.activate()
if enableRight:
_right.activate()
if enableBottom:
_bottom.activate()
if enableLeft:
_left.activate()

if timer == deactivate:
if enableTop:
_top.deactivate()
if enableRight:
_right.deactivate()
if enableBottom:
_bottom.deactivate()
if enableLeft:
_left.deactivate()
Loading

0 comments on commit cc298b2

Please sign in to comment.