reduce video memory usage by orders of magnitude

big fonts use lots of big lumalpha8, so just scale up small fonts
This commit is contained in:
Taevas 2025-03-25 23:18:33 +01:00
parent df7736a9d1
commit f7e85724b3
9 changed files with 54 additions and 45 deletions

14
elements/ring.gd Normal file
View file

@ -0,0 +1,14 @@
class_name Ring
extends CSGTorus3D
var happy_material = preload("res://graphics/happy_material.tres")
var collected = false
signal collect_signal
func _on_area_3d_body_entered(body: Node3D) -> void:
if collected == false and body.name == "Sphere":
self.material = happy_material
collected = true
$AudioStreamPlayer.play()
collect_signal.emit()

1
elements/ring.gd.uid Normal file
View file

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

View file

@ -2,25 +2,9 @@
[ext_resource type="Material" uid="uid://brwwlwb1rpro7" path="res://graphics/unhappy_material.tres" id="1_48h5f"] [ext_resource type="Material" uid="uid://brwwlwb1rpro7" path="res://graphics/unhappy_material.tres" id="1_48h5f"]
[ext_resource type="AudioStream" uid="uid://b0cl5v6q1ocbv" path="res://sounds/ring1.ogg" id="2_2so43"] [ext_resource type="AudioStream" uid="uid://b0cl5v6q1ocbv" path="res://sounds/ring1.ogg" id="2_2so43"]
[ext_resource type="Script" uid="uid://d1tdcd6b2bp05" path="res://elements/ring.gd" id="2_288uq"]
[ext_resource type="AudioStream" uid="uid://cvvs74ep5d4wt" path="res://sounds/ring2.ogg" id="3_lkqw0"] [ext_resource type="AudioStream" uid="uid://cvvs74ep5d4wt" path="res://sounds/ring2.ogg" id="3_lkqw0"]
[sub_resource type="GDScript" id="GDScript_86vhg"]
script/source = "class_name Ring
extends CSGTorus3D
var happy_material = preload(\"res://graphics/happy_material.tres\")
var collected = false
signal collect_signal
func _on_area_3d_body_entered(body: Node3D) -> void:
if collected == false and body.name == \"Sphere\":
self.material = happy_material
collected = true
$AudioStreamPlayer.play()
collect_signal.emit()
"
[sub_resource type="CylinderShape3D" id="CylinderShape3D_tgirv"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_tgirv"]
radius = 4.0 radius = 4.0
@ -37,7 +21,8 @@ outer_radius = 8.0
sides = 32 sides = 32
ring_sides = 16 ring_sides = 16
material = ExtResource("1_48h5f") material = ExtResource("1_48h5f")
script = SubResource("GDScript_86vhg") script = ExtResource("2_288uq")
metadata/_custom_type_script = "uid://d1tdcd6b2bp05"
[node name="Area3D" type="Area3D" parent="."] [node name="Area3D" type="Area3D" parent="."]

View file

@ -4,7 +4,7 @@
[node name="Text" type="Label3D" parent="."] [node name="Text" type="Label3D" parent="."]
text = "Sample text" text = "Sample text"
font_size = 1024 font_size = 64
[node name="CSGBox3D" type="CSGBox3D" parent="."] [node name="CSGBox3D" type="CSGBox3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5.1) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5.1)

View file

@ -45,6 +45,7 @@ func start_level(level_scene: PackedScene) -> void:
$VictoryScreen.hide() $VictoryScreen.hide()
var level = level_scene.instantiate() var level = level_scene.instantiate()
$Levels.add_child(level) $Levels.add_child(level)
level.connect(\"completed\", stop_level)
playing = true playing = true
PhysicsServer3D.area_set_param( PhysicsServer3D.area_set_param(
get_viewport().find_world_3d().space, get_viewport().find_world_3d().space,

View file

@ -28,6 +28,7 @@ transform = Transform3D(-1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0, 1, -366.4
transform = Transform3D(-1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, -366.478, 3.24249e-05, 0) transform = Transform3D(-1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, -366.478, 3.24249e-05, 0)
[node name="Text" parent="Signs/Sign" index="0"] [node name="Text" parent="Signs/Sign" index="0"]
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
text = "Press the arrow keys text = "Press the arrow keys
to change the gravity!" to change the gravity!"
@ -35,13 +36,14 @@ to change the gravity!"
transform = Transform3D(4.37114e-08, -7.10543e-15, -1, -8.74228e-08, -1, 0, -1, 8.74228e-08, -4.37114e-08, 150, 40, 61) transform = Transform3D(4.37114e-08, -7.10543e-15, -1, -8.74228e-08, -1, 0, -1, 8.74228e-08, -4.37114e-08, 150, 40, 61)
[node name="Text" parent="Signs/Sign7" index="0"] [node name="Text" parent="Signs/Sign7" index="0"]
transform = Transform3D(30, 0, 0, 0, 30, 0, 0, 0, 30, 0, 0, 0)
text = "SLOW DOWN!!" text = "SLOW DOWN!!"
font_size = 2056
[node name="Sign2" parent="Signs" instance=ExtResource("4_atq6y")] [node name="Sign2" parent="Signs" instance=ExtResource("4_atq6y")]
transform = Transform3D(-1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, -234.9, 2.09808e-05, 0) transform = Transform3D(-1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, -234.9, 2.09808e-05, 0)
[node name="Text" parent="Signs/Sign2" index="0"] [node name="Text" parent="Signs/Sign2" index="0"]
transform = Transform3D(15, 0, 0, 0, 15, 0, 0, 0, 15, 0, 0, 0)
text = "While the shift key is pressed, text = "While the shift key is pressed,
the gravity is much stronger!" the gravity is much stronger!"
@ -49,6 +51,7 @@ the gravity is much stronger!"
transform = Transform3D(-1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, -131.629, 81.2564, 0) transform = Transform3D(-1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, -131.629, 81.2564, 0)
[node name="Text" parent="Signs/Sign4" index="0"] [node name="Text" parent="Signs/Sign4" index="0"]
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
text = "You can take the rings text = "You can take the rings
in any order!" in any order!"
@ -56,6 +59,7 @@ in any order!"
transform = Transform3D(-4.37114e-08, 8.74228e-08, 1, 0, -1, 8.74228e-08, 1, 3.82137e-15, 4.37114e-08, -490.634, 50.3763, 34.0693) transform = Transform3D(-4.37114e-08, 8.74228e-08, 1, 0, -1, 8.74228e-08, 1, 3.82137e-15, 4.37114e-08, -490.634, 50.3763, 34.0693)
[node name="Text" parent="Signs/Sign5" index="0"] [node name="Text" parent="Signs/Sign5" index="0"]
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
text = "The level is over once text = "The level is over once
you get all the rings!" you get all the rings!"
@ -63,13 +67,13 @@ you get all the rings!"
transform = Transform3D(-0.707107, 6.18172e-08, 0.707107, -8.74228e-08, -1, 0, 0.707107, -6.18172e-08, 0.707107, -532.475, 18.0064, 60) transform = Transform3D(-0.707107, 6.18172e-08, 0.707107, -8.74228e-08, -1, 0, 0.707107, -6.18172e-08, 0.707107, -532.475, 18.0064, 60)
[node name="Text" parent="Signs/Sign6" index="0"] [node name="Text" parent="Signs/Sign6" index="0"]
transform = Transform3D(30, 0, 0, 0, 30, 0, 0, 0, 30, 0, 0, 0)
text = "Have fun!" text = "Have fun!"
font_size = 2048
[node name="Sign3" parent="Signs" instance=ExtResource("4_atq6y")] [node name="Sign3" parent="Signs" instance=ExtResource("4_atq6y")]
[node name="Text" parent="Signs/Sign3" index="0"] [node name="Text" parent="Signs/Sign3" index="0"]
transform = Transform3D(-1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0, 1, 0, 0, 0) transform = Transform3D(-20, 3.01992e-06, 0, -3.01992e-06, -20, 0, 0, 0, 20, 0, 0, 0)
text = "The less time you take, text = "The less time you take,
the more you can flex!" the more you can flex!"

View file

@ -51,9 +51,8 @@ environment = SubResource("Environment_y3whn")
transform = Transform3D(-4.37114e-08, 8.74228e-08, 1, 0, -1, 8.74228e-08, 1, 3.82137e-15, 4.37114e-08, -450, 132.977, 0) transform = Transform3D(-4.37114e-08, 8.74228e-08, 1, 0, -1, 8.74228e-08, 1, 3.82137e-15, 4.37114e-08, -450, 132.977, 0)
[node name="Text" parent="Sign" index="0"] [node name="Text" parent="Sign" index="0"]
transform = Transform3D(-1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0, 1, 0, 0, 0) transform = Transform3D(-35, 5.28485e-06, 0, -5.28485e-06, -35, 0, 0, 0, 35, 0, 0, 0)
text = "Watch out!" text = "Watch out!"
font_size = 2048
[node name="Trees" type="Node3D" parent="."] [node name="Trees" type="Node3D" parent="."]

View file

@ -1,10 +1,14 @@
class_name Level class_name Level
extends Node3D extends Node3D
signal ring_collected
signal completed
var seconds_spent: float = 0.00
var music: Music var music: Music
var velocity: float = 0.0 var velocity: float = 0.0
var rings: Array[Node] = [] var rings: Array[Ring] = []
var finished_rings_count = 0 var finished_rings_count: int = 0
func _ready() -> void: func _ready() -> void:
var children = get_children() var children = get_children()
@ -14,19 +18,21 @@ func _ready() -> void:
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")
assert(is_instance_valid(rings_node), self.name + " has no rings!") assert(is_instance_valid(rings_node), self.name + " has no Rings node!")
rings = rings_node.get_children() var rings_node_children = rings_node.get_children()
for ring in rings: for ring in rings_node_children:
ring.connect("collect_signal", do_we_end_yet) if is_instance_of(ring, Ring):
rings.push_back(ring)
ring.connect("collect_signal", collect_ring)
func do_we_end_yet(): func collect_ring():
finished_rings_count += 1 finished_rings_count = len(rings.filter(func(ring: Ring): return ring.collected))
ring_collected.emit()
if finished_rings_count >= len(rings): if finished_rings_count >= len(rings):
var game = get_parent().get_parent() completed.emit()
if is_instance_valid(game) and game.has_method("stop_level"):
game.stop_level()
func _process(delta: float) -> void: func _process(delta: float) -> void:
var sphere = $Player/Sphere seconds_spent += delta
velocity = abs(sphere.linear_velocity.x) + abs(sphere.linear_velocity.y) velocity = abs($Player.velocity.x) + abs($Player.velocity.y)
music.adaptInstrumentsToVelocity(velocity, delta) music.adaptInstrumentsToVelocity(velocity, delta)

View file

@ -174,40 +174,42 @@ transform = Transform3D(-1.31134e-07, -3, 0, 3, -1.31134e-07, 0, 0, 0, 3, -104.2
[node name="Ring2" parent="Rings" instance=ExtResource("4_brcr0")] [node name="Ring2" parent="Rings" instance=ExtResource("4_brcr0")]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, -12.3896, -2, 0) transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, -12.3896, -2, 0)
[node name="Tree" parent="." instance=ExtResource("8_kgstj")]
transform = Transform3D(-3.79443, -7.04289, 0, 7.04289, -3.79443, 0, 0, 0, 8, 28.958, -413.185, -93.8242)
[node name="Signs" type="Node3D" parent="."] [node name="Signs" type="Node3D" parent="."]
[node name="Sign" parent="Signs" instance=ExtResource("6_36yav")] [node name="Sign" parent="Signs" instance=ExtResource("6_36yav")]
transform = Transform3D(0.843785, 0, 0.536681, 0, 1, 0, -0.536681, 0, 0.843785, -159.605, -62.9326, 0) transform = Transform3D(0.843785, 0, 0.536681, 0, 1, 0, -0.536681, 0, 0.843785, -159.605, -62.9326, 0)
[node name="Text" parent="Signs/Sign" index="0"] [node name="Text" parent="Signs/Sign" index="0"]
transform = Transform3D(37, 0, 0, 0, 37, 0, 0, 0, 37, 0, 0, 0)
text = "^^^ text = "^^^
Go UP!!" Go UP!!"
font_size = 2048
[node name="Sign4" parent="Signs" instance=ExtResource("6_36yav")] [node name="Sign4" parent="Signs" instance=ExtResource("6_36yav")]
transform = Transform3D(0.965926, 0, 0.258819, 0, 1, 0, -0.258819, 0, 0.965926, 231.92, -32.6467, 0) transform = Transform3D(0.965926, 0, 0.258819, 0, 1, 0, -0.258819, 0, 0.965926, 231.92, -32.6467, 0)
[node name="Text" parent="Signs/Sign4" index="0"] [node name="Text" parent="Signs/Sign4" index="0"]
transform = Transform3D(22, 0, 0, 0, 22, 0, 0, 0, 22, 0, 0, 0)
text = "^^ text = "^^
Don't forget Don't forget
that one!" that one!"
font_size = 1500
[node name="Sign2" parent="Signs" instance=ExtResource("6_36yav")] [node name="Sign2" parent="Signs" instance=ExtResource("6_36yav")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -159.605, -30.0117, -45.6318) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -159.605, -30.0117, -45.6318)
[node name="Text" parent="Signs/Sign2" index="0"] [node name="Text" parent="Signs/Sign2" index="0"]
transform = Transform3D(30, 0, 0, 0, 30, 0, 0, 0, 30, 0, 0, 0)
text = "After taking this, text = "After taking this,
go RIGHT!" go RIGHT!"
font_size = 1600
[node name="Sign3" parent="Signs" instance=ExtResource("6_36yav")] [node name="Sign3" parent="Signs" instance=ExtResource("6_36yav")]
transform = Transform3D(-1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, -64.0671, 131.627, -45.6318) transform = Transform3D(-1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1, -64.0671, 131.627, -45.6318)
[node name="Text" parent="Signs/Sign3" index="0"] [node name="Text" parent="Signs/Sign3" index="0"]
transform = Transform3D(-1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0, 1, 0, 0, 0) transform = Transform3D(-30, 4.52987e-06, 0, -4.52987e-06, -30, 0, 0, 0, 30, 0, 0, 0)
text = "Go RIGHT!" text = "Go RIGHT!"
font_size = 2048
[node name="Stars" type="Node3D" parent="."] [node name="Stars" type="Node3D" parent="."]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 37.5124, -255.888) transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 37.5124, -255.888)
@ -307,9 +309,6 @@ transform = Transform3D(-0.99693, 0.0731445, -0.0279554, -0.0555776, -0.912445,
[node name="Star32" parent="Stars" instance=ExtResource("7_ltcl0")] [node name="Star32" parent="Stars" instance=ExtResource("7_ltcl0")]
transform = Transform3D(-0.99693, 0.0731445, -0.0279554, -0.0555776, -0.912445, -0.405407, -0.055161, -0.402609, 0.913709, 0.952739, 0.24193, 7.10684) transform = Transform3D(-0.99693, 0.0731445, -0.0279554, -0.0555776, -0.912445, -0.405407, -0.055161, -0.402609, 0.913709, 0.952739, 0.24193, 7.10684)
[node name="Tree" parent="." instance=ExtResource("8_kgstj")]
transform = Transform3D(-3.79443, -7.04289, 0, 7.04289, -3.79443, 0, 0, 0, 8, 28.958, -413.185, -93.8242)
[editable path="Signs/Sign"] [editable path="Signs/Sign"]
[editable path="Signs/Sign4"] [editable path="Signs/Sign4"]
[editable path="Signs/Sign2"] [editable path="Signs/Sign2"]