From 8b9fc4a52407b0a1e368c174eb6709dcb035fa65 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 28 Jan 2024 18:27:12 +0100 Subject: [PATCH] rolls --- scenes/game/ads/Ads_roll.tscn | 42 ++++++++++++++++++++++++++++++++++- scripts/ads/ads_roll.gd | 16 +++++++++++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/scenes/game/ads/Ads_roll.tscn b/scenes/game/ads/Ads_roll.tscn index bd69de8..f3dd3f3 100644 --- a/scenes/game/ads/Ads_roll.tscn +++ b/scenes/game/ads/Ads_roll.tscn @@ -1,7 +1,47 @@ -[gd_scene load_steps=3 format=3 uid="uid://dk6bkpnylxwdb"] +[gd_scene load_steps=5 format=3 uid="uid://dk6bkpnylxwdb"] [ext_resource type="PackedScene" uid="uid://n06gkookqeml" path="res://scenes/game/windows/Ads.tscn" id="1_n2kk4"] [ext_resource type="Script" path="res://scripts/ads/ads_roll.gd" id="2_kihjv"] +[ext_resource type="Texture2D" uid="uid://bbi7rhpstsku4" path="res://ressources/assets/RollDice/Dice.png" id="3_7himq"] +[ext_resource type="Texture2D" uid="uid://br2tesflbta84" path="res://ressources/assets/RollDice/ButtonDice.png" id="4_ldetv"] [node name="Windows" instance=ExtResource("1_n2kk4")] script = ExtResource("2_kihjv") + +[node name="Dice" type="Sprite2D" parent="." index="2"] +position = Vector2(251, 224.5) +scale = Vector2(0.401667, 0.351042) +texture = ExtResource("3_7himq") + +[node name="Right" type="Label" parent="Dice" index="0"] +offset_left = 112.033 +offset_top = 47.0029 +offset_right = 319.033 +offset_bottom = 249.003 +theme_override_font_sizes/font_size = 142 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Left" type="Label" parent="Dice" index="1"] +offset_left = -336.0 +offset_top = 47.0 +offset_right = -129.0 +offset_bottom = 249.0 +theme_override_font_sizes/font_size = 142 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="ButtonDice" type="Sprite2D" parent="." index="3"] +position = Vector2(252, 194) +scale = Vector2(0.4, 0.4) +texture = ExtResource("4_ldetv") + +[node name="Button" type="Button" parent="ButtonDice" index="0"] +offset_left = -192.0 +offset_top = -55.0 +offset_right = 198.0 +offset_bottom = 55.0 +focus_mode = 0 +flat = true + +[connection signal="pressed" from="ButtonDice/Button" to="." method="_on_button_pressed"] diff --git a/scripts/ads/ads_roll.gd b/scripts/ads/ads_roll.gd index 4e92afc..66b4b76 100644 --- a/scripts/ads/ads_roll.gd +++ b/scripts/ads/ads_roll.gd @@ -1,9 +1,21 @@ extends "res://scripts/ads/ads_default.gd" -# TODO +@onready var button := $ButtonDice/Button +@onready var label_left := $Dice/Left +@onready var label_right := $Dice/Right func _ready(): - pass + label_left.text = "0" + label_right.text = "0" func exit_condition(): return condition + +func _on_button_pressed(): + var left := randi_range(0, 6) + var right := randi_range(0, 6) + + label_left.text = str(left) + label_right.text = str(right) + + condition = left + right >= 5