From d525377e03e40f2f06844fe04da62ab19cc3c80f Mon Sep 17 00:00:00 2001 From: Logan Date: Sun, 19 Jul 2020 19:15:43 -0500 Subject: [PATCH] Energy burnout finished --- magic/Projectiles/EcoProjectile.tscn | 4 --- magic/Projectiles/PhantomProjectile.tscn | 4 --- magic/Projectiles/Projectile.gd | 2 ++ magic/Wands/WandClass.gd | 3 +- project.godot | 26 ++++++----------- script/WandPosition.gd | 9 ++++-- ui/Energy Burnout.png | Bin 0 -> 134 bytes ui/Energy Burnout.png.import | 34 +++++++++++++++++++++++ ui/PlayerStats.gd | 17 ++++++++++-- ui/PlayerStats.tscn | 11 ++++++-- 10 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 ui/Energy Burnout.png create mode 100644 ui/Energy Burnout.png.import diff --git a/magic/Projectiles/EcoProjectile.tscn b/magic/Projectiles/EcoProjectile.tscn index 56003d4..a4b4051 100644 --- a/magic/Projectiles/EcoProjectile.tscn +++ b/magic/Projectiles/EcoProjectile.tscn @@ -8,11 +8,7 @@ radius = 5.0 [node name="EcoProjectile" type="KinematicBody2D"] collision_layer = 8 -<<<<<<< HEAD collision_mask = 2 -======= -collision_mask = 6 ->>>>>>> master script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] diff --git a/magic/Projectiles/PhantomProjectile.tscn b/magic/Projectiles/PhantomProjectile.tscn index 2c00726..45e38c9 100644 --- a/magic/Projectiles/PhantomProjectile.tscn +++ b/magic/Projectiles/PhantomProjectile.tscn @@ -8,11 +8,7 @@ radius = 5.0 height = 2.0 [node name="PhantomProjectile" type="KinematicBody2D"] -<<<<<<< HEAD collision_layer = 8 -======= -collision_layer = 2147483656 ->>>>>>> master collision_mask = 6 script = ExtResource( 2 ) diff --git a/magic/Projectiles/Projectile.gd b/magic/Projectiles/Projectile.gd index cc704ab..06b8f0e 100644 --- a/magic/Projectiles/Projectile.gd +++ b/magic/Projectiles/Projectile.gd @@ -3,6 +3,7 @@ class_name Projectile export var speed = 300 var velocity = Vector2.ZERO +var energy_cost = 1 onready var Hit = get_node("Node/Hit") onready var Hit_Wall = get_node("Node/Hit Wall") @@ -13,6 +14,7 @@ func _physics_process(delta): func launch(wand, effect): velocity = (Vector2(speed, 0)).rotated(rotation) + return energy_cost func on_impact(collision): queue_free() diff --git a/magic/Wands/WandClass.gd b/magic/Wands/WandClass.gd index 9a23b94..67b1874 100644 --- a/magic/Wands/WandClass.gd +++ b/magic/Wands/WandClass.gd @@ -6,5 +6,6 @@ func fire(projectile, effect): var temp = projectile.instance() get_tree().current_scene.add_child(temp) temp.global_transform = $ProjectileSpawn.global_transform - temp.launch(null, null) + var energy_cost = temp.launch(null, null) $ShootDelay.start() + return energy_cost diff --git a/project.godot b/project.godot index cbeac25..673fb89 100644 --- a/project.godot +++ b/project.godot @@ -45,7 +45,7 @@ _global_script_class_icons={ [application] config/name="Gamejam" -run/main_scene="res://Title/Tilte.tscn" +run/main_scene="res://levels/test.tscn" config/icon="res://icon.png" [autoload] @@ -55,6 +55,10 @@ IconLoaderGithub="*res://addons/github-integration/scripts/IconLoaderGithub.gd" RestHandler="*res://addons/github-integration/scripts/RestHandler.gd" Globals="*res://script/globals.gd" +[debug] + +settings/fps/force_fps=60 + [display] window/size/width=320 @@ -90,47 +94,32 @@ texture={ "stream": false, "svg/scale": 1.0 } -wav={ -"compress/mode": 0, -"edit/loop": true, -"edit/normalize": false, -"edit/trim": false, -"force/8_bit": false, -"force/max_rate": false, -"force/max_rate_hz": 44100, -"force/mono": false -} [input] up={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) ] } down={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null) ] } left={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null) ] } right={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null) ] } shoot={ "deadzone": 0.5, -"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) ] } inventory={ @@ -141,11 +130,14 @@ inventory={ [layer_names] +2d_render/layer_1="Player" 2d_physics/layer_1="Player" +2d_render/layer_2="World" 2d_physics/layer_2="World" 2d_physics/layer_3="Enemy" 2d_physics/layer_4="Projectiles" [rendering] +quality/driver/fallback_to_gles2=true environment/default_environment="res://default_env.tres" diff --git a/script/WandPosition.gd b/script/WandPosition.gd index 2e9a86b..aeadb14 100644 --- a/script/WandPosition.gd +++ b/script/WandPosition.gd @@ -1,5 +1,7 @@ extends Position2D +onready var parent = get_parent() + func clear_conduit(): for c in get_children(): c.queue_free() @@ -9,5 +11,8 @@ func set_current_conduit(conduit): add_child(conduit.instance()) func _process(delta): - if Input.is_action_pressed("shoot") and get_child_count() != 0: - get_children()[0].fire(get_parent().Inventory.active_projectile, null) + if Input.is_action_pressed("shoot") and get_child_count() != 0 and parent.Stats.energy > 0: + var energy_cost = get_children()[0].fire(get_parent().Inventory.active_projectile, null) + if energy_cost != null: + parent.energy -= energy_cost + parent.Stats.interrupt_regen() diff --git a/ui/Energy Burnout.png b/ui/Energy Burnout.png new file mode 100644 index 0000000000000000000000000000000000000000..146a02a0d05fa6e7e32afb4de881012574e2a679 GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^YCz1%!3HGbj>q`|DaPU;cPEB*=VV?2IS!sKjv*Gk z$q5cj(IQ*^zopr07StmjsO4v literal 0 HcmV?d00001 diff --git a/ui/Energy Burnout.png.import b/ui/Energy Burnout.png.import new file mode 100644 index 0000000..8c2e1e0 --- /dev/null +++ b/ui/Energy Burnout.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Energy Burnout.png-25dbbec15c4781d66d514409c50e5504.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/Energy Burnout.png" +dest_files=[ "res://.import/Energy Burnout.png-25dbbec15c4781d66d514409c50e5504.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 +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/ui/PlayerStats.gd b/ui/PlayerStats.gd index 904c337..aa74e31 100644 --- a/ui/PlayerStats.gd +++ b/ui/PlayerStats.gd @@ -3,15 +3,21 @@ extends CanvasLayer onready var Hearts: TextureProgress = $"Player UI Frame 2/Hearts" onready var Energybar: TextureProgress = $"Player UI Frame 2/Energy" onready var Regen: Timer = $Regen +onready var BurnoutSprite: Sprite = $"Player UI Frame 2/Energy Burnout" var health = 3 setget set_health, get_health var energy = 5 setget set_energy, get_energy +var is_burnout = false func _on_Regen_timeout(): - set_energy(get_energy() + 1) + set_energy(get_accurate_energy() + 1) + if get_accurate_energy() == Energybar.max_value: + is_burnout = false func _process(delta): - if get_energy() < Energybar.max_value and Regen.is_stopped(): + BurnoutSprite.visible = is_burnout + print(Regen.is_stopped()) + if get_accurate_energy() < Energybar.max_value and Regen.is_stopped(): Regen.start() func set_health(value): @@ -22,8 +28,15 @@ func get_health(): func set_energy(value): Energybar.value = clamp(value, Energybar.min_value, Energybar.max_value) + if Energybar.value == 0: + is_burnout = true func get_energy(): + if is_burnout == true: + return 0 + return Energybar.value + +func get_accurate_energy(): return Energybar.value func interrupt_regen(): diff --git a/ui/PlayerStats.tscn b/ui/PlayerStats.tscn index da23108..68cdcec 100644 --- a/ui/PlayerStats.tscn +++ b/ui/PlayerStats.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://ui/PlayerStats.gd" type="Script" id=1] [ext_resource path="res://ui/Player UI Frame 2.png" type="Texture" id=2] [ext_resource path="res://ui/Hearts.png" type="Texture" id=3] [ext_resource path="res://ui/Energy.png" type="Texture" id=4] +[ext_resource path="res://ui/Energy Burnout.png" type="Texture" id=5] [node name="Stats" type="CanvasLayer"] script = ExtResource( 1 ) @@ -35,14 +36,18 @@ __meta__ = { anchor_right = 1.0 anchor_bottom = 1.0 margin_left = 4.0 -margin_top = -4.99998 +margin_top = -5.0 margin_right = -64.0 margin_bottom = -16.0 max_value = 5.0 -step = 1.0 value = 5.0 texture_progress = ExtResource( 4 ) __meta__ = { "_edit_use_anchors_": false } + +[node name="Energy Burnout" type="Sprite" parent="Player UI Frame 2"] +position = Vector2( 23, -1 ) +texture = ExtResource( 5 ) +offset = Vector2( 0, 0.5 ) [connection signal="timeout" from="Regen" to="." method="_on_Regen_timeout"]