Skip to content

Commit

Permalink
Added a "null" set to object and note so they lose reference
Browse files Browse the repository at this point in the history
The major problem of #1 is that after the first time the references are set, they won't reset to null, so the check would only happens successfully once. Now this may definitely fix #1

Also cleared the code removing "can_interact" logic, it isn't needed with the new approach
  • Loading branch information
henriiquecampos committed Mar 5, 2018
1 parent 13cd2d1 commit 732de54
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@
*.sample
*.oggstr
export_presets.cfg
*.pck
2 changes: 0 additions & 2 deletions actors/birds/bird.gd
Expand Up @@ -55,7 +55,6 @@ func _on_body_entered(body):
#object to interact with
if body.is_in_group("players"):
sing()
body.can_interact = true
body.object = self

func _on_body_exited( body ):
Expand All @@ -65,7 +64,6 @@ func _on_body_exited( body ):
#Sets the current interact object to be null if players exits its
#area of interaction
if body.is_in_group("players"):
body.can_interact = false
body.object = null

func set_flip_h(value):
Expand Down
8 changes: 4 additions & 4 deletions actors/player/bard/bard.gd
@@ -1,6 +1,5 @@
extends "res://actors/player/player_character.gd"

var can_interact = true
var object = null
const NOTE = preload("res://interface/note_duration/note.tscn")
var note = null
Expand All @@ -15,7 +14,7 @@ func _ready():
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 and can_interact:
if Input.is_action_just_pressed("interact") and current_state != JUMP:
can_move = false
$Animator.play("flute")
var pitch = 0.0
Expand All @@ -40,13 +39,14 @@ func _process(delta):
if !check:
miss()
object.miss()
if Input.is_action_just_released("interact") and can_interact:
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:
Expand All @@ -56,6 +56,7 @@ func _process(delta):
elif check:
miss()
object.miss()
object = null
else:
resume()

Expand All @@ -72,7 +73,6 @@ func resume():
#movement and interaction behaviors
$Animator.play("rest")
$Flute.stop()
can_interact = true

func miss():
#Plays a failing animation on both the player and the object he is
Expand Down
Binary file added icon.ico
Binary file not shown.
Binary file modified icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions icon.png.import
Expand Up @@ -7,10 +7,10 @@ path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
[deps]

source_file="res://icon.png"
source_md5="ae7e641067601e2184afcade49abd283"
source_md5="dea460adba19799bcef9a2b49f3e3c05"

dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_md5="84511021bbc8c9d37c7f0f4d181de883"
dest_md5="a3308c2460f3fb467eab85ef4e6d209b"

[params]

Expand Down
2 changes: 1 addition & 1 deletion levels/level_01/level_01.tscn
Expand Up @@ -25,7 +25,7 @@ custom_solver_bias = 0.0
normal = Vector2( 0, -1 )
d = 0.0

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

[node name="Tilemap" parent="." index="0"]

Expand Down
2 changes: 1 addition & 1 deletion screens/tutorial_screen/tutorial_screen.tscn
Expand Up @@ -944,7 +944,7 @@ func start():
$Button.show()
$Button.grab_focus()"
[node name="Tutorial" index="0" instance=ExtResource( 1 )]
[node name="Tutorial" instance=ExtResource( 1 )]
script = ExtResource( 2 )
next_scene = "res://levels/level_01/level_01.tscn"
Expand Down

0 comments on commit 732de54

Please sign in to comment.