- implementing biom change
- fixing typo in "highscore"
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
@ -3,15 +3,15 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bg78j6xxw3ck4"
|
||||
path="res://.godot/imported/normal.png-37b1636db5b68b29e796c7291d1e7fb7.ctex"
|
||||
path="res://.godot/imported/n.png-e0925980109603d0618d5083d12d13a4.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Ground/normal.png"
|
||||
dest_files=["res://.godot/imported/normal.png-37b1636db5b68b29e796c7291d1e7fb7.ctex"]
|
||||
source_file="res://assets/Ground/n.png"
|
||||
dest_files=["res://.godot/imported/n.png-e0925980109603d0618d5083d12d13a4.ctex"]
|
||||
|
||||
[params]
|
||||
|
BIN
assets/Ground/n_w.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
|
@ -3,15 +3,15 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cthy542lxhe5q"
|
||||
path="res://.godot/imported/normal_wueste.png-89ab2ffcf2bef316921cd900939a3c10.ctex"
|
||||
path="res://.godot/imported/n_w.png-3366615037638c8fbe0a788e5097fd5c.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Ground/normal_wueste.png"
|
||||
dest_files=["res://.godot/imported/normal_wueste.png-89ab2ffcf2bef316921cd900939a3c10.ctex"]
|
||||
source_file="res://assets/Ground/n_w.png"
|
||||
dest_files=["res://.godot/imported/n_w.png-3366615037638c8fbe0a788e5097fd5c.ctex"]
|
||||
|
||||
[params]
|
||||
|
Before Width: | Height: | Size: 5.5 KiB |
BIN
assets/Ground/w.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
|
@ -3,15 +3,15 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bc586lwyvhc0x"
|
||||
path="res://.godot/imported/wueste.png-5ab8ec82be959612090d314f1b3048a9.ctex"
|
||||
path="res://.godot/imported/w.png-eaecb02b75e3caf6be524da31509ca22.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Ground/wueste.png"
|
||||
dest_files=["res://.godot/imported/wueste.png-5ab8ec82be959612090d314f1b3048a9.ctex"]
|
||||
source_file="res://assets/Ground/w.png"
|
||||
dest_files=["res://.godot/imported/w.png-eaecb02b75e3caf6be524da31509ca22.ctex"]
|
||||
|
||||
[params]
|
||||
|
BIN
assets/Ground/w_n.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
34
assets/Ground/w_n.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bvel70kpfhdyx"
|
||||
path="res://.godot/imported/w_n.png-5b7c970c02b0839cd9da18edab137348.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Ground/w_n.png"
|
||||
dest_files=["res://.godot/imported/w_n.png-5b7c970c02b0839cd9da18edab137348.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
Before Width: | Height: | Size: 2.5 KiB |
|
@ -1,6 +1,4 @@
|
|||
extends Control
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
show()
|
||||
|
|
|
@ -3,7 +3,7 @@ extends TextureRect
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
#global_position.y = -80
|
||||
$AnimationPlayer.play_backwards("out-in")
|
||||
hide()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
|
@ -15,7 +15,10 @@ func _on_duck_gameover() -> void:
|
|||
$"../../Audio/GameOver".play()
|
||||
$"../../Audio/Gui-in".play()
|
||||
show()
|
||||
|
||||
print($"/root/Global".hiscore)
|
||||
if %ScoreContainer.get_score() > $"/root/Global".hiscore:
|
||||
$"/root/Global".write_save()
|
||||
|
||||
|
||||
|
||||
func _on_restart_pressed() -> void:
|
||||
|
|
|
@ -4,36 +4,43 @@ extends Node
|
|||
signal levelup
|
||||
signal start
|
||||
|
||||
|
||||
var maxspeed = 260
|
||||
var speed = 100
|
||||
var score = 0
|
||||
var gamerunning = false
|
||||
|
||||
|
||||
var hiscore
|
||||
|
||||
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())
|
||||
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 contenttext = JSON.parse_string(data.get_as_text())
|
||||
print(contenttext)
|
||||
hiscore = contenttext["hiscore"]
|
||||
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)
|
||||
data.store_string(
|
||||
JSON.stringify(
|
||||
var content = JSON.stringify(
|
||||
{
|
||||
"hiscore":$"/root/Game/Gui/HiscoreContainer/hiscore".get_score()
|
||||
"hiscore":$/root/Game/Gui/ScoreContainer.get_score()
|
||||
}
|
||||
)
|
||||
)
|
||||
print("saved: ",content)
|
||||
data.store_string(content)
|
||||
|
|
|
@ -8,11 +8,6 @@ func _ready() -> void:
|
|||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func set_new_hiscore():
|
||||
if int(text) < int(%ScoreContainer/text.text):
|
||||
text = %ScoreContainer/text.text
|
||||
$"/root/Global".write_save()
|
||||
|
||||
func get_score():
|
||||
return int(text)
|
||||
#func get_score():
|
||||
# return int(text)
|
||||
|
|
16
code/main.gd
|
@ -1,8 +1,5 @@
|
|||
extends Node
|
||||
|
||||
var biom_n = preload("res://assets/Ground/normal.png")
|
||||
var biom_n_w = preload("res://assets/Ground/normal_wueste.png")
|
||||
var biom_w = preload("res://assets/Ground/wueste.png")
|
||||
func _ready() -> void:
|
||||
$Screen/Background/Floor/EasterEggFixCollision.disabled = false
|
||||
$Gui/HiscoreContainer.show()
|
||||
|
@ -10,11 +7,11 @@ func _ready() -> void:
|
|||
|
||||
func start_game():
|
||||
$Screen/Background/Floor/EasterEggFixCollision.disabled = true
|
||||
$Screen/HindernissSpawner.del_all()
|
||||
$Gui/EastereggSpawner.del_all()
|
||||
$Screen/SpawnTimer.start()
|
||||
$Screen/LevelUpTimer.start()
|
||||
$Screen/Duck.start()
|
||||
$Screen/HindernissSpawner.del_all()
|
||||
$Screen/EastereggSpawner.del_all()
|
||||
$Gui/HiscoreContainer.hide()
|
||||
%ScoreContainer.show()
|
||||
$"/root/Global".gamerunning = true
|
||||
|
@ -35,12 +32,5 @@ func _score() -> void:
|
|||
%ScoreContainer/score.text = str($"/root/Global".score)
|
||||
|
||||
func _process(delta):
|
||||
var background_size_x = $Screen/Background/Sprite.texture.get_size().x
|
||||
|
||||
var bla = (background_size_x) + $Screen/Background/Sprite.position.x
|
||||
if $"/root/Global".gamerunning:
|
||||
$Screen/Background/Sprite.position.x -= $"/root/Global".speed*delta
|
||||
if bla <= 0:
|
||||
#$Screen/Background/Sprite.texture =biom_n_w
|
||||
$Screen/Background/Sprite.position.x = 0
|
||||
pass
|
||||
|
||||
|
|
14
code/score.gd
Normal file
|
@ -0,0 +1,14 @@
|
|||
extends HBoxContainer
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func get_score():
|
||||
return int($score.text)
|
|
@ -14,6 +14,7 @@ func die():
|
|||
|
||||
func start():
|
||||
global_position = Vector2(21,91)
|
||||
velocity = Vector2(0,0)
|
||||
alive = true
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
@ -25,7 +26,7 @@ func _physics_process(delta: float) -> void:
|
|||
move_and_slide()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if position.x < -20:
|
||||
if position.x < 20 or position.y > 100:
|
||||
if alive:
|
||||
die()
|
||||
|
||||
|
@ -43,8 +44,9 @@ func _process(_delta: float) -> void:
|
|||
$AnimationPlayer.play("walk")
|
||||
|
||||
func _collide_with_hindernis(_body: Node2D) -> void:
|
||||
if alive:
|
||||
die()
|
||||
pass
|
||||
#if alive:
|
||||
# die()
|
||||
|
||||
|
||||
func _color_slider_changed(value) -> void:
|
||||
|
|
114
scenes/Main.tscn
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=35 format=3 uid="uid://bb5qp5868y5i"]
|
||||
[gd_scene load_steps=37 format=3 uid="uid://bb5qp5868y5i"]
|
||||
|
||||
[ext_resource type="Script" path="res://code/main.gd" id="1_ar2ah"]
|
||||
[ext_resource type="PackedScene" uid="uid://8v5mbbnddorh" path="res://scenes/Duck/Duck.tscn" id="2"]
|
||||
[ext_resource type="Texture2D" uid="uid://dgfvf2ta4lc4e" path="res://assets/Ground/stars.png" id="2_ohf2r"]
|
||||
[ext_resource type="Texture2D" uid="uid://bg78j6xxw3ck4" path="res://assets/Ground/normal.png" id="3"]
|
||||
[ext_resource type="Script" path="res://scenes/ground/spawner/ground_spawner.gd" id="3_va7mo"]
|
||||
[ext_resource type="Script" path="res://scenes/hindernis/Spawner/hindernis_spawner.gd" id="4_oc6me"]
|
||||
[ext_resource type="PackedScene" uid="uid://cjq8kb0mhjh8r" path="res://scenes/ground/ground.tscn" id="4_tt0te"]
|
||||
[ext_resource type="PackedScene" uid="uid://dm307sj4nenjt" path="res://scenes/schild.tscn" id="5_ewtcf"]
|
||||
[ext_resource type="Texture2D" uid="uid://do0okfxenx2ci" path="res://assets/GUI/restart button.png" id="6_boo0r"]
|
||||
[ext_resource type="Script" path="res://scenes/easteregg/Spawner/easteregg_spawner.gd" id="8_awkaj"]
|
||||
|
@ -24,6 +25,7 @@
|
|||
[ext_resource type="AudioStream" uid="uid://bktthpfrs0118" path="res://assets/audio/gui-out.ogg" id="21_frskh"]
|
||||
[ext_resource type="FontFile" uid="uid://ddvhypxkj8a1b" path="res://Megamichisfont-small.otf" id="21_uy1pc"]
|
||||
[ext_resource type="AudioStream" uid="uid://c4wrtvywao1jn" path="res://assets/audio/duckrun.wav" id="22_ijpe0"]
|
||||
[ext_resource type="Script" path="res://code/score.gd" id="22_m4aei"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_n8ktn"]
|
||||
length = 0.001
|
||||
|
@ -153,7 +155,6 @@ func _process(delta: float) -> void:
|
|||
|
||||
|
||||
func _change_time() -> void:
|
||||
print(day)
|
||||
if day:
|
||||
$\"../AnimationPlayer\".play(\"change_time\")
|
||||
day = not day
|
||||
|
@ -164,10 +165,10 @@ func _change_time() -> void:
|
|||
"
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_o05as"]
|
||||
size = Vector2(4, 15)
|
||||
size = Vector2(2, 9.75)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0a3yj"]
|
||||
size = Vector2(361, 8)
|
||||
size = Vector2(356.5, 8)
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_jin1w"]
|
||||
|
||||
|
@ -209,7 +210,7 @@ autostart = true
|
|||
script = SubResource("GDScript_rkc4w")
|
||||
|
||||
[node name="BackgroundRect" type="ColorRect" parent="Screen"]
|
||||
offset_right = 1138.0
|
||||
offset_right = 1264.0
|
||||
offset_bottom = 97.0
|
||||
color = Color(0.560784, 0.937255, 0.937255, 1)
|
||||
|
||||
|
@ -220,33 +221,34 @@ modulate = Color(1, 1, 1, 0)
|
|||
position = Vector2(130, 50)
|
||||
texture = ExtResource("2_ohf2r")
|
||||
|
||||
[node name="Sprite" type="TextureRect" parent="Screen/Background"]
|
||||
offset_top = 8.0
|
||||
offset_right = 1134.0
|
||||
offset_bottom = 300.0
|
||||
texture = ExtResource("3")
|
||||
stretch_mode = 1
|
||||
[node name="GroundSpawner" type="Node2D" parent="Screen/Background"]
|
||||
position = Vector2(0, 8)
|
||||
script = ExtResource("3_va7mo")
|
||||
|
||||
[node name="Ground" parent="Screen/Background/GroundSpawner" instance=ExtResource("4_tt0te")]
|
||||
|
||||
[node name="Floor" type="StaticBody2D" parent="Screen/Background"]
|
||||
|
||||
[node name="EasterEggFixCollision" type="CollisionShape2D" parent="Screen/Background/Floor"]
|
||||
position = Vector2(-2, 83)
|
||||
visible = false
|
||||
position = Vector2(14, 86.875)
|
||||
shape = SubResource("RectangleShape2D_o05as")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Screen/Background/Floor"]
|
||||
position = Vector2(176, 96)
|
||||
position = Vector2(178.25, 96)
|
||||
shape = SubResource("RectangleShape2D_0a3yj")
|
||||
|
||||
[node name="HindernissSpawner" type="Marker2D" parent="Screen"]
|
||||
position = Vector2(446, 92)
|
||||
script = ExtResource("4_oc6me")
|
||||
|
||||
[node name="Duck" parent="Screen" instance=ExtResource("2")]
|
||||
position = Vector2(21, 91)
|
||||
|
||||
[node name="HindernissSpawner" type="Marker2D" parent="Screen"]
|
||||
position = Vector2(485, 92)
|
||||
script = ExtResource("4_oc6me")
|
||||
|
||||
[node name="WolkenSpawner" type="Marker2D" parent="Screen"]
|
||||
position = Vector2(485, -1)
|
||||
position = Vector2(485, 0)
|
||||
script = ExtResource("11_x2wm3")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="LevelUpTimer" type="Timer" parent="Screen"]
|
||||
wait_time = 5.0
|
||||
|
@ -257,10 +259,6 @@ wait_time = 1.6
|
|||
[node name="WolkenTimer" type="Timer" parent="Screen"]
|
||||
autostart = true
|
||||
|
||||
[node name="EastereggSpawner" type="Marker2D" parent="Screen"]
|
||||
position = Vector2(81, -18)
|
||||
script = ExtResource("8_awkaj")
|
||||
|
||||
[node name="Gui" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
|
@ -269,9 +267,13 @@ anchor_bottom = 1.0
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("8_t3tw7")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="EastereggSpawner" type="Marker2D" parent="Gui"]
|
||||
position = Vector2(81, -18)
|
||||
script = ExtResource("8_awkaj")
|
||||
|
||||
[node name="HiscoreContainer" type="VBoxContainer" parent="Gui"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
offset_left = 1.0
|
||||
offset_top = 1.0
|
||||
|
@ -283,7 +285,7 @@ theme_override_constants/separation = 0
|
|||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("21_uy1pc")
|
||||
theme_override_font_sizes/font_size = 8
|
||||
text = "Your Hiscore:"
|
||||
text = "Your Highscore:"
|
||||
|
||||
[node name="hiscore" type="Label" parent="Gui/HiscoreContainer"]
|
||||
layout_mode = 2
|
||||
|
@ -292,34 +294,6 @@ theme_override_font_sizes/font_size = 8
|
|||
text = "0"
|
||||
script = ExtResource("21_5nnhv")
|
||||
|
||||
[node name="ScoreContainer" type="HBoxContainer" parent="Gui"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -28.0
|
||||
offset_top = 17.0
|
||||
offset_right = 29.0
|
||||
offset_bottom = 24.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="text" type="Label" parent="Gui/ScoreContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("21_uy1pc")
|
||||
theme_override_font_sizes/font_size = 8
|
||||
text = "Score:"
|
||||
|
||||
[node name="score" type="Label" parent="Gui/ScoreContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("21_uy1pc")
|
||||
theme_override_font_sizes/font_size = 8
|
||||
text = " "
|
||||
|
||||
[node name="ScoreCounter" type="Timer" parent="Gui/ScoreContainer/score"]
|
||||
wait_time = 0.1
|
||||
autostart = true
|
||||
|
||||
[node name="Settings" parent="Gui" instance=ExtResource("5_ewtcf")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
@ -515,6 +489,35 @@ size_flags_horizontal = 4
|
|||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("14_4hepj")
|
||||
|
||||
[node name="ScoreContainer" type="HBoxContainer" parent="Gui"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -28.0
|
||||
offset_top = 17.0
|
||||
offset_right = 29.0
|
||||
offset_bottom = 24.0
|
||||
grow_horizontal = 2
|
||||
script = ExtResource("22_m4aei")
|
||||
|
||||
[node name="text" type="Label" parent="Gui/ScoreContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("21_uy1pc")
|
||||
theme_override_font_sizes/font_size = 8
|
||||
text = "Score:"
|
||||
|
||||
[node name="score" type="Label" parent="Gui/ScoreContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("21_uy1pc")
|
||||
theme_override_font_sizes/font_size = 8
|
||||
text = " "
|
||||
|
||||
[node name="ScoreCounter" type="Timer" parent="Gui/ScoreContainer/score"]
|
||||
wait_time = 0.1
|
||||
autostart = true
|
||||
|
||||
[node name="Audio" type="Node" parent="."]
|
||||
|
||||
[node name="Gui-in" type="AudioStreamPlayer" parent="Audio"]
|
||||
|
@ -535,12 +538,12 @@ autoplay = true
|
|||
bus = &"Background"
|
||||
|
||||
[connection signal="timeout" from="Screen/Day-NightTimer" to="Screen/Day-NightTimer" method="_change_time"]
|
||||
[connection signal="screen_entered" from="Screen/Background/GroundSpawner/Ground" to="Screen/Background/GroundSpawner" method="_on_ground_sprite_screen_entered"]
|
||||
[connection signal="gameover" from="Screen/Duck" to="Gui/HiscoreContainer/hiscore" method="set_new_hiscore"]
|
||||
[connection signal="gameover" from="Screen/Duck" to="Gui/GameOverSchild" method="_on_duck_gameover"]
|
||||
[connection signal="timeout" from="Screen/LevelUpTimer" to="." method="_on_level_up_timer_timeout"]
|
||||
[connection signal="timeout" from="Screen/SpawnTimer" to="Screen/HindernissSpawner" method="_spawn"]
|
||||
[connection signal="timeout" from="Screen/WolkenTimer" to="Screen/WolkenSpawner" method="_spawn"]
|
||||
[connection signal="timeout" from="Gui/ScoreContainer/score/ScoreCounter" to="." method="_score"]
|
||||
[connection signal="pressed" from="Gui/Settings/BackButton" to="Gui/Settings" method="_on_back_pressed"]
|
||||
[connection signal="value_changed" from="Gui/Settings/ColorSlider" to="Screen/Duck" method="_color_slider_changed"]
|
||||
[connection signal="value_changed" from="Gui/Settings/VolumeSlider" to="Gui/Settings" method="_volume_slider_changed"]
|
||||
|
@ -548,4 +551,5 @@ bus = &"Background"
|
|||
[connection signal="pressed" from="Gui/GameOverSchild/Restart" to="Gui/GameOverSchild" method="_on_restart_pressed"]
|
||||
[connection signal="pressed" from="Gui/StartSchild/Start" to="Gui/StartSchild" method="_on_start_pressed"]
|
||||
[connection signal="pressed" from="Gui/StartSchild/Settings" to="Gui/StartSchild" method="_on_settings_pressed"]
|
||||
[connection signal="pressed" from="Gui/StartSchild/Logo" to="Screen/EastereggSpawner" method="_spawn"]
|
||||
[connection signal="pressed" from="Gui/StartSchild/Logo" to="Gui/EastereggSpawner" method="_spawn"]
|
||||
[connection signal="timeout" from="Gui/ScoreContainer/score/ScoreCounter" to="." method="_score"]
|
||||
|
|
|
@ -9,5 +9,6 @@ func _ready() -> void:
|
|||
frame = randi_range(0,4)
|
||||
self_modulate = Color(1,1,1,randf_range(0,0.5))
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
global_position.x -= speed * delta
|
||||
|
|
19
scenes/ground/ground.gd
Normal file
|
@ -0,0 +1,19 @@
|
|||
extends Sprite2D
|
||||
|
||||
signal screen_entered
|
||||
|
||||
var speed: float
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if $"/root/Global".gamerunning:
|
||||
global_position.x -= $"/root/Global".speed*delta
|
||||
|
||||
|
||||
func screen_e() -> void:
|
||||
screen_entered.emit()
|
||||
|
||||
func screen_exited() -> void:
|
||||
queue_free()
|
17
scenes/ground/ground.tscn
Normal file
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cjq8kb0mhjh8r"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bg78j6xxw3ck4" path="res://assets/Ground/n.png" id="1_ocn3x"]
|
||||
[ext_resource type="Script" path="res://scenes/ground/ground.gd" id="2_eg3te"]
|
||||
|
||||
[node name="Ground" type="Sprite2D"]
|
||||
texture_filter = 1
|
||||
texture = ExtResource("1_ocn3x")
|
||||
centered = false
|
||||
script = ExtResource("2_eg3te")
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
||||
position = Vector2(399.5, 82.5)
|
||||
scale = Vector2(0.05, -0.05)
|
||||
|
||||
[connection signal="screen_entered" from="VisibleOnScreenNotifier2D" to="." method="screen_e"]
|
||||
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="screen_exited"]
|
51
scenes/ground/spawner/ground_spawner.gd
Normal file
|
@ -0,0 +1,51 @@
|
|||
extends Node2D
|
||||
|
||||
var texture_new_sprite : Texture
|
||||
|
||||
var biom_n = preload("res://assets/Ground/n.png")
|
||||
var biom_n_w = preload("res://assets/Ground/n_w.png")
|
||||
var biom_w_n = preload("res://assets/Ground/w_n.png")
|
||||
var biom_w = preload("res://assets/Ground/w.png")
|
||||
|
||||
var active_biom = "n"
|
||||
var passed
|
||||
|
||||
|
||||
func probability(prozent):
|
||||
return randf() > 1-(0.01*20) # 20% warscheinlichkeit um biom zu tauschen
|
||||
|
||||
func handle_biom_change():
|
||||
if active_biom == "n":
|
||||
if probability(20):
|
||||
active_biom = "n_w"
|
||||
elif active_biom == "n_w":
|
||||
active_biom = "w"
|
||||
elif active_biom == "w":
|
||||
active_biom = "w_n"
|
||||
elif active_biom == "w_n":
|
||||
active_biom = "n"
|
||||
set_biom_texture()
|
||||
|
||||
func set_biom_texture():
|
||||
#print("activebiom_s: " + active_biom)
|
||||
if active_biom == "w":
|
||||
texture_new_sprite = biom_w
|
||||
elif active_biom == "n":
|
||||
texture_new_sprite = biom_n
|
||||
elif active_biom == "w_n":
|
||||
texture_new_sprite = biom_w_n
|
||||
elif active_biom == "n_w":
|
||||
texture_new_sprite = biom_n_w
|
||||
|
||||
|
||||
func _spawn(last_x_position) -> void:
|
||||
var new_ground = preload("res://scenes/ground/ground.tscn").instantiate()
|
||||
new_ground.texture = texture_new_sprite
|
||||
new_ground.global_position.x = last_x_position+400
|
||||
add_child(new_ground)
|
||||
new_ground.connect("screen_entered",_on_ground_sprite_screen_entered)
|
||||
|
||||
|
||||
func _on_ground_sprite_screen_entered() -> void:
|
||||
handle_biom_change()
|
||||
_spawn(get_child(0).position.x)
|
|
@ -13,10 +13,10 @@ func _spawn() -> void:
|
|||
|
||||
var v1 = 1.5 - (speed / 260)
|
||||
var v2 = 2.0 - (speed / 260)
|
||||
print(str(v1)," ",str(v2))
|
||||
#print(str(v1)," ",str(v2))
|
||||
|
||||
$"../SpawnTimer".wait_time = randf_range(v1,v2)
|
||||
print("speed: ",speed)
|
||||
#print("speed: ",speed)
|
||||
add_child(hindernis)
|
||||
|
||||
func del_all():
|
||||
|
|
|
@ -9,3 +9,5 @@ func _ready() -> void:
|
|||
func _process(delta: float) -> void:
|
||||
speed = $"..".speed
|
||||
global_position.x -= speed*delta
|
||||
if global_position.x < -30:
|
||||
queue_free()
|
||||
|
|