diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn index 940b0be..7425150 100644 --- a/src/models/enemies/bat/Bat.tscn +++ b/src/models/enemies/bat/Bat.tscn @@ -19,6 +19,7 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" +frame = 1 playing = true centered = false diff --git a/src/models/enemies/trash_can/sprites/path/HorizontalTrashPath.tres b/src/models/enemies/trash_can/sprites/path/HorizontalTrashPath.tres new file mode 100644 index 0000000..670bbf0 --- /dev/null +++ b/src/models/enemies/trash_can/sprites/path/HorizontalTrashPath.tres @@ -0,0 +1,51 @@ +[gd_resource type="SpriteFrames" load_steps=10 format=2] + +[ext_resource path="res://src/models/enemies/trash_can/sprites/path/horizontal_animation.png" type="Texture" id=1] + +[sub_resource type="AtlasTexture" id=2] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 280, 11 ) + +[sub_resource type="AtlasTexture" id=3] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 11, 280, 11 ) + +[sub_resource type="AtlasTexture" id=4] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 22, 280, 11 ) + +[sub_resource type="AtlasTexture" id=5] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 33, 280, 11 ) + +[sub_resource type="AtlasTexture" id=6] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 44, 280, 11 ) + +[sub_resource type="AtlasTexture" id=7] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 55, 280, 11 ) + +[sub_resource type="AtlasTexture" id=8] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 66, 280, 11 ) + +[sub_resource type="AtlasTexture" id=9] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 77, 280, 11 ) + +[resource] +animations = [ { +"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ) ], +"loop": false, +"name": "default", +"speed": 7.0 +} ] diff --git a/src/models/enemies/trash_can/sprites/path/VerticalTrashPath.tres b/src/models/enemies/trash_can/sprites/path/VerticalTrashPath.tres new file mode 100644 index 0000000..9a62ea3 --- /dev/null +++ b/src/models/enemies/trash_can/sprites/path/VerticalTrashPath.tres @@ -0,0 +1,41 @@ +[gd_resource type="SpriteFrames" load_steps=8 format=2] + +[ext_resource path="res://src/models/enemies/trash_can/sprites/path/vertical_animation.png" type="Texture" id=1] + +[sub_resource type="AtlasTexture" id=1] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 11, 80 ) + +[sub_resource type="AtlasTexture" id=2] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 11, 0, 11, 80 ) + +[sub_resource type="AtlasTexture" id=3] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 22, 0, 11, 80 ) + +[sub_resource type="AtlasTexture" id=4] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 33, 0, 11, 80 ) + +[sub_resource type="AtlasTexture" id=5] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 44, 0, 11, 80 ) + +[sub_resource type="AtlasTexture" id=6] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 55, 0, 11, 80 ) + +[resource] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ], +"loop": true, +"name": "default", +"speed": 4.0 +} ] diff --git a/src/models/enemies/trash_can/sprites/path/horizontal_animation.png b/src/models/enemies/trash_can/sprites/path/horizontal_animation.png new file mode 100644 index 0000000..a08c66f Binary files /dev/null and b/src/models/enemies/trash_can/sprites/path/horizontal_animation.png differ diff --git a/src/models/enemies/trash_can/sprites/path/horizontal_animation.png.import b/src/models/enemies/trash_can/sprites/path/horizontal_animation.png.import new file mode 100644 index 0000000..ee5c35d --- /dev/null +++ b/src/models/enemies/trash_can/sprites/path/horizontal_animation.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/horizontal_animation.png-677158bb797119f6efe195b3f0db9b77.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/models/enemies/trash_can/sprites/path/horizontal_animation.png" +dest_files=[ "res://.import/horizontal_animation.png-677158bb797119f6efe195b3f0db9b77.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/models/enemies/trash_can/sprites/path/vertical_animation.png b/src/models/enemies/trash_can/sprites/path/vertical_animation.png new file mode 100644 index 0000000..64c27af Binary files /dev/null and b/src/models/enemies/trash_can/sprites/path/vertical_animation.png differ diff --git a/src/models/enemies/trash_can/sprites/path/vertical_animation.png.import b/src/models/enemies/trash_can/sprites/path/vertical_animation.png.import new file mode 100644 index 0000000..7aece2e --- /dev/null +++ b/src/models/enemies/trash_can/sprites/path/vertical_animation.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/vertical_animation.png-beaba353508fb9af321ce76c797ad7f8.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/models/enemies/trash_can/sprites/path/vertical_animation.png" +dest_files=[ "res://.import/vertical_animation.png-beaba353508fb9af321ce76c797ad7f8.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/models/enemies/trash_can/trash_can.gd b/src/models/enemies/trash_can/trash_can.gd index f7c2cb8..d7b2d51 100644 --- a/src/models/enemies/trash_can/trash_can.gd +++ b/src/models/enemies/trash_can/trash_can.gd @@ -10,43 +10,52 @@ var drop_timer = .0 var last_x var last_y +var horizontal_path = load("res://src/models/enemies/trash_can/sprites/path/HorizontalTrashPath.tres") +var vertical_path = load("res://src/models/enemies/trash_can/sprites/path/VerticalTrashPath.tres") var drop_preload = preload("res://src/models/enemies/trash_can/drop/TrashDrop.tscn") -var path_sprite = Sprite.new() +var path_sprite = AnimatedSprite.new() var horizontal_speed = 160 var vertical_speed = 60 +func delete_path_sprite(): + path_sprite.call_deferred("free") + func _ready(): - path_sprite.name = "trash_path" + path_sprite.name = "TrashPath" + path_sprite.centered = false randomize() movement_type = ["horizontal", "vertical"][randi()%2] if movement_type == "vertical": + path_sprite.frames = vertical_path + path_sprite.flip_v = true movement_start = "top" randomize() - global_position.x = randi()%248 + 40 # 320 - 12 - 40 + global_position.x = randi()%218 + 90 # 320 - 12 - 40 global_position.y = 4 - path_sprite.texture = load("res://src/models/enemies/trash_can/sprites/path/vertical.png") path_sprite.global_position.y = 21 path_sprite.global_position.x = self.global_position.x else: + path_sprite.frames = horizontal_path randomize() movement_start = ["left", "right"][randi()%2] randomize() - global_position.y = randi()%60 + 20 + global_position.y = randi()%50 + 25 global_position.x = 310 if movement_start == "right" else 10 - path_sprite.texture = load("res://src/models/enemies/trash_can/sprites/path/horizontal.png") + if movement_start == "left": path_sprite.flip_h = true path_sprite.global_position.y = self.global_position.y path_sprite.global_position.x = 26 last_x = self.global_position.x last_y = self.global_position.y - path_sprite.centered = false - path_sprite.modulate.a = 0.5 get_parent().call_deferred("add_child", path_sprite) + path_sprite.connect("animation_finished", self, "delete_path_sprite") + path_sprite.frame = 0 + path_sprite.play("default") func drop_trash(): var trash_drop = drop_preload.instance() @@ -54,18 +63,14 @@ func drop_trash(): get_parent().call_deferred("add_child", trash_drop) func _physics_process(delta): - if start_timer < 1: - path_sprite.modulate.a = (1 - start_timer) / 2 - start_timer += delta - return drop_timer += delta + start_timer += delta velocity = Vector2.ZERO if movement_type == "horizontal": if movement_start == "left": velocity.x += horizontal_speed if self.global_position.x > 360: - path_sprite.call_deferred("free") self.call_deferred("free") if self.global_position.x > last_x + 7: last_x = self.global_position.x @@ -73,7 +78,6 @@ func _physics_process(delta): else: velocity.x -= horizontal_speed if self.global_position.x < 0: - path_sprite.call_deferred("free") self.call_deferred("free") if self.global_position.x < last_x - 7: last_x = self.global_position.x @@ -82,13 +86,13 @@ func _physics_process(delta): else: velocity.y += vertical_speed if self.global_position.y > 160: - path_sprite.call_deferred("free") self.call_deferred("free") if self.global_position.y > last_y + 7: last_y = self.global_position.y drop_trash() - - velocity = move_and_slide(velocity) + + if start_timer >= 1.25: + velocity = move_and_slide(velocity) func _on_sprite_animation_finished(): if $Sprite.animation == "spawn": @@ -96,3 +100,4 @@ func _on_sprite_animation_finished(): func _on_Spawn_Animation_Start_timeout(): $Sprite.play("spawn") + diff --git a/src/scenes/game/Game.tscn b/src/scenes/game/Game.tscn index 7ef2729..69c4210 100644 --- a/src/scenes/game/Game.tscn +++ b/src/scenes/game/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=2] +[gd_scene load_steps=22 format=2] [ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1] [ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2] @@ -14,6 +14,7 @@ [ext_resource path="res://src/scenes/game/sprites/ui_background.png" type="Texture" id=12] [ext_resource path="res://src/scenes/game/sprites/hatch1.png" type="Texture" id=13] [ext_resource path="res://src/scenes/game/sprites/hatch2.png" type="Texture" id=14] +[ext_resource path="res://src/scenes/game/sprites/gameover.png" type="Texture" id=15] [ext_resource path="res://src/scenes/game/spell_recharge_bar.gd" type="Script" id=16] [sub_resource type="RectangleShape2D" id=2] @@ -30,6 +31,37 @@ animations = [ { "speed": 5.0 } ] +[sub_resource type="Animation" id=5] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath("Sprite:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 0 ) ] +} + +[sub_resource type="Animation" id=6] +resource_name = "gameover" +length = 3.0 +tracks/0/type = "value" +tracks/0/path = NodePath("Sprite:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.1, 1.5, 3 ), +"transitions": PoolRealArray( 3.24901, 29.8571, 2, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 0, 0, 0, 1 ) ] +} + [node name="Game" type="Node"] script = ExtResource( 11 ) @@ -171,3 +203,16 @@ margin_bottom = 3.0 [node name="Right" type="Control" parent="UIWrapper/UI"] margin_right = 40.0 margin_bottom = 40.0 + +[node name="Gameover" type="Control" parent="UIWrapper"] +margin_right = 320.0 +margin_bottom = 180.0 + +[node name="Sprite" type="Sprite" parent="UIWrapper/Gameover"] +modulate = Color( 1, 1, 1, 0 ) +texture = ExtResource( 15 ) +centered = false + +[node name="AnimationPlayer" type="AnimationPlayer" parent="UIWrapper/Gameover"] +anims/RESET = SubResource( 5 ) +anims/gameover = SubResource( 6 ) diff --git a/src/scenes/game/game.gd b/src/scenes/game/game.gd index 3869fe6..c6c3895 100644 --- a/src/scenes/game/game.gd +++ b/src/scenes/game/game.gd @@ -13,8 +13,8 @@ var mob_threshold = [5, 7, 10, 7] func _ready(): Global.playing = true - Global.play_time = 70 - Global.health = 3 + Global.play_time = 120 + Global.health = 1 Global.add_health(0) func pause(): diff --git a/src/scenes/game/sprites/gameover.png b/src/scenes/game/sprites/gameover.png new file mode 100644 index 0000000..f7bc88a Binary files /dev/null and b/src/scenes/game/sprites/gameover.png differ diff --git a/src/scenes/game/sprites/gameover.png.import b/src/scenes/game/sprites/gameover.png.import new file mode 100644 index 0000000..efc7465 --- /dev/null +++ b/src/scenes/game/sprites/gameover.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/gameover.png-46b9ccb4c7936f430dcf3c2c305dfc1e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/scenes/game/sprites/gameover.png" +dest_files=[ "res://.import/gameover.png-46b9ccb4c7936f430dcf3c2c305dfc1e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/scripts/global.gd b/src/scripts/global.gd index b46bfd2..cda2a9f 100644 --- a/src/scripts/global.gd +++ b/src/scripts/global.gd @@ -18,4 +18,8 @@ func add_health(amount): health = clamp(health + amount, 0, 3) get_tree().get_root().get_node("Game/UIWrapper/UI/Left/Health/HealthSprite").frame = health if health == 0: - return_to_menu() # TODO endgame + playing = false + var animplayer = get_tree().get_root().get_node("Game/UIWrapper/Gameover/AnimationPlayer") + animplayer.play("gameover") + yield(animplayer, "animation_finished") + return_to_menu()