diff --git a/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/M7.L10 - Talking wiith emotion/Arrays of dictionaries.md b/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/M7.L10 - Talking wiith emotion/Arrays of dictionaries.md new file mode 100644 index 0000000..2db3105 --- /dev/null +++ b/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/M7.L10 - Talking wiith emotion/Arrays of dictionaries.md @@ -0,0 +1,61 @@ +```python +var inventory: Array[Dictionary] = [ + { + "name": "sword", + "amount": 1, + }, + { + "name": "potion", + "amount": 5, + }, + { + "name": "potion", + "amount": 3, + }, + { + "name": "coins", + "amount": 65, + }, +] +``` +[] + + + + + +```python +var expressions := { + "happy" : preload("res://assets/emotion_happy.png"), + "regular" : preload("res://assets/emotion_regular.png"), + "sad" : preload("res://assets/emotion_sad.png"), +} + +var dialogue_items: Array[Dictionary]= [ +{ + "expression": expressions["regular"], + "text": "I'm learning about Arrays..." +}, +{ + "expression": expressions["sad"], + "text": "... and it is a little bit complicated." +}, +{ + "expression": expressions["happy"], + "text": "Let's see if I got it right: an array is a list of values!", +}, +{ + "expression": expressions["regular"], + "text": "Did I get it right? Did I?", +}, +{ + "expression": expressions["happy"], + "text": "Hehe! Bye bye~!", + }, +] + +func show_text() -> void: + var current_item := dialogue_items[current_item_index] + rich_text_label.text = current_item["text"] + expression.texture = current_item["expression"] +``` \ No newline at end of file diff --git a/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/M7.L9 - Generate buttons at runtime/Generate buttons at runtime.md b/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/M7.L9 - Generate buttons at runtime/Generate buttons at runtime.md new file mode 100644 index 0000000..5cfa983 --- /dev/null +++ b/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/M7.L9 - Generate buttons at runtime/Generate buttons at runtime.md @@ -0,0 +1,17 @@ +```python +func create_button_pink() -> void: + var button := Button.new() + row_bodies.add_child(button) +``` + + +```python +func create_buttons() -> void: + for current_body: String in bodies: + var button := Button.new() + row_bodies.add_child(button) + button.text = current_body.capitalize() + button.pressed.connect(func()-> void: + body.texture = bodies[current_body] + ) +``` diff --git a/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/M7.L9 - Generate buttons at runtime/Untitled.md b/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/M7.L9 - Generate buttons at runtime/Untitled.md deleted file mode 100644 index e69de29..0000000 diff --git a/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/Quick structural overview.md b/MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/_Quick structural overview.md similarity index 100% rename from MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/Quick structural overview.md rename to MyObsidianVault/Godot_Training/2D/Tutorial Game 4 - Telling a story/_Quick structural overview.md