Skip to content

Commit

Permalink
Minor fixes and New design approach to tutorial (#10)
Browse files Browse the repository at this point in the history
* Fixed #6

Seems to be exactly as though, remember to not use Godot bultin `ui_actions` for anything that is not an UI interaction

* Changed tutorial to behave like a key binding setting

Players now can choose which keys will be used for playing the flute.

Will, from bass to tremble, be the first three keys pressed by the player.

Still has to fix bard.gd behavior

* Fixed #8

Now the player also uses the same logic, no events are set to "interact" action by default, they are set during tutorial_screen.tscn

* Not sure it this fixes #9 but at least clear some mess
  • Loading branch information
henriiquecampos committed Mar 6, 2018
1 parent 03d316e commit 5b5c3ce
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 299 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
*.sample
*.oggstr
export_presets.cfg
*.pck
*.pck
export_presets.cfg
101 changes: 47 additions & 54 deletions actors/player/bard/bard.gd
Original file line number Diff line number Diff line change
@@ -1,73 +1,27 @@
extends "res://actors/player/player_character.gd"

const PITCHES = [1.0, 1.25, 1.50]
var object = null
const NOTE = preload("res://interface/note_duration/note.tscn")
var note = null
enum KEYS{Z, X, C}
var key = 0
var check = false

signal played_note(pitch, duration)

func _ready():
connect("played_note", get_tree().get_nodes_in_group("staff")[0], "add_note")
func _process(delta):
#Start the interaction if it can, then check for which pitch the
#player is trying to use in the interaction
if Input.is_action_just_pressed("interact") and current_state != JUMP:
can_move = false
$Animator.play("flute")
var pitch = 0.0
note = NOTE.instance()
note.position += Vector2(32, -150)
if Input.is_key_pressed(KEY_Z):
note.set_modulate(note.COLORS[Z])
pitch = 1.0
key = Z
elif Input.is_key_pressed(KEY_X):
note.set_modulate(note.COLORS[X])
pitch = 1.25
key = X
elif Input.is_key_pressed(KEY_C):
note.set_modulate(note.COLORS[C])
pitch = 1.50
key = C
add_child(note)
interact(pitch)
if object != null:
check = check_pitch(pitch, object.pitch)
if !check:
miss()
object.miss()

if Input.is_action_just_released("interact"):
can_move = true
if note == null:
return
var pitch = key
var duration = note.duration
note.finished()
note = null

if object != null:
if check_duration(duration, object.note_duration) and check:
success()
object.success()
emit_signal("played_note", pitch, duration)
elif check:
miss()
object.miss()
object = null
else:
resume()

func interact(p):
#Access the pitch effect and modify it based on the pitch the player
#is using in the interaction
var bus = AudioServer.get_bus_index($Flute.get_bus())
var fx = AudioServer.get_bus_effect(bus, 0)
fx.set_pitch_scale(p)
fx.set_pitch_scale(PITCHES[p])
$Flute.play()
if object != null:
check = check_pitch(PITCHES[p], object.pitch)
if !check:
# miss()
object.miss()

func resume():
#Returns the character to it's rest/idle position and re-enable its
Expand Down Expand Up @@ -101,4 +55,43 @@ func check_duration(player, other):
if player == other:
return(true)
else:
return(false)
return(false)

func _input(event):
if !(event is InputEventKey):
return
var p = 0

for e in InputMap.get_action_list("interact"):
if e.as_text() == event.as_text():
p = (InputMap.get_action_list("interact").find(e))

if event.is_action_pressed("interact") and current_state != JUMP:
can_move = false
$Animator.play("flute")
interact(p)
note = NOTE.instance()
note.position += Vector2(32, -150)
add_child(note)
note.set_modulate(note.COLORS[p])

elif event.is_action_released("interact"):
$Flute.stop()
can_move = true
if note == null:
return
var duration = note.duration
note.finished()
note = null

if object != null:
if check_duration(duration, object.note_duration) and check:
success()
object.success()
emit_signal("played_note", p, duration)
else:
miss()
object.miss()
else:
resume()

1 change: 1 addition & 0 deletions interface/staff/staff.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends HBoxContainer
const COLORS = [Color("bc5fd3"), Color("8d5fd3"), Color("37c871")]
const DURATIONS = [preload("res://interface/note_duration/16.png"),
preload("res://interface/note_duration/8.png"), preload("res://interface/note_duration/4.png")]

func add_note(pitch, duration):
var t = TextureRect.new()
if duration == 16:
Expand Down
10 changes: 7 additions & 3 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ timers/tooltip_delay_sec=0.5

[input]

interact=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"unicode":0,"echo":false,"script":null)
interact=[ ]
walk_left=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
]
walk_right=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
]
jump=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
]
walk_left=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
]
Expand Down
6 changes: 6 additions & 0 deletions screens/credit_screen/credit_screen.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends "res://screens/basic_screen.gd"

