Added Healt system + health bar + repair hammers

This commit is contained in:
Paul Black 2022-04-22 20:04:23 -06:00
parent fb0ab654c3
commit 91ca6be413
12 changed files with 1162 additions and 18 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://Objects/Player-tank/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Objects/Ai-tank/tank00.tscn" type="PackedScene" id=2]
@ -7,6 +7,7 @@
[ext_resource path="res://Levels/Score.gd" type="Script" id=5]
[ext_resource path="res://Audio/Tutorial_backround.wav" type="AudioStream" id=6]
[ext_resource path="res://Audio/Music.gd" type="Script" id=7]
[ext_resource path="res://Objects/Hammer/Hammer.tscn" type="PackedScene" id=8]
[sub_resource type="DynamicFont" id=1]
size = 60
@ -75,3 +76,12 @@ script = ExtResource( 7 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 2 )
[node name="Hammer" parent="." instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 11.905, 0.316137, -42.6669 )
[node name="Hammer2" parent="." instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -176.031, 0.226439, 87.7901 )
[node name="Hammer3" parent="." instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6.45557, 0.267753, 46.1506 )

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://Objects/Player-tank/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Objects/Ai-tank/tank00.tscn" type="PackedScene" id=2]
@ -7,6 +7,7 @@
[ext_resource path="res://Levels/Score.gd" type="Script" id=5]
[ext_resource path="res://Audio/Music.gd" type="Script" id=6]
[ext_resource path="res://Audio/Epic Combat LOOP.wav" type="AudioStream" id=7]
[ext_resource path="res://Objects/Hammer/Hammer.tscn" type="PackedScene" id=8]
[sub_resource type="DynamicFont" id=1]
size = 60
@ -75,3 +76,12 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 100.246, 1.1, 128.309 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 2 )
[node name="Hammer" parent="." instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 127.161, 0.190119, 60.1346 )
[node name="Hammer2" parent="." instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6.63201, 0.265376, -100.664 )
[node name="Hammer3" parent="." instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 200.005, 0.230888, -99.1484 )

View file

@ -28,9 +28,6 @@ font_data = ExtResource( 2 )
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MenuScreen" type="Sprite" parent="."]
position = Vector2( 960, 540 )

View file

@ -6,7 +6,7 @@ export var muzzle_velocity = 25 # How fast the bullets are
export var g = Vector3.DOWN * 20
var velocity = Vector3.ZERO
var bulletdamagelocal = 0.5
var bulletdamagelocal = 0.8
###### CHEATS
var godmode = 0
@ -21,20 +21,10 @@ func _physics_process(delta):
if get_overlapping_bodies().has(get_parent().get_node("PlayerTank")):
print ("Found Player Tank")
self.queue_free()
Global.playerbody = body
if (godmode == 0):
Global.bulletdamage = bulletdamagelocal
Global.playerhit = 1
if Global.playerhealthexecfinish:
if Global.playerhealthbarscale <= 0:
body.queue_free()
Global.playerdead = 1
Global.tankskilled = 0
Global.beforedeathscene = get_tree().current_scene.filename
get_tree().change_scene("res://Levels/Dead.tscn")
Global.playerhealthbarscale = 2
Global.playerhit = 0
else:
pass # Replace me with new function you'll make soon
else:
if get_overlapping_bodies():
if body.has_node("TankAI"):

12
Objects/Hammer/Hammer.gd Normal file
View file

@ -0,0 +1,12 @@
extends Area
func _physics_process(delta):
for body in get_overlapping_bodies():
if get_overlapping_bodies().has(get_parent().get_node("PlayerTank")):
print("Hammer")
self.queue_free()
if Global.playerhealthbarscale < 2:
Global.playerhealthbarscale = Global.playerhealthbarscale + 0.25
Global.bulletdamage = 0 # Makes sure the player won't take damage
Global.playerhit = 1 # This is just to make the player script notice the change to the health bar

BIN
Objects/Hammer/Hammer.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View file

@ -50,6 +50,7 @@ func _physics_process(delta):
Global.playerhit = 0
Global.bulletdamage = 0
Global.playerhealthexecfinish = 1
Global._player_dead()
velocity.x = direction.x * speed
velocity.z = direction.z * speed

View file

@ -8,14 +8,24 @@ var playerhit = 0
var playerhealthbarscale = 2
var bulletdamage = 0
var playerhealthexecfinish = 0
var playerbody
func _resetvars():
playerdead = 0
beforedeathscene
tankskilled = 0
firstlevelcompleted = 0
playerhit = 0
playerhealthbarscale = 2
bulletdamage = 0
playerhealthexecfinish = 0
func _player_dead():
if playerhealthbarscale <= 0:
playerbody.queue_free()
playerdead = 1
tankskilled = 0
beforedeathscene = get_tree().current_scene.filename
get_tree().change_scene("res://Levels/Dead.tscn")
playerhealthbarscale = 2
playerhit = 0