diff --git a/src/models/enemies/ghost/ghost.gd b/src/models/enemies/ghost/ghost.gd index fc196b1..0bef006 100644 --- a/src/models/enemies/ghost/ghost.gd +++ b/src/models/enemies/ghost/ghost.gd @@ -12,35 +12,36 @@ func _ready(): hp = 8 func _physics_process(delta): - var dist = global_position.distance_to(player.global_position) - if dist > 25 and dash_target == Vector2.ZERO: - $Aim.visible = false - global_position = global_position.move_toward(player.global_position, clamp(dist * delta * speed_multiplier, -1, 1)) - else: - if dash_target == Vector2.ZERO: - var angle = global_position.angle_to_point(player.global_position) + PI - $Aim.rotation_degrees = 0 - $Aim.rotate(angle) - $Aim.visible = true - $Aim.frame = 0 - $Aim.play("idle") - dash_target = global_position + Vector2(60, 0).rotated(angle) - if dash_target != Vector2.ZERO: - dash_timer += delta - if dash_timer >= 1.0: + if Global.playing: + var dist = global_position.distance_to(player.global_position) + if dist > 25 and dash_target == Vector2.ZERO: $Aim.visible = false - dash_timer = 0 - dashing = true - - if dashing: - global_position = global_position.move_toward(dash_target, 10) - if global_position == dash_target: - dashing = false - afterdash = true - - if afterdash: - afterdash_timer += delta - if afterdash_timer >= 1: - afterdash = false - afterdash_timer = .0 - dash_target = Vector2.ZERO + global_position = global_position.move_toward(player.global_position, clamp(dist * delta * speed_multiplier, -1, 1)) + else: + if dash_target == Vector2.ZERO: + var angle = global_position.angle_to_point(player.global_position) + PI + $Aim.rotation_degrees = 0 + $Aim.rotate(angle) + $Aim.visible = true + $Aim.frame = 0 + $Aim.play("idle") + dash_target = global_position + Vector2(60, 0).rotated(angle) + if dash_target != Vector2.ZERO: + dash_timer += delta + if dash_timer >= 1.0: + $Aim.visible = false + dash_timer = 0 + dashing = true + + if dashing: + global_position = global_position.move_toward(dash_target, 10) + if global_position == dash_target: + dashing = false + afterdash = true + + if afterdash: + afterdash_timer += delta + if afterdash_timer >= 1: + afterdash = false + afterdash_timer = .0 + dash_target = Vector2.ZERO diff --git a/src/scenes/game/Game.tscn b/src/scenes/game/Game.tscn index 6b78608..7603b6e 100644 --- a/src/scenes/game/Game.tscn +++ b/src/scenes/game/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=25 format=2] +[gd_scene load_steps=26 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] @@ -22,6 +22,7 @@ [ext_resource path="res://src/scenes/game/camera.gd" type="Script" id=20] [ext_resource path="res://src/scenes/game/sprites/shake_border.png" type="Texture" id=21] [ext_resource path="res://src/scenes/game/sprites/damage.png" type="Texture" id=22] +[ext_resource path="res://src/scenes/game/sprites/pause.png" type="Texture" id=23] [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 10, 60 ) @@ -234,14 +235,14 @@ margin_right = 40.0 margin_bottom = 44.0 [node name="CastTime" type="Sprite" parent="UIWrapper/UI/Right/CastTime"] -position = Vector2( 256, 140 ) +position = Vector2( 231, 140 ) texture = ExtResource( 7 ) [node name="CastTimeLabel" type="Label" parent="UIWrapper/UI/Right/CastTime"] modulate = Color( 1, 0.870588, 0, 1 ) -margin_left = 266.0 +margin_left = 241.0 margin_top = 133.0 -margin_right = 306.0 +margin_right = 281.0 margin_bottom = 147.0 theme = ExtResource( 4 ) text = "0.8" @@ -252,18 +253,28 @@ margin_right = 40.0 margin_bottom = 41.0 [node name="Damage" type="Sprite" parent="UIWrapper/UI/Right/Damage"] -position = Vector2( 256, 160 ) +position = Vector2( 231, 160 ) texture = ExtResource( 22 ) [node name="DamageLabel" type="Label" parent="UIWrapper/UI/Right/Damage"] modulate = Color( 1, 0.870588, 0, 1 ) -margin_left = 266.0 +margin_left = 241.0 margin_top = 153.0 -margin_right = 306.0 +margin_right = 281.0 margin_bottom = 167.0 theme = ExtResource( 4 ) text = "15" +[node name="Pause" type="Button" parent="UIWrapper/UI/Right"] +margin_left = 272.0 +margin_top = 143.0 +margin_right = 298.0 +margin_bottom = 163.0 +toggle_mode = true +icon = ExtResource( 23 ) +flat = true +icon_align = 1 + [node name="Cards" type="Control" parent="UIWrapper/UI"] visible = false margin_right = 320.0 @@ -310,3 +321,5 @@ id = 2 [node name="AudioCardSelect" type="AudioStreamPlayer" parent="UIWrapper/UI/Cards/RightPlaceholder"] stream = ExtResource( 9 ) + +[connection signal="pressed" from="UIWrapper/UI/Right/Pause" to="." method="pause_pressed"] diff --git a/src/scenes/game/game.gd b/src/scenes/game/game.gd index 20965f4..7203417 100644 --- a/src/scenes/game/game.gd +++ b/src/scenes/game/game.gd @@ -26,7 +26,7 @@ var spells = [ func _ready(): Global.playing = true - Global.play_time = .0 + Global.play_time = 300 Global.health = 5 Global.add_health(0) @@ -73,9 +73,13 @@ func select_card(): func _process(delta): update_ui() - + func update_ui(): var player = $View/Player $UIWrapper/UI/Right/CastTime/CastTimeLabel.text = String(player.get_recharge()) $UIWrapper/UI/Right/Damage/DamageLabel.text = String(player.get_damage()) $UIWrapper/UI/Left/LevelLabel.text = String(difficulty + 1) + $UIWrapper/UI/Right/Pause.pressed = Global.playing + +func pause_pressed(): + Global.playing = !Global.playing diff --git a/src/scenes/game/sprites/pause.png b/src/scenes/game/sprites/pause.png new file mode 100644 index 0000000..21b9e66 Binary files /dev/null and b/src/scenes/game/sprites/pause.png differ diff --git a/src/scenes/game/sprites/pause.png.import b/src/scenes/game/sprites/pause.png.import new file mode 100644 index 0000000..300bbd8 --- /dev/null +++ b/src/scenes/game/sprites/pause.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/pause.png-73f4605a5328cf93fa6ccbedbb975603.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/scenes/game/sprites/pause.png" +dest_files=[ "res://.import/pause.png-73f4605a5328cf93fa6ccbedbb975603.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/scenes/game/sprites/resume.png b/src/scenes/game/sprites/resume.png new file mode 100644 index 0000000..be39016 Binary files /dev/null and b/src/scenes/game/sprites/resume.png differ diff --git a/src/scenes/game/sprites/resume.png.import b/src/scenes/game/sprites/resume.png.import new file mode 100644 index 0000000..1fdcae5 --- /dev/null +++ b/src/scenes/game/sprites/resume.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/resume.png-9833efb9cb068bfb68c4ea72b39d9d12.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/scenes/game/sprites/resume.png" +dest_files=[ "res://.import/resume.png-9833efb9cb068bfb68c4ea72b39d9d12.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=true +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=true +svg/scale=1.0