Preamble: I'm trying to learn the Godot engine (and coding) by making games for jams. Still early days - learning, but not fast enough to make any deadlines. There are plenty of videos and sources out there, and I'm getting a bit lost in all the information (and different ways to achieve the same thing). Plus, some of the info has become outdated as Godot updates.
There are a couple of nodes and scripts I see myself using often in the future - if anyone can help me get up and running with these ideas I'd really appreciate it.
The context: 2D top-down game. Your laundry has blown about town - collect it before it rains.
The questions:
How do I get my character to stop showing a movement animation when no keys are pressed? I'm using an animated sprite sheet and not an animation player or animation tree on this occasion. Here is what I have:
extends KinematicBody2D
func _ready() -> void:
$AnimatedSprite.frames.get_frame("walk_down",0)
var speed : int = 200
var vel : Vector2 = Vector2()
var direction : Vector2 = Vector2()
func read_input():
vel = Vector2()
if Input.is_action_pressed("walk_up"):
vel.y -= speed
direction = Vector2(0, -1)
if Input.is_action_pressed("walk_up"):
$AnimatedSprite.play("walk_up")
if Input.is_action_pressed("walk_down"):
vel.y += speed
direction = Vector2(0, 1)
if Input. is_action_pressed("walk_down"):
$AnimatedSprite.play("walk_down")
if Input.is_action_pressed("walk_left"):
vel.x -= speed
direction = Vector2(-1, 0)
if Input.is_action_pressed("walk_left"):
$AnimatedSprite.play("walk_left")
if Input.is_action_pressed("walk_right"):
vel.x += speed
direction = Vector2(1, 0)
if Input.is_action_pressed("walk_right"):
$AnimatedSprite.play("walk_right")
vel = vel.normalized()
vel = move_and_slide(vel * 200)
func _physics_process(_delta):
read_input()
Much like a hidden object game, there would be a list of missing clothes at the bottom of the screen. On picking up the clothes, the item on the list would either fade or disappear from the list entirely. How would I implement this? How would I do this for multiple items (e.g. 4 missing socks becoming 3 missing socks etc.)?
How would I implement a hidden countdown timer which ends the game? The time could start from the moment the game starts, or from the moment the first item is collected.
Thanks for reading.