its all coming together!

This commit is contained in:
tabby 2025-05-16 15:56:55 +10:00
parent 35db2250f7
commit 2b90112231
6 changed files with 65 additions and 4 deletions

View file

@ -33,7 +33,12 @@ func _process(delta: float) -> void:
offline_channel_cover.visible = channel_mode == Mode.Offline
static_channel_cover.visible = channel_mode == Mode.Static
func start_channel(scene : PackedScene):
func start_channel():
var new_scene = channel_scene.instantiate()
game_viewport.add_child(new_scene)
channel_mode = Mode.Online
func start_specific_channel(scene : PackedScene):
var new_scene = scene.instantiate()
game_viewport.add_child(new_scene)
channel_mode = Mode.Online

View file

@ -6,25 +6,32 @@ enum Gamemode{
}
#mode settings
@export var max_lives = 3
@export var lives = 3
@export var platformer_game : PackedScene
@export var games : Array[PackedScene]
@export var zoom_speed : float = 0.5
@export_group("Channel Rules")
@export var target_channels : float = 2.5
@export var channel_growth_per_min : float = 4
@export_group("Node References")
@export var main_camera : Camera2D
@export var outer_channels : Array[Channel]
@export var main_channel : Channel
var gamemode : Gamemode = Gamemode.Story #will be set by manager/menu option
var zooming_out : bool = false
var gameplay : bool = false # becomes true when the game starts
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
GameManager.zoom_out_signal.connect(zoom_out)
GameManager.prepare.connect(get_ready)
GameManager.gaming.connect(start_game)
if(gamemode == Gamemode.Story):
main_camera.zoom = Vector2(3.1,3.1)
main_channel.start_channel(platformer_game)
main_channel.start_specific_channel(platformer_game)
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -34,6 +41,8 @@ func _process(delta: float) -> void:
if(zooming_out):
var zoom_amount : float = clampf(main_camera.zoom.x - delta * zoom_speed,1, 4 )
main_camera.zoom = Vector2(zoom_amount,zoom_amount)
if(gameplay):
game_loop(delta)
func zoom_out():
zooming_out = true
@ -41,3 +50,26 @@ func zoom_out():
func get_ready():
for channel in outer_channels:
channel.channel_mode = channel.Mode.Static
func start_game():
gameplay = true
func game_loop(delta : float):
target_channels += channel_growth_per_min * (delta/60)
var online_channels : Array[Channel]
var offline_channels : Array[Channel]
# sort all the channels into online and offline
if main_channel.channel_mode == Channel.Mode.Online:
online_channels.append(main_channel)
else:
online_channels.append(main_channel)
for channel in outer_channels:
if(channel.channel_mode == Channel.Mode.Online):
online_channels.append(channel)
else:
offline_channels.append(channel)
# if i need to switch a channel online, then pick one and run tis start channel method
print("Online Channels: " + str(online_channels.size()))
if(online_channels.size() < target_channels and offline_channels.size() > 0):
var random_channel_number = randi_range(0, offline_channels.size()-1)
offline_channels[random_channel_number].start_channel()

View file

@ -37,7 +37,7 @@ func prepare_for_gaming():
prepare.emit()
# as soon as the player dismisses this chat the game is afoot
GameManager.show_item("Broken TV Remote", broken_tv_remote)
GameManager.show_chat("[color=red]ALERT: Intruder Detected")
GameManager.show_chat("[color=red]ALERT: Intruder Detected... Initiating Security Protocol...")
pass
func actually_gaming():

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=3 uid="uid://ct8axfbvd2wn4"]
[gd_scene load_steps=16 format=3 uid="uid://ct8axfbvd2wn4"]
[ext_resource type="Script" uid="uid://d2q6xfk8htbyy" path="res://game_logic.gd" id="1_j5hk1"]
[ext_resource type="PackedScene" uid="uid://63rik2noj8id" path="res://base modules/test_channel.tscn" id="1_mlf6e"]
@ -11,6 +11,7 @@
[ext_resource type="PackedScene" uid="uid://bkabgl6p44c5b" path="res://games/space invaders/space_invaders.tscn" id="9_miq82"]
[ext_resource type="PackedScene" uid="uid://drk2fwkv816qv" path="res://games/crafting/crafting.tscn" id="9_udeyl"]
[ext_resource type="Texture2D" uid="uid://baf30tscdkl0i" path="res://sprites/tv_remote.png" id="11_j5hk1"]
[ext_resource type="Script" uid="uid://ca41i40uerrbr" path="res://games/platformer/platformer_channel.gd" id="11_mlphb"]
[ext_resource type="Script" uid="uid://dgq2y6wjlye6" path="res://chatboxController.gd" id="11_ueiaa"]
[ext_resource type="Script" uid="uid://dnptjh111yd8i" path="res://itemPopup.gd" id="12_daj04"]
@ -71,6 +72,7 @@ channel_scene = ExtResource("5_e35lh")
[node name="Main" parent="GridContainer" instance=ExtResource("1_mlf6e")]
layout_mode = 2
script = ExtResource("11_mlphb")
channel_name = "Platformer"
channel_scene = ExtResource("4_mj2jn")

View file

@ -0,0 +1,21 @@
extends Channel
func _process(delta: float) -> void:
offline_channel_cover.visible = channel_mode == Mode.Offline
static_channel_cover.visible = channel_mode == Mode.Static
func start_specific_channel(scene : PackedScene):
var new_scene = scene.instantiate()
game_viewport.add_child(new_scene)
channel_mode = Mode.Online
func start_channel():
var new_scene = channel_scene.instantiate()
game_viewport.add_child(new_scene)
channel_mode = Mode.Online
func end_channel():
channel_mode = Mode.Static
modulate = Color.DIM_GRAY
# TODO: a bunch of stuff here
#game_viewport.get_child(0).queue_free()

View file

@ -0,0 +1 @@
uid://ca41i40uerrbr