func _process(delta):
$"CreditsViewport/ParallaxBackground/ParallaxLayer".motion_offset.y -= 30 * delta
if Input.is_action_just_pressed("interact") or Input.is_action_just_pressed("jump"):
change_scene()
77 changes: 34 additions & 43 deletions screens/credit_screen/credit_screen.tscn
Original file line number Diff line number Diff line change
@@ -1,45 +1,37 @@
[gd_scene load_steps=9 format=2]

[ext_resource path="res://screens/basic_screen.tscn" type="PackedScene" id=1]
[ext_resource path="res://screens/splash_screen/background.png" type="Texture" id=2]
[ext_resource path="res://screens/credit_screen/logo.png" type="Texture" id=3]
[ext_resource path="res://screens/theme.tres" type="Theme" id=4]
[ext_resource path="res://screens/GaroaHackerClubeBold.otf" type="DynamicFontData" id=5]
[ext_resource path="res://screens/credit_screen/credit_screen.gd" type="Script" id=2]
[ext_resource path="res://screens/splash_screen/background.png" type="Texture" id=3]
[ext_resource path="res://screens/credit_screen/logo.png" type="Texture" id=4]
[ext_resource path="res://screens/theme.tres" type="Theme" id=5]
[ext_resource path="res://screens/GaroaHackerClubeBold.otf" type="DynamicFontData" id=6]
[ext_resource path="res://screens/credit_screen/credits_texture.tres" type="Texture" id=7]

[sub_resource type="ViewportTexture" id=3]

resource_local_to_scene = true
flags = 0
viewport_path = NodePath("CreditsViewport")

[sub_resource type="GDScript" id=2]

script/source = "extends ParallaxBackground
signal back
func _process(delta):
$ParallaxLayer.motion_offset.y -= 30 * delta

