extends Node2D
var player_words = [] # the words the player chooses.
var prompt = ["a noun", "a verb", "a color", "an animal", "a body part", "an adjective"]
var story = "Once upon a time, there was a %s who loved to %s. She loved it so much that she did it every day. One day she came across a %s %s who chased her. While running, she hurt her %s and magically it became very %s."
func _ready():
$Blackboard/StoryText.text = " Welcome to Loony Lips!\n\nWe're going to have so many laughs together. If you will give me just a few different types of words, I'll tell you a very funny story.\n\n\nCan I have " + prompt[player_words.size()] + ", please?"
$Blackboard/TextBox.text = ""
func _on_TextureButton_pressed():
if is_story_done():
get_tree().reload_current_scene()
else:
var new_text = $Blackboard/TextBox.get_text()
_on_TextBox_text_entered(new_text)
prompt_player()
func _on_TextBox_text_entered(new_text):
player_words.append(new_text)
$Blackboard/TextBox.text = ""
check_player_word_length()
func is_story_done():
return player_words.size() == prompt.size()
func prompt_player():
$Blackboard/StoryText.text = ("Can I have " + prompt[player_words.size()] + ", please?")
func check_player_word_length():
if is_story_done():
tell_story()
end_game()
$TextureButton/ButtonLabel.text = "Again!"
else:
prompt_player()
func tell_story():
$Blackboard/StoryText.text = story % player_words
func end_game():
$Blackboard/TextBox.queue_free()
1 Like