- improving textures

- adding coins (no shop jet)
- adding skin changing [no gui jet
- fixing loops for deleting stuff]
This commit is contained in:
megamichi 2024-11-10 19:51:00 +01:00
parent 45193fc27f
commit dd5b4bcae5
45 changed files with 547 additions and 382 deletions

View file

@ -1,33 +1,22 @@
extends TextureRect
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$AnimationPlayer.play_backwards("out-in")
hide()
func _process(_delta: float) -> void:
pass
#global_position.x = get_viewport().get_visible_rect().size.x * 0.5
func _on_duck_gameover() -> void:
$AnimationPlayer.play_backwards("out-in")
$AnimationPlayer.pop_in()
$"../../Audio/GameOver".play()
$"../../Audio/Gui-in".play()
show()
$Restart.grab_focus()
print($"/root/Global".hiscore)
if %ScoreContainer.get_score() > $"/root/Global".hiscore:
$"/root/Global".write_save()
func _on_restart_pressed() -> void:
$"../..".start_game()
$AnimationPlayer.play("out-in")
$"../../Audio/Gui-out".play()
await $AnimationPlayer.animation_finished
hide()
$AnimationPlayer.pop_out()
func _on_back_pressed() -> void:

View file

@ -5,7 +5,7 @@ var audio_bus_sounds = 2
var sound_button_on_of = {true:preload("res://assets/GUI/sound button.png"),false:preload("res://assets/GUI/sound button off.png")}
var sound_button_on_of_f = {true:preload("res://assets/GUI/buttons fucused/sound button f.png"),false:preload("res://assets/GUI/buttons fucused/sound button off f.png")}
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
#$"../../Audio/Duckrun".volume_db = linear_to_db(20*0.01)
$AnimationPlayer.play_backwards("out-in")
@ -16,25 +16,18 @@ func _process(_delta: float) -> void:
#$Logo.global_position.x = 0
func open():
show()
$AnimationPlayer.play_backwards("out-in")
$"../../Audio/Gui-in".play()
$AnimationPlayer.pop_in()
$BackButton.grab_focus()
func _on_back_pressed() -> void:
$AnimationPlayer.play("out-in")
$"../../Audio/Gui-out".play()
await $AnimationPlayer.animation_finished
hide()
$AnimationPlayer.pop_out()
$"../StartSchild"._ready()
func _volume_slider_changed(value: float) -> void:
AudioServer.set_bus_volume_db(audio_bus_music,linear_to_db(value*0.01))
func _on_sound_button_toggled(toggled_on: bool) -> void:
func _on_sound_button_toggled(_toggled_on: bool) -> void:
$SoundToggleButton.texture_normal = sound_button_on_of[AudioServer.is_bus_mute(audio_bus_sounds)]
$SoundToggleButton.texture_focused = sound_button_on_of_f[AudioServer.is_bus_mute(audio_bus_sounds)]
AudioServer.set_bus_mute(audio_bus_sounds,not AudioServer.is_bus_mute(audio_bus_sounds))

View file

@ -1,28 +1,21 @@
extends TextureRect
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$AnimationPlayer.play_backwards("out-in")
$"../../Audio/Gui-in".play()
show()
$"../StartSchildLogo/AnimationPlayer".pop_in()
$AnimationPlayer.pop_in()
$Start.grab_focus()
func _process(delta: float) -> void:
$Logo.global_position.x = -5
func _on_start_pressed() -> void:
$AnimationPlayer.pop_out()
$"../StartSchildLogo/AnimationPlayer".pop_out()
$"../..".start_game()
$AnimationPlayer.play("out-in")
$"../../Audio/Gui-out".play()
await $AnimationPlayer.animation_finished
hide()
func _on_settings_pressed() -> void:
$AnimationPlayer.play("out-in")
$"../../Audio/Gui-out".play()
await $AnimationPlayer.animation_finished
hide()
$"../StartSchildLogo/AnimationPlayer".pop_out()
$AnimationPlayer.pop_out()
$"../Settings".open()

View file

@ -1,3 +1,4 @@
{
"hiscore":0
"hiscore":0,
"coins":0
}

View file

@ -12,40 +12,13 @@ var active_biom
var gamerunning = false
var hiscore
var hiscore:int
var coins:int
func _ready() -> void:
load_save()
#write_save()
func load_save():
var data : FileAccess
if (not FileAccess.file_exists("user://save.json")) or (FileAccess.open("user://save.json", FileAccess.READ_WRITE).get_as_text() == ""):
data = FileAccess.open("user://save.json", FileAccess.WRITE)
data.store_string(FileAccess.open("res://code/first_save.json", FileAccess.READ).get_as_text())
data.close()
data = FileAccess.open("user://save.json", FileAccess.READ)
var content_text = JSON.parse_string(data.get_as_text())
if content_text:
print("loaded: ",content_text)
hiscore = content_text.get("hiscore", 0)
else:
print("Failed to parse JSON")
data.close()
func write_save():
var data : FileAccess
data = FileAccess.open("user://save.json",FileAccess.WRITE)
var content = JSON.stringify(
{
"hiscore":$/root/Game/Gui/ScoreContainer.get_score()
}
)
print("saved: ",content)
data.store_string(content)
var save = load_save()
hiscore = save["hiscore"]
coins = save["hiscore"]
func reset_game():
speed = 100
@ -53,5 +26,39 @@ func reset_game():
active_biom = "n"
gamerunning = false
_ready()
$/root/Game/Fade/FadeAnimation.play("fade")
get_tree().reload_current_scene()
var data : FileAccess
func load_save() -> Dictionary:
# wenn kein save vorhanden ist, erstelle eins
if (not FileAccess.file_exists("user://save.json")) or (FileAccess.open("user://save.json", FileAccess.READ_WRITE).get_as_text() == ""):
init_save()
data = FileAccess.open("user://save.json", FileAccess.READ)
var content_text: Dictionary = JSON.parse_string(data.get_as_text())
if content_text:
print("loaded: ",content_text)
return content_text
else:
print("Failed to parse JSON")
return {}
func write_save():
var sdata : FileAccess
sdata = FileAccess.open("user://save.json",FileAccess.WRITE)
var content = JSON.stringify(
{
"hiscore":$/root/Game/Gui/ScoreContainer.get_score()
}
)
print("saved: ",content)
sdata.store_string(content)
func init_save():
data = FileAccess.open("user://save.json", FileAccess.WRITE)
data.store_string(FileAccess.open("res://code/first_save.json", FileAccess.READ).get_as_text())
data.close()

View file

@ -1,13 +1,5 @@
extends Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
text = str($"/root/Global".hiscore)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
#func get_score():
# return int(text)

View file

@ -1,7 +1,7 @@
extends Node
func _ready() -> void:
$Fade/FadeAnimation.play_backwards("fade")
$Fade/Animation.play_backwards("fade")
$Screen/Background/Floor/EasterEggFixCollision.disabled = false
$Gui/HiscoreContainer.show()
%ScoreContainer.hide()

View file

@ -7,7 +7,7 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
pass
func get_score():