Skip to content

Commit

Permalink
custom light sabers, bigger hitboxes and more small improvements (#13)
Browse files Browse the repository at this point in the history
* costomizable light sabers, bigger hitboxes

* cut sound is now part of the sword

* improved custom sabers, brighter cubes

* minor improvements

* use signals instead of calling methods on saber models

* use preview data to preview song with smooth transitions

* fix bug were disabling cutted blocks only worked on half of the blocks

* sync cut sound to cube beat

* remove unnecesary duplicated code

* separate cube collider layers to make harder to hit the wrong note

* fix tiny cubes bug (fixes #14)
  • Loading branch information
leandrodreamer authored May 24, 2021
1 parent ef8b2b8 commit c1c0813
Show file tree
Hide file tree
Showing 33 changed files with 1,253 additions and 302 deletions.
45 changes: 23 additions & 22 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,50 @@ export_filter="all_resources"
include_filter="*oculussig_*, *.dat, *.json, *.egg"
exclude_filter=""
export_path="src_data/exports/godot_beep_saber_0.3.1.apk"
patch_list=PoolStringArray( )
script_export_mode=0
script_encryption_key=""

[preset.0.options]

graphics/32_bits_framebuffer=false
xr_features/xr_mode=1
xr_features/degrees_of_freedom=1
xr_features/hand_tracking=1
xr_features/focus_awareness=true
one_click_deploy/clear_previous_install=false
custom_template/debug="bin/android_debug.apk"
custom_template/release=""
custom_template/use_custom_build=false
custom_template/export_format=0
architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
keystore/debug="bin/debug.keystore"
keystore/debug_user="androiddebugkey"
keystore/debug_password="android"
keystore/release=""
keystore/release_user=""
keystore/release_password=""
one_click_deploy/clear_previous_install=false
command_line/extra_args=""
version/code=3
version/name="0.3.1"
package/unique_name="org.dammertz.vr.godot_beep_saber"
package/name="Godot Beep Saber 0.3.1"
package/signed=true
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
launcher_icons/adaptive_background_432x432=""
graphics/32_bits_framebuffer=false
graphics/opengl_debug=false
xr_features/xr_mode=1
xr_features/degrees_of_freedom=1
xr_features/hand_tracking=1
xr_features/focus_awareness=true
screen/immersive_mode=true
screen/orientation=0
screen/support_small=true
screen/support_normal=true
screen/support_large=true
screen/support_xlarge=true
command_line/extra_args=""
screen/opengl_debug=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
launcher_icons/adaptive_background_432x432=""
keystore/debug="bin/debug.keystore"
keystore/debug_user="androiddebugkey"
keystore/debug_password="android"
keystore/release=""
keystore/release_user=""
keystore/release_password=""
apk_expansion/enable=false
apk_expansion/SALT=""
apk_expansion/public_key=""
architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
permissions/custom_permissions=PoolStringArray( )
permissions/access_checkin_properties=false
permissions/access_coarse_location=false
Expand Down
10 changes: 9 additions & 1 deletion game/BeepCube.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ onready var _mesh_instance : MeshInstance = $CubeMeshOrientation/CubeMeshAnimati
var _mesh : Mesh = null;
var _mat = null;
var speed = 1.0;
export var min_speed = 0.5;

func _ready():
_mesh = _mesh_instance.mesh;
_mat = _mesh_instance.material_override;
# play the spawn animation when this cube enters the scene
_anim.playback_speed = speed
_anim.playback_speed = max(min_speed,speed)
_anim.play("Spawn");

#separates cube collision layers to allow a diferent collider on right/wrong cuts
yield(get_tree(),"physics_frame")
$CubeMeshOrientation/BeepCube_Big.set_collision_mask_bit(4,!bool(_note._type))
$CubeMeshOrientation/BeepCube_Big.set_collision_mask_bit(14,bool(_note._type))
$CubeMeshOrientation/BeepCube_Small.set_collision_mask_bit(4,bool(_note._type))
$CubeMeshOrientation/BeepCube_Small.set_collision_mask_bit(14,!bool(_note._type))

func duplicate_create(color : Color):
var mi = $CubeMeshOrientation/CubeMeshAnimation/BeepCube_Mesh;
Expand Down
24 changes: 18 additions & 6 deletions game/BeepCube.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=7 format=2]

[ext_resource path="res://game/data/BeepCube.mesh" type="ArrayMesh" id=1]
[ext_resource path="res://game/BeepCube.gd" type="Script" id=2]
[ext_resource path="res://game/BeepCube_new_material.material" type="Material" id=3]

[sub_resource type="BoxShape" id=1]
extents = Vector3( 0.28, 0.2, 0.458049 )

[sub_resource type="BoxShape" id=2]
extents = Vector3( 0.2, 0.2, 0.2 )

[sub_resource type="Animation" id=2]
[sub_resource type="Animation" id=3]
length = 0.8
tracks/0/type = "value"
tracks/0/path = NodePath(".:translation")
Expand Down Expand Up @@ -51,15 +54,24 @@ script = ExtResource( 2 )

[node name="CubeMeshOrientation" type="Spatial" parent="."]

[node name="BeepCube_Area" type="Area" parent="CubeMeshOrientation" groups=[
[node name="BeepCube_Big" type="Area" parent="CubeMeshOrientation" groups=[
"beepcube",
]]
collision_layer = 2
collision_mask = 16
collision_mask = 16400

[node name="CollisionShape" type="CollisionShape" parent="CubeMeshOrientation/BeepCube_Area"]
[node name="CollisionBig" type="CollisionShape" parent="CubeMeshOrientation/BeepCube_Big"]
shape = SubResource( 1 )

[node name="BeepCube_Small" type="Area" parent="CubeMeshOrientation" groups=[
"beepcube",
]]
collision_layer = 2
collision_mask = 16400

[node name="CollisionSmall" type="CollisionShape" parent="CubeMeshOrientation/BeepCube_Small"]
shape = SubResource( 2 )

[node name="CubeMeshAnimation" type="Spatial" parent="CubeMeshOrientation"]

[node name="BeepCube_Mesh" type="MeshInstance" parent="CubeMeshOrientation/CubeMeshAnimation"]
Expand All @@ -69,4 +81,4 @@ mesh = ExtResource( 1 )
material/0 = null

[node name="AnimationPlayer" type="AnimationPlayer" parent="CubeMeshOrientation/CubeMeshAnimation"]
anims/Spawn = SubResource( 2 )
anims/Spawn = SubResource( 3 )
Binary file modified game/BeepCube_new_material.material
Binary file not shown.
35 changes: 31 additions & 4 deletions game/BeepSaberMainMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ var _map_id = null;
var _map_info = null;
var _map_path = null;

onready var song_prev = $song_prev
onready var song_prev_Tween = $song_prev/Tween
var song_prev_lastid = -1
var song_prev_transition_time = 1.0

func _select_song(id):
if id is int:
$SongsMenu.select(id)
Expand Down Expand Up @@ -189,15 +194,36 @@ func _select_song(id):
_select_difficulty(0)

#preview song
$song_prev.stop()
if song_prev.playing:
song_prev_Tween.stop_all()
song_prev_Tween.interpolate_property(song_prev,"volume_db",
song_prev.volume_db, -50, song_prev_transition_time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
song_prev_Tween.start()
yield(get_tree().create_timer(song_prev_transition_time),"timeout")
song_prev.stop()
if not _beepsaber.song_player.playing:
var snd_file = File.new()
snd_file.open(_map_info._path + _map_info._songFilename, File.READ) #works whether it's a resource or a file
snd_file.open(_map_info._path + _map_info._songFilename, File.READ)
var stream = AudioStreamOGGVorbis.new()
stream.data = snd_file.get_buffer(snd_file.get_len())
snd_file.close()
$song_prev.stream = stream;
$song_prev.play()
song_prev.stream = stream;

song_prev_Tween.stop_all()
song_prev_Tween.interpolate_property(song_prev,"volume_db",
song_prev.volume_db, 0, song_prev_transition_time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
song_prev_Tween.start()

song_prev.play(float(_map_info._previewStartTime))
$song_prev/stop_prev.start(float(_map_info._previewDuration))

func _on_stop_prev_timeout():
song_prev_Tween.stop_all()
song_prev_Tween.interpolate_property(song_prev,"volume_db",
song_prev.volume_db, -50, song_prev_transition_time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
song_prev_Tween.start()
yield(get_tree().create_timer(song_prev_transition_time),"timeout")
song_prev.stop()


var _map_difficulty = 0
Expand Down Expand Up @@ -364,3 +390,4 @@ func _clean_search():




7 changes: 7 additions & 0 deletions game/BeepSaberMainMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ __meta__ = {
}

[node name="song_prev" type="AudioStreamPlayer" parent="."]
volume_db = -60.0

[node name="Tween" type="Tween" parent="song_prev"]

[node name="stop_prev" type="Timer" parent="song_prev"]
one_shot = true
[connection signal="pressed" from="Play_Button" to="." method="_on_Play_Button_pressed"]
[connection signal="button_up" from="Delete_Button" to="." method="_on_Delete_Button_button_up"]
[connection signal="pressed" from="Exit_Button" to="." method="_on_Exit_Button_pressed"]
Expand All @@ -249,3 +255,4 @@ __meta__ = {
[connection signal="item_selected" from="DifficultyMenu" to="." method="_select_difficulty"]
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
[connection signal="pressed" from="LoadPlaylists_Button" to="." method="_on_LoadPlaylists_Button_pressed"]
[connection signal="timeout" from="song_prev/stop_prev" to="." method="_on_stop_prev_timeout"]
15 changes: 11 additions & 4 deletions game/BeepSaber_Game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ func _spawn_cube(note, current_beat):
else:
return;

cube.speed = float(menu._map_difficulty_noteJumpMovementSpeed)/9
if menu._map_difficulty_noteJumpMovementSpeed > 0:
cube.speed = float(menu._map_difficulty_noteJumpMovementSpeed)/9
track.add_child(cube);

var line = -(CUBE_DISTANCE * 3.0 / 2.0) + note._lineIndex * CUBE_DISTANCE;
Expand Down Expand Up @@ -422,7 +423,7 @@ func disable_events(disabled):
# cut the cube by creating two rigid bodies and using a CSGBox to create
# the cut plane
func _create_cut_rigid_body(_sign, cube : Spatial, cutplane : Plane, cut_distance, controller_speed, saber_ends):
if not cube_cuts_falloff and _sign == 1:
if not cube_cuts_falloff:
return
#remove cutted cubes when there are more than max_cutted_cubes
var cutted_cubes_group = get_tree().get_nodes_in_group("cutted_cube")
Expand Down Expand Up @@ -498,7 +499,10 @@ func _update_points_from_cut(saber, cube, beat_accuracy, cut_angle_accuracy, cut
#if (beat_accuracy == 0.0 || cut_angle_accuracy == 0.0 || cut_distance_accuracy == 0.0):
# _reset_combo();
# return;


#send data to saber for esthetics effects
saber.hit(cube)

# check if we hit the cube with the correctly colored saber
if (saber.type != cube._note._type):
_reset_combo();
Expand Down Expand Up @@ -527,6 +531,7 @@ func _update_points_from_cut(saber, cube, beat_accuracy, cut_angle_accuracy, cut
_wrong_notes += 1.0-normalized_points;

_display_points();



func _display_points():
Expand Down Expand Up @@ -589,7 +594,7 @@ func _quiet_song():
# restores song volume when player leaves wall
func _louden_song():
song_player.volume_db = 0.0;

func _on_LeftLightSaber_area_entered(area : Area):
if song_player.playing and (area.is_in_group("beepcube")):
_cut_cube(left_controller, left_saber, area.get_parent().get_parent());
Expand Down Expand Up @@ -645,3 +650,5 @@ func _on_Pause_Panel_continue_button():
$Pause_countdown.visible = false
continue_map()



4 changes: 3 additions & 1 deletion game/BeepSaber_Game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ glow_blend_mode = 0
[sub_resource type="SphereShape" id=2]
radius = 0.07

[node name="BeepSaber" type="Spatial"]
[node name="BeepSaber" type="Spatial" groups=[
"main_game",
]]
script = ExtResource( 9 )

[node name="WorldEnvironment" type="WorldEnvironment" parent="." groups=[
Expand Down
Loading

0 comments on commit c1c0813

Please sign in to comment.