if Input.is_action_just_pressed(\"interact\") or Input.is_action_just_pressed(\"ui_accept\"):
emit_signal(\"back\")"

[sub_resource type="DynamicFont" id=1]
[sub_resource type="DynamicFont" id=3]

size = 32
use_mipmaps = true
use_filter = true
extra_spacing_top = 4
font_data = ExtResource( 5 )
font_data = ExtResource( 6 )
_sections_unfolded = [ "Extra Spacing", "Font" ]

[node name="CreditScreen" index="0" instance=ExtResource( 1 )]
[node name="CreditScreen" instance=ExtResource( 1 )]

script = ExtResource( 2 )
_sections_unfolded = [ "Rect", "Theme" ]
next_scene = "res://screens/main_screen/main_screen.tscn"

[node name="Transition" parent="." index="1"]

layer = 2

[node name="ColorRect" parent="Transition" index="0"]

margin_left = -1280.0
margin_right = -256.0

[node name="Background" type="TextureRect" parent="." index="2"]

anchor_left = 0.0
Expand All @@ -53,7 +45,7 @@ mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
texture = ExtResource( 2 )
texture = ExtResource( 3 )
stretch_mode = 0
_sections_unfolded = [ "Rect" ]

Expand Down Expand Up @@ -89,7 +81,7 @@ mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 1
texture = ExtResource( 3 )
texture = ExtResource( 4 )
expand = true
stretch_mode = 6
_sections_unfolded = [ "Size Flags" ]
Expand Down Expand Up @@ -260,15 +252,9 @@ lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Size Flags" ]

[node name="Credits" type="Sprite" parent="." index="5"]

position = Vector2( 0, 139 )
texture = SubResource( 3 )
centered = false
_sections_unfolded = [ "Offset" ]

[node name="CreditsViewport" type="Viewport" parent="." index="6"]
[node name="CreditsViewport" type="Viewport" parent="." index="5"]

editor/display_folded = true
arvr = false
size = Vector2( 1024, 360 )
own_world = false
Expand All @@ -279,7 +265,7 @@ hdr = false
disable_3d = true
usage = 0
debug_draw = 0
render_target_v_flip = true
render_target_v_flip = false
render_target_clear_mode = 0
render_target_update_mode = 2
audio_listener_enable_2d = false
Expand All @@ -292,7 +278,7 @@ shadow_atlas_quad_0 = 2
shadow_atlas_quad_1 = 2
shadow_atlas_quad_2 = 3
shadow_atlas_quad_3 = 4
_sections_unfolded = [ "Render Target" ]
_sections_unfolded = [ "Render Target", "Rendering" ]

[node name="ParallaxBackground" type="ParallaxBackground" parent="CreditsViewport" index="0"]

Expand All @@ -307,7 +293,6 @@ scroll_base_scale = Vector2( 1, 1 )
scroll_limit_begin = Vector2( 0, 0 )
scroll_limit_end = Vector2( 0, 0 )
scroll_ignore_camera_zoom = true
script = SubResource( 2 )
_sections_unfolded = [ "Scroll" ]

[node name="ParallaxLayer" type="ParallaxLayer" parent="CreditsViewport/ParallaxBackground" index="0"]
Expand All @@ -331,7 +316,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
theme = ExtResource( 4 )
theme = ExtResource( 5 )
_sections_unfolded = [ "Rect", "Scroll", "Theme" ]

[node name="Categories" type="VBoxContainer" parent="CreditsViewport/ParallaxBackground/ParallaxLayer/Credits" index="0"]
Expand Down Expand Up @@ -364,7 +349,7 @@ mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_fonts/font = SubResource( 1 )
custom_fonts/font = SubResource( 3 )
text = "audio"
align = 1
valign = 1
Expand Down Expand Up @@ -504,7 +489,7 @@ mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_fonts/font = SubResource( 1 )
custom_fonts/font = SubResource( 3 )
text = "design"
align = 1
valign = 1
Expand Down Expand Up @@ -763,7 +748,7 @@ mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_fonts/font = SubResource( 1 )
custom_fonts/font = SubResource( 3 )
text = "engineering"
align = 1
valign = 1
Expand Down Expand Up @@ -845,7 +830,7 @@ mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_fonts/font = SubResource( 1 )
custom_fonts/font = SubResource( 3 )
text = "graphics"
align = 1
valign = 1
Expand Down Expand Up @@ -1163,7 +1148,7 @@ mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_fonts/font = SubResource( 1 )
custom_fonts/font = SubResource( 3 )
text = "special thanks to"
align = 1
valign = 1
Expand Down Expand Up @@ -1197,6 +1182,12 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

[connection signal="back" from="CreditsViewport/ParallaxBackground" to="." method="change_scene"]
[node name="Credits" type="Sprite" parent="." index="6"]

position = Vector2( 0, 139 )
texture = ExtResource( 7 )
centered = false
flip_v = true
_sections_unfolded = [ "Offset" ]


8 changes: 8 additions & 0 deletions screens/credit_screen/credits_texture.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="ViewportTexture" format=2]

[resource]

resource_local_to_scene = true
flags = 0
viewport_path = NodePath("CreditsViewport")

Binary file removed screens/tutorial_screen/c_key.png
Binary file not shown.
Binary file removed screens/tutorial_screen/c_key_pressed.png
Binary file not shown.

0 comments on commit 5b5c3ce

Please sign in to comment.