Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add speed boost areas in races #43

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Copyright: 2019 Zylann
License: CC-BY-NC-ND-1.0
Source: https://github.com/Zylann/marbles

Files: assets/sounds/boost.ogg
Copyright: 2018 rubberduck
License: CC0-1.0
Source: https://opengameart.org/content/50-cc0-retro-synth-sfx

# Fonts

Files: assets/fonts/box_pixies.ttf
Expand All @@ -78,3 +83,8 @@ Files: shaders/sky.gdshader
Copyright: 2023 krzmig
License: MIT
Source: https://godotshaders.com/shader/stylized-sky-with-procedural-sun-and-moon/

Files: shaders/ernergy_shield.gdshader
Copyright: 2023 Daniel Bologna
License: MIT
Source: https://godotshaders.com/shader/energy-shield-with-impact-effect/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Added
- Add speed boost areas in races ([#43](https://github.com/MechanicalFlower/Marble/pull/43))
### Changed
### Deprecated
### Removed
Expand Down
Binary file added assets/sounds/boost.ogg
Binary file not shown.
19 changes: 19 additions & 0 deletions assets/sounds/boost.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://5o2mnxsagwq1"
path="res://.godot/imported/boost.ogg-94c400d1a8bbbf61e00982a73ca9efe8.oggvorbisstr"

[deps]

source_file="res://assets/sounds/boost.ogg"
dest_files=["res://.godot/imported/boost.ogg-94c400d1a8bbbf61e00982a73ca9efe8.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
11 changes: 9 additions & 2 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ SettingsManager="*res://scripts/framework/settings_manager.gd"
Shake="*res://scripts/shake.gd"
DebugMenu="*res://addons/debug_menu/debug_menu.tscn"

[build_info]

package/version="1.4.6"
package/build_date="2024/01/14"
source/commit="41b766d42997fc9af1af4cb8680329bf02d0833f"

[custom_options]

build_info/commit="8ae31e80beb2a3f9b2f8682c2e6488e90aa01de9"
build_info/date="2024/02/04"
build_info/commit="e3b934bf067266c1a8ca09db07e5e6308e89346e"
build_info/date="2024/02/10"

[display]

Expand Down Expand Up @@ -73,6 +79,7 @@ wav={
3d_physics/layer_1="Props"
3d_physics/layer_2="ConnectAreas"
3d_physics/layer_3="Marbles"
3d_physics/layer_4="Boosts"

[physics]

Expand Down
6 changes: 5 additions & 1 deletion scenes/blocks/forward_down.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=7 format=3 uid="uid://h3dbn48vuyv4"]
[gd_scene load_steps=8 format=3 uid="uid://h3dbn48vuyv4"]

[ext_resource type="Script" path="res://scripts/blocks/piece.gd" id="1"]
[ext_resource type="Material" uid="uid://be05svsycj308" path="res://resources/materials/piece.tres" id="2"]
[ext_resource type="ArrayMesh" uid="uid://1na70ao3gxxv" path="res://assets/blocks/forward_down.obj" id="3"]
[ext_resource type="Script" path="res://scripts/blocks/checkpoint.gd" id="4"]
[ext_resource type="PackedScene" uid="uid://768qm8vsl1un" path="res://scenes/boost.tscn" id="5_ppdv3"]

[sub_resource type="ConcavePolygonShape3D" id="1"]
data = PackedVector3Array(-0.7391, -0.3061, -1, -0.9239, -0.3827, -1, -0.6652, -0.4445, -1, -0.6652, -0.4445, -1, -0.9239, -0.3827, -1, -0.8315, -0.5556, -1, 0.1561, -0.7846, -1, 0.1951, -0.9808, -1, 0.3061, -0.7391, -1, 0.3061, -0.7391, -1, 0.1951, -0.9808, -1, 0.3827, -0.9239, -1, -0.7846, -0.1561, -1, -0.9808, -0.1951, -1, -0.7391, -0.3061, -1, -0.7391, -0.3061, -1, -0.9808, -0.1951, -1, -0.9239, -0.3827, -1, 0, -0.8, -1, 0, -1, -1, 0.1561, -0.7846, -1, 0.1561, -0.7846, -1, 0, -1, -1, 0.1951, -0.9808, -1, 0.7846, -0.1561, -1, 0.9808, -0.1951, -1, 0.8, 0, -1, 0.8, 0, -1, 0.9808, -0.1951, -1, 1, 0, -1, -0.8, 0, -1, -1, 0, -1, -0.7846, -0.1561, -1, -0.7846, -0.1561, -1, -1, 0, -1, -0.9808, -0.1951, -1, -0.1561, -0.7846, -1, -0.1951, -0.9808, -1, 0, -0.8, -1, 0, -0.8, -1, -0.1951, -0.9808, -1, 0, -1, -1, 0.7391, -0.3061, -1, 0.9239, -0.3827, -1, 0.7846, -0.1561, -1, 0.7846, -0.1561, -1, 0.9239, -0.3827, -1, 0.9808, -0.1951, -1, -0.3061, -0.7391, -1, -0.3827, -0.9239, -1, -0.1561, -0.7846, -1, -0.1561, -0.7846, -1, -0.3827, -0.9239, -1, -0.1951, -0.9808, -1, 0.6652, -0.4445, -1, 0.8315, -0.5556, -1, 0.7391, -0.3061, -1, 0.7391, -0.3061, -1, 0.8315, -0.5556, -1, 0.9239, -0.3827, -1, -0.4445, -0.6652, -1, -0.5556, -0.8315, -1, -0.3061, -0.7391, -1, -0.3061, -0.7391, -1, -0.5556, -0.8315, -1, -0.3827, -0.9239, -1, 0.5657, -0.5657, -1, 0.7071, -0.7071, -1, 0.6652, -0.4445, -1, 0.6652, -0.4445, -1, 0.7071, -0.7071, -1, 0.8315, -0.5556, -1, -0.5657, -0.5657, -1, -0.7071, -0.7071, -1, -0.4445, -0.6652, -1, -0.4445, -0.6652, -1, -0.7071, -0.7071, -1, -0.5556, -0.8315, -1, 0.4445, -0.6652, -1, 0.5556, -0.8315, -1, 0.5657, -0.5657, -1, 0.5657, -0.5657, -1, 0.5556, -0.8315, -1, 0.7071, -0.7071, -1, -0.6652, -0.4445, -1, -0.8315, -0.5556, -1, -0.5657, -0.5657, -1, -0.5657, -0.5657, -1, -0.8315, -0.5556, -1, -0.7071, -0.7071, -1, 0.3061, -0.7391, -1, 0.3827, -0.9239, -1, 0.4445, -0.6652, -1, 0.4445, -0.6652, -1, 0.3827, -0.9239, -1, 0.5556, -0.8315, -1, -0.8315, -1.5556, 3, -0.9239, -1.3827, 3, -0.6652, -1.4445, 3, -0.6652, -1.4445, 3, -0.9239, -1.3827, 3, -0.7391, -1.3061, 3, 0.3827, -1.9239, 3, 0.1951, -1.9808, 3, 0.3061, -1.7391, 3, 0.3061, -1.7391, 3, 0.1951, -1.9808, 3, 0.1561, -1.7846, 3, -0.9239, -1.3827, 3, -0.9808, -1.1951, 3, -0.7391, -1.3061, 3, -0.7391, -1.3061, 3, -0.9808, -1.1951, 3, -0.7846, -1.1561, 3, 0.1951, -1.9808, 3, 0, -2, 3, 0.1561, -1.7846, 3, 0.1561, -1.7846, 3, 0, -2, 3, 0, -1.8, 3, 1, -1, 3, 0.9808, -1.1951, 3, 0.8, -1, 3, 0.8, -1, 3, 0.9808, -1.1951, 3, 0.7846, -1.1561, 3, -0.9808, -1.1951, 3, -1, -1, 3, -0.7846, -1.1561, 3, -0.7846, -1.1561, 3, -1, -1, 3, -0.8, -1, 3, 0, -2, 3, -0.1951, -1.9808, 3, 0, -1.8, 3, 0, -1.8, 3, -0.1951, -1.9808, 3, -0.1561, -1.7846, 3, 0.9808, -1.1951, 3, 0.9239, -1.3827, 3, 0.7846, -1.1561, 3, 0.7846, -1.1561, 3, 0.9239, -1.3827, 3, 0.7391, -1.3061, 3, -0.1951, -1.9808, 3, -0.3827, -1.9239, 3, -0.1561, -1.7846, 3, -0.1561, -1.7846, 3, -0.3827, -1.9239, 3, -0.3061, -1.7391, 3, 0.9239, -1.3827, 3, 0.8315, -1.5556, 3, 0.7391, -1.3061, 3, 0.7391, -1.3061, 3, 0.8315, -1.5556, 3, 0.6652, -1.4445, 3, -0.3827, -1.9239, 3, -0.5556, -1.8315, 3, -0.3061, -1.7391, 3, -0.3061, -1.7391, 3, -0.5556, -1.8315, 3, -0.4445, -1.6652, 3, 0.8315, -1.5556, 3, 0.7071, -1.7071, 3, 0.6652, -1.4445, 3, 0.6652, -1.4445, 3, 0.7071, -1.7071, 3, 0.5657, -1.5657, 3, -0.5556, -1.8315, 3, -0.7071, -1.7071, 3, -0.4445, -1.6652, 3, -0.4445, -1.6652, 3, -0.7071, -1.7071, 3, -0.5657, -1.5657, 3, 0.7071, -1.7071, 3, 0.5556, -1.8315, 3, 0.5657, -1.5657, 3, 0.5657, -1.5657, 3, 0.5556, -1.8315, 3, 0.4445, -1.6652, 3, -0.7071, -1.7071, 3, -0.8315, -1.5556, 3, -0.5657, -1.5657, 3, -0.5657, -1.5657, 3, -0.8315, -1.5556, 3, -0.6652, -1.4445, 3, 0.5556, -1.8315, 3, 0.3827, -1.9239, 3, 0.4445, -1.6652, 3, 0.4445, -1.6652, 3, 0.3827, -1.9239, 3, 0.3061, -1.7391, 3, 0.7071, -0.7071, -1, 0.5556, -0.8315, -1, 0.7071, -1.7071, 3, 0.7071, -1.7071, 3, 0.5556, -0.8315, -1, 0.5556, -1.8315, 3, -0.1561, -0.7846, -1, 0, -0.8, -1, -0.1561, -1.7846, 3, -0.1561, -1.7846, 3, 0, -0.8, -1, 0, -1.8, 3, 0.5556, -0.8315, -1, 0.3827, -0.9239, -1, 0.5556, -1.8315, 3, 0.5556, -1.8315, 3, 0.3827, -0.9239, -1, 0.3827, -1.9239, 3, 0, -0.8, -1, 0.1561, -0.7846, -1, 0, -1.8, 3, 0, -1.8, 3, 0.1561, -0.7846, -1, 0.1561, -1.7846, 3, 0.3827, -0.9239, -1, 0.1951, -0.9808, -1, 0.3827, -1.9239, 3, 0.3827, -1.9239, 3, 0.1951, -0.9808, -1, 0.1951, -1.9808, 3, 0.1561, -0.7846, -1, 0.3061, -0.7391, -1, 0.1561, -1.7846, 3, 0.1561, -1.7846, 3, 0.3061, -0.7391, -1, 0.3061, -1.7391, 3, 0.1951, -0.9808, -1, 0, -1, -1, 0.1951, -1.9808, 3, 0.1951, -1.9808, 3, 0, -1, -1, 0, -2, 3, 0.3061, -0.7391, -1, 0.4445, -0.6652, -1, 0.3061, -1.7391, 3, 0.3061, -1.7391, 3, 0.4445, -0.6652, -1, 0.4445, -1.6652, 3, 0, -1, -1, -0.1951, -0.9808, -1, 0, -2, 3, 0, -2, 3, -0.1951, -0.9808, -1, -0.1951, -1.9808, 3, 0.4445, -0.6652, -1, 0.5657, -0.5657, -1, 0.4445, -1.6652, 3, 0.4445, -1.6652, 3, 0.5657, -0.5657, -1, 0.5657, -1.5657, 3, 0.8, 0, -1, 1, 0, -1, 0.8, -1, 3, 0.8, -1, 3, 1, 0, -1, 1, -1, 3, -0.1951, -0.9808, -1, -0.3827, -0.9239, -1, -0.1951, -1.9808, 3, -0.1951, -1.9808, 3, -0.3827, -0.9239, -1, -0.3827, -1.9239, 3, 0.5657, -0.5657, -1, 0.6652, -0.4445, -1, 0.5657, -1.5657, 3, 0.5657, -1.5657, 3, 0.6652, -0.4445, -1, 0.6652, -1.4445, 3, -0.3827, -0.9239, -1, -0.5556, -0.8315, -1, -0.3827, -1.9239, 3, -0.3827, -1.9239, 3, -0.5556, -0.8315, -1, -0.5556, -1.8315, 3, 0.6652, -0.4445, -1, 0.7391, -0.3061, -1, 0.6652, -1.4445, 3, 0.6652, -1.4445, 3, 0.7391, -0.3061, -1, 0.7391, -1.3061, 3, -1, 0, -1, -0.8, 0, -1, -1, -1, 3, -1, -1, 3, -0.8, 0, -1, -0.8, -1, 3, -0.8, 0, -1, -0.7846, -0.1561, -1, -0.8, -1, 3, -0.8, -1, 3, -0.7846, -0.1561, -1, -0.7846, -1.1561, 3, -0.5556, -0.8315, -1, -0.7071, -0.7071, -1, -0.5556, -1.8315, 3, -0.5556, -1.8315, 3, -0.7071, -0.7071, -1, -0.7071, -1.7071, 3, 0.7391, -0.3061, -1, 0.7846, -0.1561, -1, 0.7391, -1.3061, 3, 0.7391, -1.3061, 3, 0.7846, -0.1561, -1, 0.7846, -1.1561, 3, -0.7846, -0.1561, -1, -0.7391, -0.3061, -1, -0.7846, -1.1561, 3, -0.7846, -1.1561, 3, -0.7391, -0.3061, -1, -0.7391, -1.3061, 3, -0.7071, -0.7071, -1, -0.8315, -0.5556, -1, -0.7071, -1.7071, 3, -0.7071, -1.7071, 3, -0.8315, -0.5556, -1, -0.8315, -1.5556, 3, 0.7846, -0.1561, -1, 0.8, 0, -1, 0.7846, -1.1561, 3, 0.7846, -1.1561, 3, 0.8, 0, -1, 0.8, -1, 3, -0.7391, -0.3061, -1, -0.6652, -0.4445, -1, -0.7391, -1.3061, 3, -0.7391, -1.3061, 3, -0.6652, -0.4445, -1, -0.6652, -1.4445, 3, -0.8315, -0.5556, -1, -0.9239, -0.3827, -1, -0.8315, -1.5556, 3, -0.8315, -1.5556, 3, -0.9239, -0.3827, -1, -0.9239, -1.3827, 3, 1, 0, -1, 0.9808, -0.1951, -1, 1, -1, 3, 1, -1, 3, 0.9808, -0.1951, -1, 0.9808, -1.1951, 3, -0.6652, -0.4445, -1, -0.5657, -0.5657, -1, -0.6652, -1.4445, 3, -0.6652, -1.4445, 3, -0.5657, -0.5657, -1, -0.5657, -1.5657, 3, -0.9239, -0.3827, -1, -0.9808, -0.1951, -1, -0.9239, -1.3827, 3, -0.9239, -1.3827, 3, -0.9808, -0.1951, -1, -0.9808, -1.1951, 3, 0.9808, -0.1951, -1, 0.9239, -0.3827, -1, 0.9808, -1.1951, 3, 0.9808, -1.1951, 3, 0.9239, -0.3827, -1, 0.9239, -1.3827, 3, -0.5657, -0.5657, -1, -0.4445, -0.6652, -1, -0.5657, -1.5657, 3, -0.5657, -1.5657, 3, -0.4445, -0.6652, -1, -0.4445, -1.6652, 3, -0.9808, -0.1951, -1, -1, 0, -1, -0.9808, -1.1951, 3, -0.9808, -1.1951, 3, -1, 0, -1, -1, -1, 3, 0.9239, -0.3827, -1, 0.8315, -0.5556, -1, 0.9239, -1.3827, 3, 0.9239, -1.3827, 3, 0.8315, -0.5556, -1, 0.8315, -1.5556, 3, -0.4445, -0.6652, -1, -0.3061, -0.7391, -1, -0.4445, -1.6652, 3, -0.4445, -1.6652, 3, -0.3061, -0.7391, -1, -0.3061, -1.7391, 3, 0.8315, -0.5556, -1, 0.7071, -0.7071, -1, 0.8315, -1.5556, 3, 0.8315, -1.5556, 3, 0.7071, -0.7071, -1, 0.7071, -1.7071, 3, -0.3061, -0.7391, -1, -0.1561, -0.7846, -1, -0.3061, -1.7391, 3, -0.3061, -1.7391, 3, -0.1561, -0.7846, -1, -0.1561, -1.7846, 3)
Expand Down Expand Up @@ -44,3 +45,6 @@ shape = SubResource("2")

[node name="Position3D" type="Marker3D" parent="Positions"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14304, 1)

[node name="Boost" parent="." instance=ExtResource("5_ppdv3")]
transform = Transform3D(3, 0, 0, 0, 3, 0, 0, 0, 3, 0, -0.5, 1)
6 changes: 5 additions & 1 deletion scenes/blocks/turn_left_2.tscn

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion scenes/blocks/turn_left_3.tscn

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion scenes/blocks/turn_right_2.tscn

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion scenes/blocks/turn_right_3.tscn

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions scenes/boost.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[gd_scene load_steps=7 format=3 uid="uid://768qm8vsl1un"]

[ext_resource type="Shader" path="res://shaders/energy_shield.gdshader" id="1_gmgfm"]
[ext_resource type="Script" path="res://scripts/boost.gd" id="1_rrijl"]
[ext_resource type="AudioStream" uid="uid://5o2mnxsagwq1" path="res://assets/sounds/boost.ogg" id="3_serww"]

[sub_resource type="SphereMesh" id="SphereMesh_yntlh"]
radial_segments = 8
rings = 4

[sub_resource type="ShaderMaterial" id="ShaderMaterial_nfirf"]
render_priority = 0
shader = ExtResource("1_gmgfm")
shader_parameter/_shield_color = Color(0, 0, 1, 1)
shader_parameter/_shield_color_brightness = 10.0
shader_parameter/_shield_intensity = 2.0
shader_parameter/_rotation = Vector3(0.1, 0, 0)
shader_parameter/_shield_size = 0.0
shader_parameter/_shield_pulse_frequency = 1.0
shader_parameter/_shield_pulse_density = 1.0
shader_parameter/_shield_pulse_amplitude = 1.0
shader_parameter/_shield_pulse_blend = 1.0
shader_parameter/_shield_pulse_radius = 1.0
shader_parameter/_impact_origin = Vector3(1, 0, 0)
shader_parameter/_impact_frequency = 5.0
shader_parameter/_impact_density = 5.0
shader_parameter/_impact_amplitude = 6.0
shader_parameter/_impact_blend = 0.0
shader_parameter/_impact_radius = 1.1
shader_parameter/_impact_anim = 0.0

[sub_resource type="SphereShape3D" id="SphereShape3D_hmxdj"]

[node name="Boost" type="Node3D"]
script = ExtResource("1_rrijl")

[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("SphereMesh_yntlh")
surface_material_override/0 = SubResource("ShaderMaterial_nfirf")

[node name="Area3D" type="Area3D" parent="."]
collision_layer = 8
collision_mask = 4
monitorable = false

[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
shape = SubResource("SphereShape3D_hmxdj")

[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("3_serww")
unit_size = 1.0

[connection signal="body_entered" from="Area3D" to="." method="_on_area_3d_body_entered"]
4 changes: 2 additions & 2 deletions scenes/race.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

[ext_resource type="Script" path="res://scripts/race.gd" id="1"]

[sub_resource type="Curve3D" id="Curve3D_f15n6"]
[sub_resource type="Curve3D" id="Curve3D_8pftg"]

[node name="Race" type="Node3D"]
script = ExtResource("1")

[node name="Path" type="Path3D" parent="."]
curve = SubResource("Curve3D_f15n6")
curve = SubResource("Curve3D_8pftg")
2 changes: 1 addition & 1 deletion scripts/blocks/bumper.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class_name Bumper

extends Area3D

var Group := load("res://scripts/constants/groups.gd")
const Group := preload("res://scripts/constants/groups.gd")

@onready var _animation_player := get_node(^"%AnimationPlayer") as AnimationPlayer
@onready var _bump_sound := get_node(^"%BumpSound") as AudioStreamPlayer3D
Expand Down
2 changes: 1 addition & 1 deletion scripts/blocks/checkpoint.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class_name Checkpoint

extends Area3D

var Group := load("res://scripts/constants/groups.gd")
const Group := preload("res://scripts/constants/groups.gd")

var _marbles: PackedStringArray = []

Expand Down
2 changes: 1 addition & 1 deletion scripts/blocks/finish_line.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class_name FinishLine

extends Area3D

var Group := load("res://scripts/constants/groups.gd")
const Group := preload("res://scripts/constants/groups.gd")

@onready var _player := get_node(^"%Sound") as AudioStreamPlayer3D

Expand Down
3 changes: 1 addition & 2 deletions scripts/blocks/piece.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ extends StaticBody3D

const CollisionLayers := preload("res://scripts/constants/collision_layers.gd")
const DefaultPieceMaterial := preload("res://resources/materials/piece.tres")
const Group := preload("res://scripts/constants/groups.gd")

@export var empty_material_override := false

var Group := load("res://scripts/constants/groups.gd")

@onready var _begin_area := get_node(^"%BeginArea") as Area3D
@onready var _end_area := get_node(^"%EndArea") as Area3D

Expand Down
34 changes: 34 additions & 0 deletions scripts/boost.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@tool
extends Node3D

const Group := preload("res://scripts/constants/groups.gd")
const CollisionLayers := preload("res://scripts/constants/collision_layers.gd")

@export var active: bool:
set = activate,
get = is_activated

@onready var area: Area3D = get_node(^"Area3D")
@onready var audio: AudioStreamPlayer3D = get_node(^"AudioStreamPlayer3D")


func _ready():
activate(false)

area.collision_layer = 1 << CollisionLayers.BOOSTS
area.collision_mask = 1 << CollisionLayers.MARBLES


func activate(val) -> void:
set_visible(val)
area.set_monitoring(val)


func is_activated() -> bool:
return is_visible()


func _on_area_3d_body_entered(body):
if body.is_in_group(Group.MARBLES):
body.linear_velocity *= 2
audio.play()
1 change: 1 addition & 0 deletions scripts/constants/collision_layers.gd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const PROPS := 0
const CONNECTION_AREAS := 1
const MARBLES := 2
const BOOSTS := 3
3 changes: 1 addition & 2 deletions scripts/gui/overlay.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ class_name Overlay
extends Control

const Participant := preload("res://scenes/gui/participant.tscn")

var Group := load("res://scripts/constants/groups.gd")
const Group := preload("res://scripts/constants/groups.gd")

@onready var _ranking := get_node(^"%Ranking") as Ranking
@onready var _marble_pool = get_tree().get_nodes_in_group(&"marble_pool")[0]
Expand Down
3 changes: 1 addition & 2 deletions scripts/gui/participant.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const IconConfetti := preload("res://assets/icons/icons8-confetti-100.png")
const IconTrophy := preload("res://assets/icons/icons8-trophy-100.png")
const IconBang := preload("res://assets/icons/icons8-bang-100.png")
const IconSkull := preload("res://assets/icons/icons8-skull-100.png")

var Group := load("res://scripts/constants/groups.gd")
const Group := preload("res://scripts/constants/groups.gd")

var _marble: Marble = null
var _last_rank := -1
Expand Down
5 changes: 2 additions & 3 deletions scripts/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ enum State { MODE_START, MODE_PAUSE, MODE_MARBLE }
const RotationCamera := preload("res://scenes/camera/rotation_camera.tscn")
const CinematicCamera := preload("res://scenes/camera/marble_camera.tscn")
const Race := preload("res://scenes/race.tscn")
const Group := preload("res://scripts/constants/groups.gd")
const NameGenerator := preload("res://scripts/utils/name_generator.gd")

const TIME_PERIOD := 5 # 500ms

var Group := load("res://scripts/constants/groups.gd")
var NameGenerator := load("res://scripts/utils/name_generator.gd")

var _rotation_camera = null
var _cinematic_camera = null
var _mode: int = State.MODE_START
Expand Down
9 changes: 9 additions & 0 deletions scripts/race.gd
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ func place_piece(piece_index: int) -> void:
rotate_piece(piece)
translate_piece(piece)

randomize_boost(piece)

# Store data for next piece and positions for the race path
store_piece_data(piece, piece_data)
store_piece_positions(piece)
Expand Down Expand Up @@ -152,6 +154,13 @@ func calculate_translation_offset(piece: Piece) -> Vector3:
return offset


# Function to enable randomly boost on the piece
func randomize_boost(piece: Piece) -> void:
var boost = piece.get_node_or_null("Boost")
if boost and randf() > 0.5:
boost.activate(true)


# Function to store data for the next piece
func store_piece_data(piece: Piece, piece_data: Dictionary) -> void:
_previous_piece = piece
Expand Down
Loading
Loading