Add Recharge Bar
parent
d67d1568ee
commit
e0980065c2
|
@ -15,5 +15,5 @@ void fragment(){
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
shader = SubResource( 3 )
|
shader = SubResource( 3 )
|
||||||
shader_param/active = true
|
shader_param/active = false
|
||||||
shader_param/color = Color( 1, 1, 1, 0 )
|
shader_param/color = Color( 1, 1, 1, 1 )
|
||||||
|
|
|
@ -5,6 +5,7 @@ var outline_material = load("res://res/shaders/outline_material.tres")
|
||||||
var speed_multiplier: float = 1.0
|
var speed_multiplier: float = 1.0
|
||||||
var invincibility_timer = .0
|
var invincibility_timer = .0
|
||||||
var velocity = Vector2.ZERO
|
var velocity = Vector2.ZERO
|
||||||
|
var recharge_timer = .0
|
||||||
var invincible = false
|
var invincible = false
|
||||||
var target: EnemyClass
|
var target: EnemyClass
|
||||||
var slowed = false
|
var slowed = false
|
||||||
|
@ -60,6 +61,9 @@ func area_entered(area):
|
||||||
invincible = true
|
invincible = true
|
||||||
invincibility_timer = .0
|
invincibility_timer = .0
|
||||||
|
|
||||||
|
func get_recharge():
|
||||||
|
return 2.0
|
||||||
|
|
||||||
func _shoot():
|
func _shoot():
|
||||||
bullet = bullet_preload.instance()
|
bullet = bullet_preload.instance()
|
||||||
bullet.target = target
|
bullet.target = target
|
||||||
|
@ -77,14 +81,17 @@ func _process(_delta):
|
||||||
if abs(velocity.x) > 10:
|
if abs(velocity.x) > 10:
|
||||||
$Sprite.flip_h = true if velocity.x < 0 else false
|
$Sprite.flip_h = true if velocity.x < 0 else false
|
||||||
|
|
||||||
if Input.is_action_just_pressed("shoot"):
|
|
||||||
_shoot()
|
|
||||||
update()
|
update()
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
get_input()
|
get_input()
|
||||||
|
|
||||||
invincibility_timer += delta
|
invincibility_timer += delta
|
||||||
|
recharge_timer += delta
|
||||||
|
|
||||||
|
if recharge_timer >= get_recharge():
|
||||||
|
_shoot()
|
||||||
|
recharge_timer = .0
|
||||||
|
|
||||||
var areas = $EnemyCollision.get_overlapping_areas()
|
var areas = $EnemyCollision.get_overlapping_areas()
|
||||||
slowed = false
|
slowed = false
|
||||||
|
|
|
@ -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/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]
|
||||||
|
@ -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/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/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/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]
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
extents = Vector2( 10, 60 )
|
extents = Vector2( 10, 60 )
|
||||||
|
@ -126,6 +127,17 @@ frames = SubResource( 4 )
|
||||||
frame = 2
|
frame = 2
|
||||||
centered = false
|
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"]
|
[node name="PlayerIcon" type="Sprite" parent="UIWrapper/UI"]
|
||||||
position = Vector2( 20, 134 )
|
position = Vector2( 20, 134 )
|
||||||
texture = ExtResource( 10 )
|
texture = ExtResource( 10 )
|
||||||
|
|
|
@ -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())
|
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
||||||
|
@ -31,5 +31,5 @@ process/invert_color=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
stream=false
|
stream=false
|
||||||
size_limit=0
|
size_limit=0
|
||||||
detect_3d=true
|
detect_3d=false
|
||||||
svg/scale=1.0
|
svg/scale=1.0
|
||||||
|
|
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
||||||
|
@ -31,5 +31,5 @@ process/invert_color=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
stream=false
|
stream=false
|
||||||
size_limit=0
|
size_limit=0
|
||||||
detect_3d=true
|
detect_3d=false
|
||||||
svg/scale=1.0
|
svg/scale=1.0
|
||||||
|
|
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
||||||
|
@ -31,5 +31,5 @@ process/invert_color=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
stream=false
|
stream=false
|
||||||
size_limit=0
|
size_limit=0
|
||||||
detect_3d=true
|
detect_3d=false
|
||||||
svg/scale=1.0
|
svg/scale=1.0
|
||||||
|
|
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
||||||
|
@ -31,5 +31,5 @@ process/invert_color=false
|
||||||
process/normal_map_invert_y=false
|
process/normal_map_invert_y=false
|
||||||
stream=false
|
stream=false
|
||||||
size_limit=0
|
size_limit=0
|
||||||
detect_3d=true
|
detect_3d=false
|
||||||
svg/scale=1.0
|
svg/scale=1.0
|
||||||
|
|
Loading…
Reference in New Issue