ddr gaming

This commit is contained in:
Tabby 2025-05-13 15:56:51 +10:00
parent 04417dffbd
commit 288245037b
25 changed files with 466 additions and 6 deletions

33
games/ddr/ddr.gd Normal file
View file

@ -0,0 +1,33 @@
extends Node
@export var note_frequency : float = 2
@export var paths : Array[Node2D]
var next_note : float = 99
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
next_note = note_frequency
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
next_note -= delta
if(next_note <= 0):
next_note = note_frequency
spawn_note()
if(Input.is_action_just_pressed("ddr_left")):
detect_hit(0)
if(Input.is_action_just_pressed("ddr_down")):
detect_hit(1)
if(Input.is_action_just_pressed("ddr_up")):
detect_hit(2)
if(Input.is_action_just_pressed("ddr_right")):
detect_hit(3)
func spawn_note():
var ran_path = randi_range(0, paths.size()-1)
paths[ran_path].spawn_note()
func detect_hit(lane : int):
paths[lane].check_hit()

1
games/ddr/ddr.gd.uid Normal file
View file

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

48
games/ddr/ddr.tscn Normal file
View file

@ -0,0 +1,48 @@
[gd_scene load_steps=8 format=3 uid="uid://b5lh8cnwu8xhg"]
[ext_resource type="PackedScene" uid="uid://dgg4fsg4xhdwa" path="res://games/ddr/note_path.tscn" id="1_wdky4"]
[ext_resource type="Script" uid="uid://dv72o4x8p6raq" path="res://games/ddr/ddr.gd" id="1_wvoco"]
[ext_resource type="Texture2D" uid="uid://50vdogpsfifh" path="res://sprites/ddr_green.png" id="2_oxbdn"]
[ext_resource type="Texture2D" uid="uid://c30il7iehgccl" path="res://sprites/ddr_yellow.png" id="3_wvoco"]
[ext_resource type="Texture2D" uid="uid://c3rmkv7q4q8gc" path="res://sprites/ddr_blue.png" id="4_i3ush"]
[sub_resource type="Gradient" id="Gradient_s8ryg"]
interpolation_color_space = 2
offsets = PackedFloat32Array(0, 0.129707, 1)
colors = PackedColorArray(5.17406e-07, 0.310176, 0.264961, 1, 0, 0.313239, 0.313239, 1, 0.313805, 0.000234589, 0.377941, 1)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_wdky4"]
gradient = SubResource("Gradient_s8ryg")
fill = 2
fill_from = Vector2(0.542735, 1)
fill_to = Vector2(0.487179, 0)
[node name="Ddr" type="Node" node_paths=PackedStringArray("paths")]
script = ExtResource("1_wvoco")
paths = [NodePath("left_path"), NodePath("down_path"), NodePath("up_path"), NodePath("right_path")]
[node name="TextureRect" type="TextureRect" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("GradientTexture2D_wdky4")
[node name="left_path" parent="." instance=ExtResource("1_wdky4")]
position = Vector2(379, 40)
arrow_rotation = 270
[node name="down_path" parent="." instance=ExtResource("1_wdky4")]
position = Vector2(445, 40)
arrow_texture = ExtResource("2_oxbdn")
arrow_rotation = 180
[node name="up_path" parent="." instance=ExtResource("1_wdky4")]
position = Vector2(511, 40)
arrow_texture = ExtResource("3_wvoco")
[node name="right_path" parent="." instance=ExtResource("1_wdky4")]
position = Vector2(577, 40)
arrow_texture = ExtResource("4_i3ush")
arrow_rotation = 90

14
games/ddr/ddr_note.gd Normal file
View file

@ -0,0 +1,14 @@
extends Node2D
var note_speed : float = 1
@export_group("Node References")
@export var sprite : Sprite2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
position.y -= note_speed * delta

View file

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

20
games/ddr/ddr_note.tscn Normal file
View file

@ -0,0 +1,20 @@
[gd_scene load_steps=4 format=3 uid="uid://br48sxf5llkep"]
[ext_resource type="Texture2D" uid="uid://co01e75fr42v2" path="res://sprites/ddr_red.png" id="1_eadbn"]
[ext_resource type="Script" uid="uid://c1bu18t3p2nuq" path="res://games/ddr/ddr_note.gd" id="1_olog6"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_olog6"]
size = Vector2(30, 30)
[node name="DdrNote" type="Node2D" node_paths=PackedStringArray("sprite")]
scale = Vector2(2, 2)
script = ExtResource("1_olog6")
sprite = NodePath("Sprite2D")
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("RectangleShape2D_olog6")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_eadbn")

48
games/ddr/note_path.gd Normal file
View file

@ -0,0 +1,48 @@
extends Node2D
signal note_hit
signal note_miss
@export var note_speed : float = 1
#@export var frequency_min : float = 0.5
#@export var frequency_max : float = 2
@export var arrow_texture : Texture
@export var arrow_rotation : int =0
@export_group("Node References")
@export var detection_area : Area2D
@export var judgement_arrow : Sprite2D
@export var note_spawn_location : Marker2D
#var next_spawn_time : float = 10
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
judgement_arrow.rotation_degrees += arrow_rotation
#next_spawn_time = randf_range(frequency_min, frequency_max)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
#next_spawn_time -= delta
#if next_spawn_time <= 0:
#next_spawn_time = randf_range(frequency_min, frequency_max)
#spawn_note()
pass
func spawn_note():
var new_note : Node2D = load("res://games/ddr/ddr_note.tscn").instantiate()
new_note.sprite.texture = arrow_texture
new_note.note_speed = note_speed
new_note.global_position = note_spawn_location.global_position
new_note.rotation_degrees += arrow_rotation
get_parent().add_child(new_note)
func _on_kill_area_entered(area: Area2D) -> void:
note_miss.emit()
func check_hit():
if (detection_area.get_overlapping_areas().size() > 0):
note_hit.emit()
detection_area.get_overlapping_areas()[0].get_parent().queue_free()

View file

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

45
games/ddr/note_path.tscn Normal file
View file

@ -0,0 +1,45 @@
[gd_scene load_steps=6 format=3 uid="uid://dgg4fsg4xhdwa"]
[ext_resource type="Script" uid="uid://ctxqhit4up2a1" path="res://games/ddr/note_path.gd" id="1_ddair"]
[ext_resource type="Texture2D" uid="uid://co01e75fr42v2" path="res://sprites/ddr_red.png" id="2_1p2y5"]
[ext_resource type="Texture2D" uid="uid://5fc77pbmdrlx" path="res://sprites/ddr_grey.png" id="3_6whpv"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_oxbdn"]
size = Vector2(60, 12)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ddair"]
size = Vector2(60, 12)
[node name="NotePath" type="Node2D" node_paths=PackedStringArray("detection_area", "judgement_arrow", "note_spawn_location")]
script = ExtResource("1_ddair")
note_speed = 75.0
arrow_texture = ExtResource("2_1p2y5")
detection_area = NodePath("Hit/Area2D")
judgement_arrow = NodePath("Hit/Sprite2D")
note_spawn_location = NodePath("NoteSpawn")
[node name="NoteSpawn" type="Marker2D" parent="."]
position = Vector2(0, 366)
[node name="Hit" type="Node2D" parent="."]
[node name="Sprite2D" type="Sprite2D" parent="Hit"]
modulate = Color(1, 1, 1, 0.32549)
scale = Vector2(2, 2)
texture = ExtResource("3_6whpv")
[node name="Area2D" type="Area2D" parent="Hit"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hit/Area2D"]
shape = SubResource("RectangleShape2D_oxbdn")
[node name="NoteKiller" type="Node2D" parent="."]
[node name="Area2D" type="Area2D" parent="NoteKiller"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="NoteKiller/Area2D"]
position = Vector2(0, -96)
shape = SubResource("RectangleShape2D_ddair")
debug_color = Color(0.993681, 0.0732683, 0, 0.42)
[connection signal="area_entered" from="NoteKiller/Area2D" to="." method="_on_kill_area_entered"]