Pause Button

main
Luna Brovchuk 2023-10-02 23:44:25 +02:00
parent 018267e152
commit 73cdf2aa18
7 changed files with 128 additions and 40 deletions

View File

@ -12,35 +12,36 @@ func _ready():
hp = 8 hp = 8
func _physics_process(delta): func _physics_process(delta):
var dist = global_position.distance_to(player.global_position) if Global.playing:
if dist > 25 and dash_target == Vector2.ZERO: var dist = global_position.distance_to(player.global_position)
$Aim.visible = false if dist > 25 and 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 $Aim.visible = false
dash_timer = 0 global_position = global_position.move_toward(player.global_position, clamp(dist * delta * speed_multiplier, -1, 1))
dashing = true else:
if dash_target == Vector2.ZERO:
if dashing: var angle = global_position.angle_to_point(player.global_position) + PI
global_position = global_position.move_toward(dash_target, 10) $Aim.rotation_degrees = 0
if global_position == dash_target: $Aim.rotate(angle)
dashing = false $Aim.visible = true
afterdash = true $Aim.frame = 0
$Aim.play("idle")
if afterdash: dash_target = global_position + Vector2(60, 0).rotated(angle)
afterdash_timer += delta if dash_target != Vector2.ZERO:
if afterdash_timer >= 1: dash_timer += delta
afterdash = false if dash_timer >= 1.0:
afterdash_timer = .0 $Aim.visible = false
dash_target = Vector2.ZERO 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

View File

@ -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/menu/background/background.png" type="Texture" id=1]
[ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2] [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/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/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/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] [sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 10, 60 ) extents = Vector2( 10, 60 )
@ -234,14 +235,14 @@ margin_right = 40.0
margin_bottom = 44.0 margin_bottom = 44.0
[node name="CastTime" type="Sprite" parent="UIWrapper/UI/Right/CastTime"] [node name="CastTime" type="Sprite" parent="UIWrapper/UI/Right/CastTime"]
position = Vector2( 256, 140 ) position = Vector2( 231, 140 )
texture = ExtResource( 7 ) texture = ExtResource( 7 )
[node name="CastTimeLabel" type="Label" parent="UIWrapper/UI/Right/CastTime"] [node name="CastTimeLabel" type="Label" parent="UIWrapper/UI/Right/CastTime"]
modulate = Color( 1, 0.870588, 0, 1 ) modulate = Color( 1, 0.870588, 0, 1 )
margin_left = 266.0 margin_left = 241.0
margin_top = 133.0 margin_top = 133.0
margin_right = 306.0 margin_right = 281.0
margin_bottom = 147.0 margin_bottom = 147.0
theme = ExtResource( 4 ) theme = ExtResource( 4 )
text = "0.8" text = "0.8"
@ -252,18 +253,28 @@ margin_right = 40.0
margin_bottom = 41.0 margin_bottom = 41.0
[node name="Damage" type="Sprite" parent="UIWrapper/UI/Right/Damage"] [node name="Damage" type="Sprite" parent="UIWrapper/UI/Right/Damage"]
position = Vector2( 256, 160 ) position = Vector2( 231, 160 )
texture = ExtResource( 22 ) texture = ExtResource( 22 )
[node name="DamageLabel" type="Label" parent="UIWrapper/UI/Right/Damage"] [node name="DamageLabel" type="Label" parent="UIWrapper/UI/Right/Damage"]
modulate = Color( 1, 0.870588, 0, 1 ) modulate = Color( 1, 0.870588, 0, 1 )
margin_left = 266.0 margin_left = 241.0
margin_top = 153.0 margin_top = 153.0
margin_right = 306.0 margin_right = 281.0
margin_bottom = 167.0 margin_bottom = 167.0
theme = ExtResource( 4 ) theme = ExtResource( 4 )
text = "15" 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"] [node name="Cards" type="Control" parent="UIWrapper/UI"]
visible = false visible = false
margin_right = 320.0 margin_right = 320.0
@ -310,3 +321,5 @@ id = 2
[node name="AudioCardSelect" type="AudioStreamPlayer" parent="UIWrapper/UI/Cards/RightPlaceholder"] [node name="AudioCardSelect" type="AudioStreamPlayer" parent="UIWrapper/UI/Cards/RightPlaceholder"]
stream = ExtResource( 9 ) stream = ExtResource( 9 )
[connection signal="pressed" from="UIWrapper/UI/Right/Pause" to="." method="pause_pressed"]

View File

@ -26,7 +26,7 @@ var spells = [
func _ready(): func _ready():
Global.playing = true Global.playing = true
Global.play_time = .0 Global.play_time = 300
Global.health = 5 Global.health = 5
Global.add_health(0) Global.add_health(0)
@ -73,9 +73,13 @@ func select_card():
func _process(delta): func _process(delta):
update_ui() update_ui()
func update_ui(): func update_ui():
var player = $View/Player var player = $View/Player
$UIWrapper/UI/Right/CastTime/CastTimeLabel.text = String(player.get_recharge()) $UIWrapper/UI/Right/CastTime/CastTimeLabel.text = String(player.get_recharge())
$UIWrapper/UI/Right/Damage/DamageLabel.text = String(player.get_damage()) $UIWrapper/UI/Right/Damage/DamageLabel.text = String(player.get_damage())
$UIWrapper/UI/Left/LevelLabel.text = String(difficulty + 1) $UIWrapper/UI/Left/LevelLabel.text = String(difficulty + 1)
$UIWrapper/UI/Right/Pause.pressed = Global.playing
func pause_pressed():
Global.playing = !Global.playing

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -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