Add joke buttons

This commit is contained in:
Waldemar Tomme 2024-01-27 11:38:38 +01:00
parent bdb583d206
commit 515c9eefc7
5 changed files with 104 additions and 29 deletions

View File

@ -28,6 +28,10 @@ window/size/window_height_override=1080
window/stretch/mode="canvas_items"
window/stretch/aspect="keep_height"
[dotnet]
project/assembly_name="Tough Crowd"
[gui]
theme/custom="res://ui/theme.tres"
@ -86,6 +90,21 @@ pause={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
joke_button_1={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
]
}
joke_button_2={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
joke_button_3={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
]
}
[internationalization]

View File

@ -0,0 +1,19 @@
extends Node2D
signal button_pressed
@export_enum("joke_button_1", "joke_button_2", "joke_button_3") var action: String
var current_joke: Joke
func _init():
current_joke = Joke.new(Joke.JokeType.Joke1)
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Input.is_action_just_pressed(action):
emit_signal("button_pressed", current_joke)

View File

@ -1,12 +1,16 @@
[gd_scene load_steps=5 format=3 uid="uid://cicyfp5xjvvu4"]
[gd_scene load_steps=7 format=3 uid="uid://cicyfp5xjvvu4"]
[ext_resource type="Script" path="res://scenes/Tim.gd" id="1_g3k2b"]
[ext_resource type="Texture2D" uid="uid://kq63ictuirhc" path="res://sprites/tim_side.png" id="1_saxit"]
[ext_resource type="Script" path="res://scenes/Boundary.gd" id="2_8p6ir"]
[ext_resource type="Script" path="res://scenes/Joke Button.gd" id="3_opgtx"]
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_3hx6l"]
size = Vector2(600, 200)
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_k2q2d"]
size = Vector2(150, 50)
[node name="Stage" type="Node2D"]
[node name="Sprite2D" type="Sprite2D" parent="."]
@ -25,5 +29,28 @@ scale = Vector2(0.4, 0.4)
texture = ExtResource("1_saxit")
offset = Vector2(0, 50)
[node name="Joke Buttons" type="Node2D" parent="Tim"]
position = Vector2(0, -25)
[node name="Joke Button 1" type="Node2D" parent="Tim/Joke Buttons"]
script = ExtResource("3_opgtx")
[node name="Sprite2D" type="Sprite2D" parent="Tim/Joke Buttons/Joke Button 1"]
texture = SubResource("PlaceholderTexture2D_k2q2d")
[node name="Joke Button 2" type="Node2D" parent="Tim/Joke Buttons"]
script = ExtResource("3_opgtx")
[node name="Sprite2D" type="Sprite2D" parent="Tim/Joke Buttons/Joke Button 2"]
position = Vector2(-150, -50)
texture = SubResource("PlaceholderTexture2D_k2q2d")
[node name="Joke Button 3" type="Node2D" parent="Tim/Joke Buttons"]
script = ExtResource("3_opgtx")
[node name="Sprite2D" type="Sprite2D" parent="Tim/Joke Buttons/Joke Button 3"]
position = Vector2(150, -50)
texture = SubResource("PlaceholderTexture2D_k2q2d")
[node name="Boundary" type="Node2D" parent="."]
script = ExtResource("2_8p6ir")

10
godot/types/joke.gd Normal file
View File

@ -0,0 +1,10 @@
class_name Joke
enum JokeType {
Joke1,
Joke2,
Joke3
}
func _init(type):
self.type = type

File diff suppressed because one or more lines are too long