I’ve now added the player and am working on the first minigame. Right now I just have the ground and the background for the minigame. I made the player sprite on Piskel (does anybody else use that?). For some reason it’s blurry here, but it’s not blurry in Godot thankfully. So far I have only one problem, but as far as I can tell it’s quite a big problem. It never gets to my minigame screen! It goes from the title screen to the timer screen, and just stays on that forever! There seems to be a lot of errors but I have no idea what they mean, and also, since I copy pasted my code directly from the mission guide, I don’t know why there even are errors. The end.
Comments 1
here’s the code in case you wanna find out what’s wrong… Go on, READ IT!
extends Node2D
@onready var life_container: HBoxContainer = $LifeContainer
@onready var life_1: TextureRect = $LifeContainer/Life1
@onready var life_2: TextureRect = $LifeContainer/Life2
@onready var life_3: TextureRect = $LifeContainer/Life3
@onready var life_4: TextureRect = $LifeContainer/Life4
@onready var life_5: TextureRect = $LifeContainer/Life5
@onready var level: RichTextLabel = $Level
@onready var timer: RichTextLabel = $Timer
var time
func _ready() -> void:
if Global.minigames_done < 3: # if you havent completed 3 minigames yet Global.minigames_done = Global.minigames_done +1 get_tree().change_scene_to_file("res://scenes/minigame_" + str(Global.minigames_done) + ".tscn") # changes your # scene by arranging this frankenstein path. Above, your script is being told to go to the next minigame. If the current minigame is Level 1, then you would be on minigame 1. If you complete that level, you have the minigames_done add one, and then you look for the scene titled minigame_ and then whatever minigame number should be next. Make sure you name your minigame saves appropriately. else: get_tree().change_scene_to_file("res://scenes/title_screen.tscn") # changes your sceneawait Timer(5.0) # using the function created
func _process(delta: float) -> void: # runs EVERY FRAME
4: life_1.hide() 3: life_1.hide() life_2.hide() 2: life_1.hide() life_2.hide() life_3.hide() 1: life_1.hide() life_2.hide() life_3.hide() life_4.hide() 0: life_container.hide() # just hides everything timer.text = str(time) # make ths text reflect the value of the time variable. this makes names easier. the str() converts the int to a String level.text = "Level " + str(Global.minigames_done) # this tells you what minigame you're on using concatenation (google the word)match Global.lives: # asks or checks if lives is equal to one of
#these values, cool hack. by the way this is a horrid way to illustrate the
#lives visually so later you can always find alternative code. Now, dw abt it.
func Timer(start_time: float): # making a new function for timer countdown!
time = start_time # make the timer, which is reflected through the timer text, start at your desired number while time > 0.0: # run if timer hasnt reached 0 await wait(0.1) # asks script to wait on this function. the 'wait' name for the function does nothing here, as await is just telling the scrpit to wait for the function to complete before progressing time -= 0.1 # remove 0.1 # progressively get the value smaller and smaller #when timer reaches 0 return# we want the timer to go down, and when it reaches 0 it transitions
# to the next scene!
func wait(seconds: float) -> void: # write this simple function out for wait!
await get_tree().create_timer(seconds).timeout # makes u wait, dw abt this being complex ‘’’
Sign in to join the conversation.