Compare commits
1 commit
20250503.0
...
master
Author | SHA1 | Date | |
---|---|---|---|
2f646169fb |
5 changed files with 91 additions and 1 deletions
|
@ -11,8 +11,10 @@ var velocity := 0.0:
|
||||||
if value != velocity:
|
if value != velocity:
|
||||||
velocity_change.emit(value)
|
velocity_change.emit(value)
|
||||||
velocity = value
|
velocity = value
|
||||||
|
@onready var ball_position: Vector3 = $Sphere.position
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
|
ball_position = $Sphere.position
|
||||||
$SpotLightMain.position = $Sphere.position + Vector3(0, 5, 0)
|
$SpotLightMain.position = $Sphere.position + Vector3(0, 5, 0)
|
||||||
$SpotLightTop.position = $Sphere.position
|
$SpotLightTop.position = $Sphere.position
|
||||||
$SpotLightLeft.position = $Sphere.position
|
$SpotLightLeft.position = $Sphere.position
|
||||||
|
|
66
gui/map.tscn
Normal file
66
gui/map.tscn
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://bcxbw6wd54ksv"]
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_r4thc"]
|
||||||
|
script/source = "extends Control
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
$TemplateRing.hide()
|
||||||
|
|
||||||
|
func display_rings(player: Node3D, rings: Array[Ring]) -> void:
|
||||||
|
var old_rings_display := $Rings.get_children()
|
||||||
|
var difference := len(rings) - len(old_rings_display)
|
||||||
|
|
||||||
|
# Too many displayed, free them
|
||||||
|
for i in -difference:
|
||||||
|
old_rings_display[-(1 + i)].queue_free()
|
||||||
|
# Not enough displayed, create some
|
||||||
|
for i in difference:
|
||||||
|
var new_child := $TemplateRing.duplicate()
|
||||||
|
new_child.name = \"Ring\" + str(i + 1)
|
||||||
|
new_child.show()
|
||||||
|
$Rings.add_child(new_child)
|
||||||
|
|
||||||
|
var rings_display := $Rings.get_children()
|
||||||
|
var center: Vector2i = get_viewport().size / 2
|
||||||
|
for i in len(rings):
|
||||||
|
rings_display[i].color = rings[i].material.albedo_color
|
||||||
|
rings_display[i].rotation = rings[i].rotation.z
|
||||||
|
rings_display[i].position.x = center.x + rings[i].position.x - player.ball_position.x
|
||||||
|
rings_display[i].position.y = center.y - rings[i].position.y + player.ball_position.y
|
||||||
|
|
||||||
|
if rings[i].collected:
|
||||||
|
rings_display[i].scale = $TemplateRing.scale * 2 * min(4, max(1, rings[i].scale.x))
|
||||||
|
else:
|
||||||
|
rings_display[i].scale = $TemplateRing.scale * 3 * min(4, max(1, rings[i].scale.x))
|
||||||
|
"
|
||||||
|
|
||||||
|
[node name="Map" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = SubResource("GDScript_r4thc")
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(1, 0, 1, 0.0392157)
|
||||||
|
|
||||||
|
[node name="Rings" type="Control" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="TemplateRing" type="ColorRect" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_right = 2.0
|
||||||
|
offset_bottom = 2.0
|
14
index.tscn
14
index.tscn
|
@ -1,8 +1,9 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://ccgnnif026wb4"]
|
[gd_scene load_steps=8 format=3 uid="uid://ccgnnif026wb4"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://xd3nsiglcdfc" path="res://gui/timer.tscn" id="1_356j3"]
|
[ext_resource type="PackedScene" uid="uid://xd3nsiglcdfc" path="res://gui/timer.tscn" id="1_356j3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://gui/gravity.tscn" id="1_ir7so"]
|
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://gui/gravity.tscn" id="1_ir7so"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cckeamgkt8bqo" path="res://gui/speed.tscn" id="2_2gn6w"]
|
[ext_resource type="PackedScene" uid="uid://cckeamgkt8bqo" path="res://gui/speed.tscn" id="2_2gn6w"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bcxbw6wd54ksv" path="res://gui/map.tscn" id="2_d1yoc"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cn55m5dqo3m6u" path="res://gui/rings.tscn" id="3_mbj17"]
|
[ext_resource type="PackedScene" uid="uid://cn55m5dqo3m6u" path="res://gui/rings.tscn" id="3_mbj17"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dkxtwpcy4moyo" path="res://menus/pause_menu.tscn" id="4_3bfj3"]
|
[ext_resource type="PackedScene" uid="uid://dkxtwpcy4moyo" path="res://menus/pause_menu.tscn" id="4_3bfj3"]
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ var current_level_scene: PackedScene
|
||||||
const res_main_menu = preload(\"res://menus/main/main_menu.tscn\")
|
const res_main_menu = preload(\"res://menus/main/main_menu.tscn\")
|
||||||
|
|
||||||
@onready var gui_gravity := $GUI/Gravity
|
@onready var gui_gravity := $GUI/Gravity
|
||||||
|
@onready var gui_map := $GUI/Map
|
||||||
@onready var gui_timer := $GUI/TopLeft/Timer
|
@onready var gui_timer := $GUI/TopLeft/Timer
|
||||||
@onready var gui_speed := $GUI/TopRight/Speed
|
@onready var gui_speed := $GUI/TopRight/Speed
|
||||||
@onready var gui_rings := $GUI/BottomRight/Rings
|
@onready var gui_rings := $GUI/BottomRight/Rings
|
||||||
|
@ -130,8 +132,14 @@ func fullscreen_game() -> void:
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if is_instance_valid(current_level):
|
if is_instance_valid(current_level):
|
||||||
gui_speed.ball_velocity = current_level.velocity
|
gui_speed.ball_velocity = current_level.velocity
|
||||||
|
if Input.is_action_pressed(\"display_map\"):
|
||||||
|
gui_map.display_rings(current_level.player, current_level.rings)
|
||||||
|
|
||||||
func _input(_event: InputEvent) -> void:
|
func _input(_event: InputEvent) -> void:
|
||||||
|
if Input.is_action_just_released(\"display_map\"):
|
||||||
|
gui_map.hide()
|
||||||
|
if Input.is_action_just_pressed(\"display_map\"):
|
||||||
|
gui_map.show()
|
||||||
if Input.is_action_just_pressed(\"restart_level\"):
|
if Input.is_action_just_pressed(\"restart_level\"):
|
||||||
restart_level()
|
restart_level()
|
||||||
|
|
||||||
|
@ -154,6 +162,10 @@ mouse_filter = 2
|
||||||
[node name="Gravity" parent="GUI" instance=ExtResource("1_ir7so")]
|
[node name="Gravity" parent="GUI" instance=ExtResource("1_ir7so")]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
||||||
|
[node name="Map" parent="GUI" instance=ExtResource("2_d1yoc")]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 1
|
||||||
|
|
||||||
[node name="TopLeft" type="MarginContainer" parent="GUI"]
|
[node name="TopLeft" type="MarginContainer" parent="GUI"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
offset_right = 160.0
|
offset_right = 160.0
|
||||||
|
|
|
@ -12,6 +12,7 @@ const gravity_strength_strong = gravity_strength_normal * 3
|
||||||
## Lowercase, spaceless name of the level
|
## Lowercase, spaceless name of the level
|
||||||
var id: String
|
var id: String
|
||||||
var thumbnail: CompressedTexture2D
|
var thumbnail: CompressedTexture2D
|
||||||
|
var player: Node3D
|
||||||
var music: Music
|
var music: Music
|
||||||
var rings: Array[Ring] = []
|
var rings: Array[Ring] = []
|
||||||
|
|
||||||
|
@ -39,6 +40,8 @@ func _ready() -> void:
|
||||||
for child in children:
|
for child in children:
|
||||||
if is_instance_of(child, Music):
|
if is_instance_of(child, Music):
|
||||||
music = child
|
music = child
|
||||||
|
if child.name == "Player" and is_instance_of(child, Node3D):
|
||||||
|
player = child
|
||||||
assert(is_instance_valid(music), self.name + " has no music!")
|
assert(is_instance_valid(music), self.name + " has no music!")
|
||||||
|
|
||||||
var rings_node = get_node("Rings")
|
var rings_node = get_node("Rings")
|
||||||
|
|
|
@ -78,6 +78,13 @@ restart_level={
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
display_map={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue