gameplay start

This commit is contained in:
siembra
2026-02-10 13:58:50 -05:00
parent 5b7324ade4
commit 3042bb93c7
19 changed files with 249 additions and 6 deletions

77
scenes/game/comet_zap.gd Normal file
View File

@@ -0,0 +1,77 @@
extends Node2D
# word stuff
var word_set
var word_set_file_path
var word_set_file
var word_set_content
var word_set_array
# init random
var alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z"]
var comets = []
var comet_speed = 150
# numbers
var delay = 2
var spawn_timer = 0
# objects
var comet_source = preload("res://scenes/objects/game/comet.tscn")
# Runs on start
func _ready() -> void:
# Load Corresponding Text File
word_set_file_path = "res://gameplay/word_sets/" + word_set + ".txt"
word_set_file = FileAccess.open(word_set_file_path, FileAccess.READ)
# Gets file contents as text
word_set_content = word_set_file.get_as_text()
# Splits text file contents by line and removes the first entry (its just the name)
word_set_array = word_set_content.split("\n", true)
word_set_array.remove_at(0)
if word_set_array[len(word_set_array)-1] == "":
word_set_array.remove_at(len(word_set_array)-1)
#print(word_set_array)
# Runs every frame
func _process(delta: float) -> void:
spawn_timer += delta
if spawn_timer >= delay:
spawn_timer = 0
spawn_word()
func spawn_word():
var new_word = word_set_array[randi_range(0,len(word_set_array)-1)]
var viewport_size = get_viewport_rect().size
var offset = 0
for char in new_word:
if char != " ":
var new_commet = comet_source.instantiate()
new_commet.position = Vector2(128+offset,-128)
new_commet.get_node("Sprite").get_node("Label").text = char
new_commet.speed = comet_speed
add_child(new_commet)
comets.append(new_commet)
offset += 75
func _input(event):
if event is InputEventKey and event.pressed:
if event.as_text() in alphabet:
print(event.as_text())
if len(comets) > 0:
var comet = comets[0]
if event.as_text() == comet.get_node("Sprite").get_node("Label").text:
comets.erase(comet)
comet.get_node("Sprite").play("cometbreak")
$CometBreakSound.play()
await comet.get_node("Sprite").animation_finished
comet.queue_free()

View File

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

View File

@@ -1,11 +1,16 @@
[gd_scene format=3 uid="uid://bef8re5x0kmmd"]
[ext_resource type="Script" uid="uid://c7vntfq6dyb2k" path="res://scenes/game/comet_zap.gd" id="1_eyb20"]
[ext_resource type="Texture2D" uid="uid://b0qibayc8b02i" path="res://assets/visual/backgrounds/misc/10-6.png" id="1_lcssi"]
[ext_resource type="AudioStream" uid="uid://b2l55uknctgo6" path="res://assets/audio/music/game/Ranma Nibun-no-ichi Bakuretsu Rantouhen - King's Casino [Qk0v_NIqVPg].mp3" id="2_ije4o"]
[ext_resource type="Texture2D" uid="uid://jd2rnhvq6gl6" path="res://original data/images/tux/tux-yes2.png" id="4_yib6v"]
[ext_resource type="AudioStream" uid="uid://t6tbvilcrwy8" path="res://assets/audio/sfx/SE_Push.ogg" id="5_62k7v"]
[node name="CometZap" type="Node2D" unique_id=1227404695]
script = ExtResource("1_eyb20")
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1005683026]
layer = -1
[node name="Control" type="Control" parent="CanvasLayer" unique_id=2022519285]
layout_mode = 3
@@ -29,3 +34,12 @@ expand_mode = 1
stream = ExtResource("2_ije4o")
autoplay = true
parameters/looping = true
[node name="Tux" type="Sprite2D" parent="." unique_id=1799546830]
position = Vector2(599, 651.00006)
scale = Vector2(2.654338, 2.220616)
texture = ExtResource("4_yib6v")
[node name="CometBreakSound" type="AudioStreamPlayer2D" parent="." unique_id=169663936]
stream = ExtResource("5_62k7v")
volume_db = -10.0