Godot Version
4.5.1
Question
So for a little break of my main game I’m making a little cup game where you have to pick one of 3 cups there is a guy on a table and you have to pick 3 cups in a row to win but if you pick wrong 3 times game over. I have some code right now but I’m wondering how to randomly pick a number (In this case the winning cup) this is the code
extends AnimatedSprite2D
var lives = 3
func _process(delta: float) -> void:
if lives == 3:
$".".play("start")
$Lives.text = "Lives:3"
if lives == 2:
$".".play("wrong 1")
$Lives.text = "Lives:2"
if lives == 1:
$".".play("wrong 2")
$Lives.text = "Lives:1"
func _on_animation_finished() -> void:
if animation == "start":
start_game()
func start_game() -> void:
lives = 3
if lives == 2:
play("wrong1")
$Lives.text = "2"
elif lives == 1:
play("wrong2")
$Lives.text = "1"
elif lives <= 0:
play("game_over")
$Lives.text = "0"
func game_over() -> void:
play("game_over")
print("GAME OVER")
func _on_cup_1_pressed() -> void:
print("CUP 1 PRESSED")
func _on_cup_2_pressed() -> void:
print("CUP 2 PRESSED")
func _on_cup_3_pressed() -> void:
print("CUP 3 PRESSED")