working on platfoermer, rather confused
This commit is contained in:
parent
34eb42616d
commit
88cb8f5899
11 changed files with 244 additions and 7 deletions
16
games/platformer/flasher.gd
Normal file
16
games/platformer/flasher.gd
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
extends Sprite2D
|
||||
|
||||
var flash_delay : float = 0.3
|
||||
var timer :float = 1
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
timer = flash_delay
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
timer -= delta
|
||||
if(timer <= 0):
|
||||
visible = !visible
|
||||
timer = flash_delay
|
||||
1
games/platformer/flasher.gd.uid
Normal file
1
games/platformer/flasher.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bvldm4nv0g3
|
||||
|
|
@ -3,21 +3,45 @@ extends Node
|
|||
signal game_win
|
||||
signal game_lose
|
||||
|
||||
enum GameStage{
|
||||
Warning, # big red highlights (flashing?) show the player where to avoid
|
||||
Lasers, # the lasers actively firing
|
||||
None # the starting and ending (offline) state where nothing is happening
|
||||
}
|
||||
|
||||
|
||||
@export var warning_duration = 5
|
||||
@export var laser_duration = 2
|
||||
@export_group("Node References")
|
||||
@export var score_label : Label
|
||||
@export var player : CharacterBody2D
|
||||
@export var skip_location : Marker2D
|
||||
@export var timer : Timer
|
||||
@export var warning_areas : Array[Node2D]
|
||||
@export var laser_areas : Array[Area2D]
|
||||
|
||||
var game_active : bool = false
|
||||
var stage : GameStage = GameStage.None
|
||||
var safe_lane : int # 0,1 or 2 - the others will be hit by lasers
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
GameManager.skip_intro.connect(rec_skip_intro)
|
||||
GameManager.update_data.connect(update_ui)
|
||||
GameManager.start_platformer.connect(start_game)
|
||||
GameManager.end_platformer.connect(end_game)
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
for i in range(2):
|
||||
#warning_areas[i].visible = stage == GameStage.Warning and safe_lane!=i
|
||||
#laser_areas[i].visible = stage == GameStage.Lasers and safe_lane!=i
|
||||
pass
|
||||
warning_areas[0].visible = stage == GameStage.Warning
|
||||
laser_areas[0].visible = stage == GameStage.Lasers
|
||||
#todo make sure lasers dont trigger the door/remote/event hitboxes
|
||||
|
||||
func update_ui(score : int, lives :int):
|
||||
score_label.text = str(score)
|
||||
|
|
@ -27,3 +51,22 @@ func rec_skip_intro():
|
|||
player.global_position = skip_location.global_position
|
||||
#maybe bring up an invis wall behind them but it doesnt matter
|
||||
pass
|
||||
|
||||
func start_game():
|
||||
game_active = true
|
||||
timer.start(warning_duration)
|
||||
safe_lane = randi_range(0,2)
|
||||
stage = GameStage.Warning
|
||||
pass
|
||||
|
||||
func end_game():
|
||||
game_active = false
|
||||
pass
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if(stage == GameStage.Warning):
|
||||
stage = GameStage.Lasers
|
||||
timer.start(laser_duration)
|
||||
if(stage == GameStage.Lasers):
|
||||
stage = GameStage.None
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=32 format=4 uid="uid://ckbyiwy0dxbsd"]
|
||||
[gd_scene load_steps=36 format=4 uid="uid://ckbyiwy0dxbsd"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dqyddqx8xm0gw" path="res://games/platformer/player.gd" id="1_1wj3w"]
|
||||
[ext_resource type="Script" uid="uid://bs4keltwfbrrn" path="res://games/platformer/platformer.gd" id="1_mauky"]
|
||||
|
|
@ -15,6 +15,9 @@
|
|||
[ext_resource type="Texture2D" uid="uid://r71wb0u4bsxw" path="res://sprites/broken_tv_remote.png" id="11_vuxiy"]
|
||||
[ext_resource type="Script" uid="uid://bl7sx7fl7ye4a" path="res://games/platformer/tv_remote.gd" id="13_7gl5q"]
|
||||
[ext_resource type="PackedScene" uid="uid://dv4ex5tshavff" path="res://games/platformer/door.tscn" id="14_yphhh"]
|
||||
[ext_resource type="Texture2D" uid="uid://bvnudttaiaab5" path="res://sprites/platformer_lab_laser.png" id="16_wtveo"]
|
||||
[ext_resource type="Texture2D" uid="uid://dyfubdnvunea2" path="res://sprites/whiteSqaure.png" id="17_x1jr7"]
|
||||
[ext_resource type="Script" uid="uid://bvldm4nv0g3" path="res://games/platformer/flasher.gd" id="18_x1jr7"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_1wj3w"]
|
||||
offsets = PackedFloat32Array(0.0209205, 1)
|
||||
|
|
@ -185,11 +188,17 @@ animations = [{
|
|||
font_size = 86
|
||||
font_color = Color(1, 1, 1, 0.439216)
|
||||
|
||||
[node name="Platformer" type="Node" node_paths=PackedStringArray("score_label", "player", "skip_location")]
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_gyyvr"]
|
||||
size = Vector2(576, 64)
|
||||
|
||||
[node name="Platformer" type="Node" node_paths=PackedStringArray("score_label", "player", "skip_location", "timer", "warning_areas", "laser_areas")]
|
||||
script = ExtResource("1_mauky")
|
||||
score_label = NodePath("Score")
|
||||
player = NodePath("Player")
|
||||
skip_location = NodePath("IntroSkipLocation")
|
||||
timer = NodePath("Timer")
|
||||
warning_areas = [NodePath("Warnings/WarningNode"), NodePath("Warnings/WarningNode2"), NodePath("Warnings/WarningNode3")]
|
||||
laser_areas = [NodePath("Lasers/LaserSet"), NodePath("Lasers/LaserSet2"), NodePath("Lasers/LaserSet3")]
|
||||
|
||||
[node name="Parallax2D" type="Parallax2D" parent="."]
|
||||
scroll_scale = Vector2(0, 0)
|
||||
|
|
@ -330,6 +339,106 @@ horizontal_alignment = 1
|
|||
[node name="IntroSkipLocation" type="Marker2D" parent="."]
|
||||
position = Vector2(-40, 256)
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
|
||||
[node name="Lasers" type="Node2D" parent="."]
|
||||
|
||||
[node name="LaserSet" type="Area2D" parent="Lasers"]
|
||||
visible = false
|
||||
position = Vector2(40, 40)
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Lasers/LaserSet"]
|
||||
position = Vector2(280, 8)
|
||||
rotation = 1.57079
|
||||
scale = Vector2(2.003, 36)
|
||||
texture = ExtResource("16_wtveo")
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="Lasers/LaserSet"]
|
||||
position = Vector2(280, 40)
|
||||
rotation = 1.57079
|
||||
scale = Vector2(2.003, 36)
|
||||
texture = ExtResource("16_wtveo")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Lasers/LaserSet"]
|
||||
position = Vector2(280, 24)
|
||||
shape = SubResource("RectangleShape2D_gyyvr")
|
||||
debug_color = Color(0.977603, 0, 0.402823, 0.42)
|
||||
|
||||
[node name="LaserSet2" type="Area2D" parent="Lasers"]
|
||||
visible = false
|
||||
position = Vector2(40, 136)
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Lasers/LaserSet2"]
|
||||
position = Vector2(280, 8)
|
||||
rotation = 1.57079
|
||||
scale = Vector2(2.003, 36)
|
||||
texture = ExtResource("16_wtveo")
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="Lasers/LaserSet2"]
|
||||
position = Vector2(280, 40)
|
||||
rotation = 1.57079
|
||||
scale = Vector2(2.003, 36)
|
||||
texture = ExtResource("16_wtveo")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Lasers/LaserSet2"]
|
||||
position = Vector2(280, 24)
|
||||
shape = SubResource("RectangleShape2D_gyyvr")
|
||||
debug_color = Color(0.977603, 0, 0.402823, 0.42)
|
||||
|
||||
[node name="LaserSet3" type="Area2D" parent="Lasers"]
|
||||
visible = false
|
||||
position = Vector2(40, 232)
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Lasers/LaserSet3"]
|
||||
position = Vector2(280, 8)
|
||||
rotation = 1.57079
|
||||
scale = Vector2(2.003, 36)
|
||||
texture = ExtResource("16_wtveo")
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="Lasers/LaserSet3"]
|
||||
position = Vector2(280, 40)
|
||||
rotation = 1.57079
|
||||
scale = Vector2(2.003, 36)
|
||||
texture = ExtResource("16_wtveo")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Lasers/LaserSet3"]
|
||||
position = Vector2(280, 24)
|
||||
shape = SubResource("RectangleShape2D_gyyvr")
|
||||
debug_color = Color(0.977603, 0, 0.402823, 0.42)
|
||||
|
||||
[node name="Warnings" type="Node2D" parent="."]
|
||||
|
||||
[node name="WarningNode" type="Node2D" parent="Warnings"]
|
||||
visible = false
|
||||
position = Vector2(320, 64)
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Warnings/WarningNode"]
|
||||
modulate = Color(1, 0, 0, 0.482353)
|
||||
scale = Vector2(18, 2)
|
||||
texture = ExtResource("17_x1jr7")
|
||||
script = ExtResource("18_x1jr7")
|
||||
|
||||
[node name="WarningNode2" type="Node2D" parent="Warnings"]
|
||||
visible = false
|
||||
position = Vector2(320, 160)
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Warnings/WarningNode2"]
|
||||
modulate = Color(1, 0, 0, 0.482353)
|
||||
scale = Vector2(18, 2)
|
||||
texture = ExtResource("17_x1jr7")
|
||||
script = ExtResource("18_x1jr7")
|
||||
|
||||
[node name="WarningNode3" type="Node2D" parent="Warnings"]
|
||||
visible = false
|
||||
position = Vector2(320, 256)
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Warnings/WarningNode3"]
|
||||
modulate = Color(1, 0, 0, 0.482353)
|
||||
scale = Vector2(18, 2)
|
||||
texture = ExtResource("17_x1jr7")
|
||||
script = ExtResource("18_x1jr7")
|
||||
|
||||
[connection signal="area_entered" from="Player/hitbox" to="Player" method="_on_hitbox_area_entered"]
|
||||
[connection signal="area_entered" from="TheBitWhereYouTrip" to="TripAnimation" method="_on_the_bit_where_you_trip_area_entered"]
|
||||
[connection signal="area_entered" from="BrokenRemote" to="AnimationProps/TVRemote" method="_on_broken_remote_area_entered"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
extends Channel
|
||||
|
||||
var platformer_online : bool = true
|
||||
|
||||
func _ready() -> void:
|
||||
#GameManager.end_platformer.connect(end_channel) #maybe?
|
||||
pass
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
offline_channel_cover.visible = channel_mode == Mode.Offline
|
||||
static_channel_cover.visible = channel_mode == Mode.Static
|
||||
if platformer_online :
|
||||
modulate = Color.WHITE
|
||||
else:
|
||||
modulate = Color.DIM_GRAY
|
||||
|
||||
func start_specific_channel(scene : PackedScene):
|
||||
var new_scene = scene.instantiate()
|
||||
|
|
@ -12,11 +22,16 @@ func start_specific_channel(scene : PackedScene):
|
|||
channel_mode = Mode.Online
|
||||
|
||||
func start_channel():
|
||||
start_specific_channel(channel_scene)
|
||||
#start_specific_channel(channel_scene)
|
||||
print("we do a bit of ovveridng")
|
||||
platformer_online = true
|
||||
GameManager.start_platformer.emit()
|
||||
|
||||
|
||||
func end_channel():
|
||||
channel_mode = Mode.Static
|
||||
modulate = Color.DIM_GRAY
|
||||
#channel_mode = Mode.Static
|
||||
#modulate = Color.DIM_GRAY
|
||||
platformer_online = false
|
||||
# TODO: a bunch of stuff here
|
||||
## bro what did you mean when you meant this T_T
|
||||
#game_viewport.get_child(0).queue_free()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue