diff --git a/src/models/player/player.gd b/src/models/player/player.gd index 0d50d8e..ea828cf 100644 --- a/src/models/player/player.gd +++ b/src/models/player/player.gd @@ -5,6 +5,7 @@ var outline_material = load("res://res/shaders/outline_material.tres") var speed_multiplier: float = 1.0 var invincibility_timer = .0 var velocity = Vector2.ZERO +var recharge_timer = .0 var invincible = false var target: EnemyClass var slowed = false @@ -60,6 +61,9 @@ func area_entered(area): invincible = true invincibility_timer = .0 +func get_recharge(): + return 2.0 + func _shoot(): bullet = bullet_preload.instance() bullet.target = target @@ -77,14 +81,17 @@ func _process(_delta): if abs(velocity.x) > 10: $Sprite.flip_h = true if velocity.x < 0 else false - if Input.is_action_just_pressed("shoot"): - _shoot() update() func _physics_process(delta): get_input() invincibility_timer += delta + recharge_timer += delta + + if recharge_timer >= get_recharge(): + _shoot() + recharge_timer = .0 var areas = $EnemyCollision.get_overlapping_areas() slowed = false diff --git a/src/scenes/game/Game.tscn b/src/scenes/game/Game.tscn index af96e17..94a15ca 100644 --- a/src/scenes/game/Game.tscn +++ b/src/scenes/game/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=20 format=2] +[gd_scene load_steps=21 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] @@ -15,6 +15,7 @@ [ext_resource path="res://src/models/enemies/trash_can/TrashCan.tscn" type="PackedScene" id=13] [ext_resource path="res://src/models/enemies/bat/Bat.tscn" type="PackedScene" id=14] [ext_resource path="res://src/models/enemies/ghost/Ghost.tscn" type="PackedScene" id=15] +[ext_resource path="res://src/scenes/game/spell_recharge_bar.gd" type="Script" id=16] [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 10, 60 ) @@ -126,6 +127,17 @@ frames = SubResource( 4 ) frame = 2 centered = false +[node name="SpellRechargeBar" type="Control" parent="UIWrapper/UI"] +margin_left = 120.0 +margin_top = 162.0 +margin_right = 200.0 +margin_bottom = 165.0 +script = ExtResource( 16 ) + +[node name="ColorRect" type="ColorRect" parent="UIWrapper/UI/SpellRechargeBar"] +margin_right = 80.0 +margin_bottom = 3.0 + [node name="PlayerIcon" type="Sprite" parent="UIWrapper/UI"] position = Vector2( 20, 134 ) texture = ExtResource( 10 ) diff --git a/src/scenes/game/spell_recharge_bar.gd b/src/scenes/game/spell_recharge_bar.gd new file mode 100644 index 0000000..70107b7 --- /dev/null +++ b/src/scenes/game/spell_recharge_bar.gd @@ -0,0 +1,7 @@ +extends Control + +onready var player = get_tree().get_root().get_node("Game/View/Player") +var max_size = 80 + +func _process(delta): + $ColorRect.rect_size.x = max_size * (player.recharge_timer / player.get_recharge()) diff --git a/src/scenes/game/sprites/health/0.png.import b/src/scenes/game/sprites/health/0.png.import index 07dc339..07a8674 100644 --- a/src/scenes/game/sprites/health/0.png.import +++ b/src/scenes/game/sprites/health/0.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 @@ -31,5 +31,5 @@ process/invert_color=false process/normal_map_invert_y=false stream=false size_limit=0 -detect_3d=true +detect_3d=false svg/scale=1.0 diff --git a/src/scenes/game/sprites/health/1.png.import b/src/scenes/game/sprites/health/1.png.import index 3df52a5..ec3fc65 100644 --- a/src/scenes/game/sprites/health/1.png.import +++ b/src/scenes/game/sprites/health/1.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 @@ -31,5 +31,5 @@ process/invert_color=false process/normal_map_invert_y=false stream=false size_limit=0 -detect_3d=true +detect_3d=false svg/scale=1.0 diff --git a/src/scenes/game/sprites/health/2.png.import b/src/scenes/game/sprites/health/2.png.import index aed1e96..156377f 100644 --- a/src/scenes/game/sprites/health/2.png.import +++ b/src/scenes/game/sprites/health/2.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 @@ -31,5 +31,5 @@ process/invert_color=false process/normal_map_invert_y=false stream=false size_limit=0 -detect_3d=true +detect_3d=false svg/scale=1.0 diff --git a/src/scenes/game/sprites/health/3.png.import b/src/scenes/game/sprites/health/3.png.import index 5068175..5be0b8a 100644 --- a/src/scenes/game/sprites/health/3.png.import +++ b/src/scenes/game/sprites/health/3.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 @@ -31,5 +31,5 @@ process/invert_color=false process/normal_map_invert_y=false stream=false size_limit=0 -detect_3d=true +detect_3d=false svg/scale=1.0