Advertisement
humpda

CookieClicker

Apr 22nd, 2025 (edited)
1,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends Node2D
  2.  
  3. # sers variable score to 0
  4. var score = 0
  5.  
  6. # Used to initialise program. Put variables here.
  7. # -> void means a value is not returned. You can leave this out if wanted.
  8. func _ready() -> void:
  9.     # Shows score on screen as 0
  10.     $CanvasLayer/RichTextLabel.text = str(score)
  11.    
  12.    
  13.  
  14. # when button pressed adds 1 to score and plays sound. If score is greater than 10, reset to 1.
  15. func _on_texture_button_pressed() -> void:
  16.     # this is the same as score = score + 1
  17.     score += 1
  18.     if score > 10:
  19.         score = 1
  20.     $CanvasLayer/RichTextLabel.text = str(score)
  21.     $CanvasLayer/AudioStreamPlayer2D.play()
  22.        
  23. # add a different sound when score = 10
  24. # add new textbox that shows "hello world" when score == 10
  25. # add a new button that changes count.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement