From a49238f4409cc704e5dc09b4913fdd53e2a11201 Mon Sep 17 00:00:00 2001 From: noyciy7037 Date: Wed, 3 Jan 2024 13:40:31 +0900 Subject: [PATCH] playable --- assets/images/bullet/shot.svg | 50 ++++++++++++++++++++++ assets/images/bullet/shot.svg.import | 37 +++++++++++++++++ assets/images/effect/death0.svg | 20 +++++++++ assets/images/effect/death0.svg.import | 37 +++++++++++++++++ assets/images/effect/death1.svg | 25 +++++++++++ assets/images/effect/death1.svg.import | 37 +++++++++++++++++ assets/images/effect/death2.svg | 20 +++++++++ assets/images/effect/death2.svg.import | 37 +++++++++++++++++ assets/images/mob/mob_A0.svg | 46 +++++++++++++++++++++ assets/images/mob/mob_A0.svg.import | 37 +++++++++++++++++ assets/images/mob/mob_A1.svg | 46 +++++++++++++++++++++ assets/images/mob/mob_A1.svg.import | 37 +++++++++++++++++ assets/images/player/mob_A1.svg | 46 +++++++++++++++++++++ assets/images/player/mob_A1.svg.import | 37 +++++++++++++++++ entity/Player.gd | 21 ++++++++-- entity/bullet/shot.gd | 11 +++++ entity/bullet/shot.tscn | 22 ++++++++++ entity/mob/mob_enemy.gd | 21 ++++++++++ entity/mob/mob_enemy.tscn | 57 ++++++++++++++++++++++++++ entity/player.tscn | 5 ++- project.godot | 17 ++++++++ scene/stage_1.gd | 13 +++++- scene/stage_1.tscn | 28 ++++++++++++- scene/title.gd | 9 +++- scene/title.tscn | 5 ++- ui/game_ui.gd | 5 +-- ui/game_ui.tscn | 18 +++++++- 27 files changed, 729 insertions(+), 15 deletions(-) create mode 100644 assets/images/bullet/shot.svg create mode 100644 assets/images/bullet/shot.svg.import create mode 100644 assets/images/effect/death0.svg create mode 100644 assets/images/effect/death0.svg.import create mode 100644 assets/images/effect/death1.svg create mode 100644 assets/images/effect/death1.svg.import create mode 100644 assets/images/effect/death2.svg create mode 100644 assets/images/effect/death2.svg.import create mode 100644 assets/images/mob/mob_A0.svg create mode 100644 assets/images/mob/mob_A0.svg.import create mode 100644 assets/images/mob/mob_A1.svg create mode 100644 assets/images/mob/mob_A1.svg.import create mode 100644 assets/images/player/mob_A1.svg create mode 100644 assets/images/player/mob_A1.svg.import create mode 100644 entity/bullet/shot.gd create mode 100644 entity/bullet/shot.tscn create mode 100644 entity/mob/mob_enemy.gd create mode 100644 entity/mob/mob_enemy.tscn diff --git a/assets/images/bullet/shot.svg b/assets/images/bullet/shot.svg new file mode 100644 index 0000000..a553dc7 --- /dev/null +++ b/assets/images/bullet/shot.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + diff --git a/assets/images/bullet/shot.svg.import b/assets/images/bullet/shot.svg.import new file mode 100644 index 0000000..84446f7 --- /dev/null +++ b/assets/images/bullet/shot.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://djrsq3b36qbwp" +path="res://.godot/imported/shot.svg-9a0b4bb3b50c9c15ca31472858929761.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/bullet/shot.svg" +dest_files=["res://.godot/imported/shot.svg-9a0b4bb3b50c9c15ca31472858929761.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/images/effect/death0.svg b/assets/images/effect/death0.svg new file mode 100644 index 0000000..d9693ad --- /dev/null +++ b/assets/images/effect/death0.svg @@ -0,0 +1,20 @@ + + + + diff --git a/assets/images/effect/death0.svg.import b/assets/images/effect/death0.svg.import new file mode 100644 index 0000000..88f4796 --- /dev/null +++ b/assets/images/effect/death0.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bgbjvearadscl" +path="res://.godot/imported/death0.svg-d517042a7cb46a6fbd47c0e0f00fe2df.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/effect/death0.svg" +dest_files=["res://.godot/imported/death0.svg-d517042a7cb46a6fbd47c0e0f00fe2df.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/images/effect/death1.svg b/assets/images/effect/death1.svg new file mode 100644 index 0000000..228a214 --- /dev/null +++ b/assets/images/effect/death1.svg @@ -0,0 +1,25 @@ + + + + diff --git a/assets/images/effect/death1.svg.import b/assets/images/effect/death1.svg.import new file mode 100644 index 0000000..ba1e862 --- /dev/null +++ b/assets/images/effect/death1.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cbwskucribly0" +path="res://.godot/imported/death1.svg-f1f1d0f410c641c72ace9e657f43f4d7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/effect/death1.svg" +dest_files=["res://.godot/imported/death1.svg-f1f1d0f410c641c72ace9e657f43f4d7.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/images/effect/death2.svg b/assets/images/effect/death2.svg new file mode 100644 index 0000000..072f291 --- /dev/null +++ b/assets/images/effect/death2.svg @@ -0,0 +1,20 @@ + + + + diff --git a/assets/images/effect/death2.svg.import b/assets/images/effect/death2.svg.import new file mode 100644 index 0000000..52e00d0 --- /dev/null +++ b/assets/images/effect/death2.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://blbv74h0mwgwe" +path="res://.godot/imported/death2.svg-5b5210ee2b761d1def9ddfafbaf063d4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/effect/death2.svg" +dest_files=["res://.godot/imported/death2.svg-5b5210ee2b761d1def9ddfafbaf063d4.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/images/mob/mob_A0.svg b/assets/images/mob/mob_A0.svg new file mode 100644 index 0000000..b203b69 --- /dev/null +++ b/assets/images/mob/mob_A0.svg @@ -0,0 +1,46 @@ + + + + diff --git a/assets/images/mob/mob_A0.svg.import b/assets/images/mob/mob_A0.svg.import new file mode 100644 index 0000000..fd8c4f9 --- /dev/null +++ b/assets/images/mob/mob_A0.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://2er7ud1ssj70" +path="res://.godot/imported/mob_A0.svg-02276270234100b033e0f858c8e66e8f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/mob/mob_A0.svg" +dest_files=["res://.godot/imported/mob_A0.svg-02276270234100b033e0f858c8e66e8f.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/images/mob/mob_A1.svg b/assets/images/mob/mob_A1.svg new file mode 100644 index 0000000..3ed2e39 --- /dev/null +++ b/assets/images/mob/mob_A1.svg @@ -0,0 +1,46 @@ + + + + diff --git a/assets/images/mob/mob_A1.svg.import b/assets/images/mob/mob_A1.svg.import new file mode 100644 index 0000000..7f7b3e1 --- /dev/null +++ b/assets/images/mob/mob_A1.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://txkug16xogsh" +path="res://.godot/imported/mob_A1.svg-213c5bea531e8e7f89cbc4686e5908f9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/mob/mob_A1.svg" +dest_files=["res://.godot/imported/mob_A1.svg-213c5bea531e8e7f89cbc4686e5908f9.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/images/player/mob_A1.svg b/assets/images/player/mob_A1.svg new file mode 100644 index 0000000..442e927 --- /dev/null +++ b/assets/images/player/mob_A1.svg @@ -0,0 +1,46 @@ + + + + diff --git a/assets/images/player/mob_A1.svg.import b/assets/images/player/mob_A1.svg.import new file mode 100644 index 0000000..7c82318 --- /dev/null +++ b/assets/images/player/mob_A1.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dalgye6fkcmda" +path="res://.godot/imported/mob_A1.svg-a6ab08843b45cf5f34a7ee9afbbd2420.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/player/mob_A1.svg" +dest_files=["res://.godot/imported/mob_A1.svg-a6ab08843b45cf5f34a7ee9afbbd2420.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/entity/Player.gd b/entity/Player.gd index 4443590..bab4eea 100644 --- a/entity/Player.gd +++ b/entity/Player.gd @@ -1,16 +1,20 @@ extends Area2D @export var speed = 400 -var screen_size +@export var shot_scene: PackedScene +var finalShot = 0.0 + +signal shot_signal # Called when the node enters the scene tree for the first time. func _ready(): - screen_size = get_viewport_rect().size + pass # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): var velocity = Vector2.ZERO # The player's movement vector. + var rate = 1 if Input.is_action_pressed("move_right"): velocity.x += 1 if Input.is_action_pressed("move_left"): @@ -19,9 +23,20 @@ func _process(delta): velocity.y += 1 if Input.is_action_pressed("move_up"): velocity.y -= 1 + if Input.is_action_pressed("slow"): + rate = 0.5 + if Input.is_action_pressed(("shot")) and finalShot > 0.1: + var shot = shot_scene.instantiate() + shot.linear_velocity = Vector2(0,-800) + shot.position = position + # ステージに生成を指示 + shot_signal.emit(shot) + finalShot = 0 + + finalShot += delta if velocity.length() > 0: - velocity = velocity.normalized() * speed + velocity = velocity.normalized() * speed * rate $AnimatedSprite2D.play() else: $AnimatedSprite2D.stop() diff --git a/entity/bullet/shot.gd b/entity/bullet/shot.gd new file mode 100644 index 0000000..06a183f --- /dev/null +++ b/entity/bullet/shot.gd @@ -0,0 +1,11 @@ +extends RigidBody2D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass diff --git a/entity/bullet/shot.tscn b/entity/bullet/shot.tscn new file mode 100644 index 0000000..cd64327 --- /dev/null +++ b/entity/bullet/shot.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://b2biksphf4kpn"] + +[ext_resource type="Script" path="res://entity/bullet/shot.gd" id="1_2tnht"] +[ext_resource type="Texture2D" uid="uid://djrsq3b36qbwp" path="res://assets/images/bullet/shot.svg" id="1_gt67b"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_du5u8"] +radius = 13.0384 + +[node name="Shot" type="RigidBody2D"] +collision_layer = 2 +collision_mask = 4 +gravity_scale = 0.0 +linear_damp_mode = 1 +angular_damp_mode = 1 +script = ExtResource("1_2tnht") +metadata/_edit_group_ = true + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_gt67b") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_du5u8") diff --git a/entity/mob/mob_enemy.gd b/entity/mob/mob_enemy.gd new file mode 100644 index 0000000..822a78c --- /dev/null +++ b/entity/mob/mob_enemy.gd @@ -0,0 +1,21 @@ +extends Area2D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + var mob_types = $AnimatedSprite2D.sprite_frames.get_animation_names() + #$AnimatedSprite2D.play(mob_types[randi() % mob_types.size()]) + $AnimatedSprite2D.play("mobA") + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_body_entered(body): + $CollisionShape2D.set_deferred("disabled", true) + var playerSprite = $AnimatedSprite2D + playerSprite.play("death") + await playerSprite.animation_finished + queue_free() diff --git a/entity/mob/mob_enemy.tscn b/entity/mob/mob_enemy.tscn new file mode 100644 index 0000000..ef94d6d --- /dev/null +++ b/entity/mob/mob_enemy.tscn @@ -0,0 +1,57 @@ +[gd_scene load_steps=9 format=3 uid="uid://bp6kld25usim4"] + +[ext_resource type="Texture2D" uid="uid://2er7ud1ssj70" path="res://assets/images/mob/mob_A0.svg" id="1_m208q"] +[ext_resource type="Script" path="res://entity/mob/mob_enemy.gd" id="1_nmxwn"] +[ext_resource type="Texture2D" uid="uid://txkug16xogsh" path="res://assets/images/mob/mob_A1.svg" id="2_ho6m5"] +[ext_resource type="Texture2D" uid="uid://bgbjvearadscl" path="res://assets/images/effect/death0.svg" id="2_v08g0"] +[ext_resource type="Texture2D" uid="uid://cbwskucribly0" path="res://assets/images/effect/death1.svg" id="3_qfb3p"] +[ext_resource type="Texture2D" uid="uid://blbv74h0mwgwe" path="res://assets/images/effect/death2.svg" id="4_dqgde"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_620mj"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_v08g0") +}, { +"duration": 1.0, +"texture": ExtResource("3_qfb3p") +}, { +"duration": 1.0, +"texture": ExtResource("4_dqgde") +}], +"loop": false, +"name": &"death", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("1_m208q") +}, { +"duration": 1.0, +"texture": ExtResource("2_ho6m5") +}], +"loop": true, +"name": &"mobA", +"speed": 8.0 +}] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_dopta"] +radius = 22.0 +height = 80.0 + +[node name="MobEnemy" type="Area2D"] +collision_layer = 4 +collision_mask = 2 +script = ExtResource("1_nmxwn") +metadata/_edit_group_ = true + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.6, 0.6) +sprite_frames = SubResource("SpriteFrames_620mj") +animation = &"death" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 1.5708 +shape = SubResource("CapsuleShape2D_dopta") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/entity/player.tscn b/entity/player.tscn index 7f9cffe..143a967 100644 --- a/entity/player.tscn +++ b/entity/player.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=10 format=3 uid="uid://djokiepdvy3r4"] +[gd_scene load_steps=11 format=3 uid="uid://djokiepdvy3r4"] [ext_resource type="Script" path="res://entity/Player.gd" id="1_wbhmb"] [ext_resource type="Texture2D" uid="uid://bk7g7e8esssyj" path="res://assets/images/player/up0.png" id="2_lkbqe"] +[ext_resource type="PackedScene" uid="uid://b2biksphf4kpn" path="res://entity/bullet/shot.tscn" id="2_wtk07"] [ext_resource type="Texture2D" uid="uid://dqhbikc2p5eqy" path="res://assets/images/player/up1.png" id="3_81m7d"] [ext_resource type="Texture2D" uid="uid://d3kwb3cf58ano" path="res://assets/images/player/up2.png" id="4_oshyc"] [ext_resource type="Texture2D" uid="uid://cnhmnm7ow2ctf" path="res://assets/images/player/walk0.png" id="5_yac28"] @@ -48,7 +49,9 @@ animations = [{ [sub_resource type="CircleShape2D" id="CircleShape2D_cvy7c"] [node name="Player" type="Area2D"] +collision_mask = 12 script = ExtResource("1_wbhmb") +shot_scene = ExtResource("2_wtk07") metadata/_edit_group_ = true [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] diff --git a/project.godot b/project.godot index ba96147..dd02dc8 100644 --- a/project.godot +++ b/project.godot @@ -52,6 +52,23 @@ move_right={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null) ] } +slow={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +shot={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":122,"echo":false,"script":null) +] +} + +[layer_names] + +2d_physics/layer_1="player" +2d_physics/layer_2="shot" +2d_physics/layer_3="enemy" +2d_physics/layer_4="bullet" [rendering] diff --git a/scene/stage_1.gd b/scene/stage_1.gd index e08925d..e90d8df 100644 --- a/scene/stage_1.gd +++ b/scene/stage_1.gd @@ -1,11 +1,20 @@ extends Node +var time = 0 # Called when the node enters the scene tree for the first time. func _ready(): - pass # Replace with function body. + $Player.position = $StartPos.position # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - pass + time += delta + + +func _on_player_shot_signal(shot): + add_child(shot) + + +func _on_game_body_exited(body): + body.queue_free() diff --git a/scene/stage_1.tscn b/scene/stage_1.tscn index b9b5312..7448ae4 100644 --- a/scene/stage_1.tscn +++ b/scene/stage_1.tscn @@ -1,12 +1,38 @@ -[gd_scene load_steps=4 format=3 uid="uid://t4bkano14bq8"] +[gd_scene load_steps=5 format=3 uid="uid://t4bkano14bq8"] [ext_resource type="PackedScene" uid="uid://djokiepdvy3r4" path="res://entity/player.tscn" id="1_iklq5"] [ext_resource type="Script" path="res://scene/stage_1.gd" id="1_xsra1"] [ext_resource type="PackedScene" uid="uid://c1u2s2e48w4pd" path="res://ui/game_ui.tscn" id="2_j74kp"] +[ext_resource type="PackedScene" uid="uid://bp6kld25usim4" path="res://entity/mob/mob_enemy.tscn" id="4_druno"] [node name="Stage1" type="Node"] script = ExtResource("1_xsra1") [node name="Player" parent="." instance=ExtResource("1_iklq5")] +position = Vector2(480, 1000) [node name="GameUI" parent="." instance=ExtResource("2_j74kp")] + +[node name="Game" type="Area2D" parent="."] +collision_layer = 16 +collision_mask = 14 +metadata/_edit_group_ = true + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Game"] +visible = false +polygon = PackedVector2Array(0, 0, 960, 0, 960, 1080, 0, 1080) + +[node name="MobEnemy" parent="." instance=ExtResource("4_druno")] +position = Vector2(477, 83) + +[node name="MobEnemy2" parent="." instance=ExtResource("4_druno")] +position = Vector2(138, 203) + +[node name="MobEnemy3" parent="." instance=ExtResource("4_druno")] +position = Vector2(783, 206) + +[node name="StartPos" type="Marker2D" parent="."] +position = Vector2(480, 1000) + +[connection signal="shot_signal" from="Player" to="." method="_on_player_shot_signal"] +[connection signal="body_exited" from="Game" to="." method="_on_game_body_exited"] diff --git a/scene/title.gd b/scene/title.gd index 63def90..566f144 100644 --- a/scene/title.gd +++ b/scene/title.gd @@ -1,5 +1,6 @@ extends CanvasLayer +@export var stage1_scene: PackedScene # Called when the node enters the scene tree for the first time. func _ready(): @@ -14,9 +15,13 @@ func _process(delta): quitBtn.grab_focus() func enableExtra(): - $MarginContainer/VBoxContainer/Extra.disabled = false - $MarginContainer/VBoxContainer/Extra.focus_mode = 2 + var extraBtn = $MarginContainer/VBoxContainer/Extra + extraBtn.disabled = false + extraBtn.focus_mode = 2 +func _on_start_pressed(): + get_tree().change_scene_to_packed(stage1_scene) func _on_quit_pressed(): get_tree().quit() + diff --git a/scene/title.tscn b/scene/title.tscn index 3bfb1e6..3862cc9 100644 --- a/scene/title.tscn +++ b/scene/title.tscn @@ -1,12 +1,14 @@ -[gd_scene load_steps=4 format=3 uid="uid://bqyi0a4fcs563"] +[gd_scene load_steps=5 format=3 uid="uid://bqyi0a4fcs563"] [ext_resource type="Script" path="res://scene/title.gd" id="1_5j3g0"] [ext_resource type="FontFile" uid="uid://q5lv1cuadoq5" path="res://fonts/DotGothic16/DotGothic16-Regular.ttf" id="2_bf5un"] +[ext_resource type="PackedScene" uid="uid://t4bkano14bq8" path="res://scene/stage_1.tscn" id="2_clc4v"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tokxl"] [node name="Title" type="CanvasLayer"] script = ExtResource("1_5j3g0") +stage1_scene = ExtResource("2_clc4v") [node name="MarginContainer" type="MarginContainer" parent="."] anchors_preset = 3 @@ -163,4 +165,5 @@ text = "Quit" flat = true alignment = 0 +[connection signal="pressed" from="MarginContainer/VBoxContainer/Start" to="." method="_on_start_pressed"] [connection signal="pressed" from="MarginContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"] diff --git a/ui/game_ui.gd b/ui/game_ui.gd index aaf93b9..97eec95 100644 --- a/ui/game_ui.gd +++ b/ui/game_ui.gd @@ -8,8 +8,5 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - pass + $Panel/Label.set_text("FPS: " + "%s" % Engine.get_frames_per_second()) -func _on_viewport_size_changed(): - # Do whatever you need to do when the window changes! - print ("Viewport size changed") diff --git a/ui/game_ui.tscn b/ui/game_ui.tscn index 3ea5fac..af81223 100644 --- a/ui/game_ui.tscn +++ b/ui/game_ui.tscn @@ -1,10 +1,15 @@ -[gd_scene load_steps=4 format=3 uid="uid://c1u2s2e48w4pd"] +[gd_scene load_steps=6 format=3 uid="uid://c1u2s2e48w4pd"] [ext_resource type="Script" path="res://ui/game_ui.gd" id="1_ritbu"] +[ext_resource type="FontFile" uid="uid://q5lv1cuadoq5" path="res://fonts/DotGothic16/DotGothic16-Regular.ttf" id="2_u12eu"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vehpn"] bg_color = Color(0, 0.65098, 0.882353, 1) +[sub_resource type="LabelSettings" id="LabelSettings_2pcfq"] +font = ExtResource("2_u12eu") +font_size = 50 + [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bsuwx"] bg_color = Color(1, 0.262745, 0.615686, 1) @@ -21,6 +26,17 @@ grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_vehpn") +[node name="Label" type="Label" parent="Panel"] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -73.0 +offset_right = 150.0 +grow_vertical = 0 +text = "FPS: 0" +label_settings = SubResource("LabelSettings_2pcfq") + [node name="Panel2" type="Panel" parent="."] anchors_preset = 15 anchor_right = 1.0