Applying Tweens, Nodes, and Await from scratch
Due: before next class
Homework: Build "Juicy Clicker" from scratch
.zip on the course portal.You will build a game from a completely blank project.
You will take a boring mechanic (clicking a Godot icon) and add layers of "juice" using everything you learned this week.
Start here before tackling any challenge.
Node2D root, rename it Gamegame.tscnTimer node (Set Autostart = On, Wait Time = 1.0)Label node for the score
game.gd to the root Game node.Required
Goal: Spawn a Godot icon every second, but make it pop into existence.
Steps:
timeout signal to your game.gd script.Sprite2D.new() to create a node.load("res://icon.svg")randf_range()).add_child(sprite)scale from (0,0) to (1,1) using a tween with TRANS_BOUNCE and EASE_OUT.Here's the pattern for the tween:
var tween = create_tween()
tween.tween_property(sprite, "scale", Vector2(1, 1), 0.5)\
.from(Vector2(0, 0))\
.set_trans(Tween.TRANS_BOUNCE)\
.set_ease(Tween.EASE_OUT)
When you succeed: Your screen should slowly fill up with bouncing Godot heads!
Required
Goal: When clicked, the sprite shouldn't just vanish; it should have a juicy death animation.
Steps:
_input(event) in game.gd. If it's a mouse click, loop through all children. If a child is a Sprite2D, use event.position.distance_to(child.position) < 64 to detect a hit..set_parallel(true) to do three things at once over 0.3 seconds:
(2, 2)modulate:a to 0.0rotation to TAU * 2await tween.finished then child.queue_free().Required
Goal: Give visual feedback exactly where the player clicked.
Steps:
score variable and update your main Label.Label.new() to dynamically spawn a new label exactly at event.position."+1", change its font size, and add_child(label).position.y -= 50) while simultaneously fading out (modulate:a to 0).await and queue_free().Stretch Goal
Goal: Make the main score counter roll up smoothly instead of instantly snapping.
Steps:
score, create a custom variable:var display_score: int = 0:
set(value):
display_score = value
$Label.text = "Score: %d" % display_score
tween.tween_property(self, "display_score", actual_score, 0.5)Submit your completed project before the next class.
Your submission must include:
You will be graded on:
.new())distance_to)await and queue_free()