Added health bar (WIP)
This commit is contained in:
parent
2b0d0daf2c
commit
a2b037374a
10 changed files with 98 additions and 15 deletions
|
@ -8,7 +8,7 @@ extends Control
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
Global._resetvars()
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
@ -17,10 +17,8 @@ func _ready():
|
||||||
|
|
||||||
|
|
||||||
func _on_Button_pressed():
|
func _on_Button_pressed():
|
||||||
Global.playerdead = 0
|
|
||||||
get_tree().change_scene(Global.beforedeathscene)
|
get_tree().change_scene(Global.beforedeathscene)
|
||||||
|
|
||||||
|
|
||||||
func _on_Button2_pressed():
|
func _on_Button2_pressed():
|
||||||
Global.playerdead = 0
|
|
||||||
get_tree().change_scene("res://Levels/Main.tscn")
|
get_tree().change_scene("res://Levels/Main.tscn")
|
||||||
|
|
|
@ -8,8 +8,7 @@ extends Control
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
Global.tankskilled = 0
|
Global._resetvars()
|
||||||
Global.firstlevelcompleted = 0
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
|
|
@ -18,3 +18,7 @@ func _ready():
|
||||||
|
|
||||||
func _on_Button_pressed():
|
func _on_Button_pressed():
|
||||||
get_tree().change_scene("res://Levels/Main.tscn")
|
get_tree().change_scene("res://Levels/Main.tscn")
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
if Input.is_action_pressed("ui_cancel"):
|
||||||
|
get_tree().change_scene("res://Levels/Main.tscn")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
Global._resetvars()
|
||||||
|
|
||||||
func _on_Button_pressed():
|
func _on_Button_pressed():
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
Global._resetvars()
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
if Input.is_action_pressed("ui_accept"):
|
if Input.is_action_pressed("ui_accept"):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://fonts/Born2bSportyV2.ttf" type="DynamicFontData" id=1]
|
[ext_resource path="res://fonts/Born2bSportyV2.ttf" type="DynamicFontData" id=1]
|
||||||
[ext_resource path="res://Levels/win-01.gd" type="Script" id=2]
|
[ext_resource path="res://Levels/win-01.gd" type="Script" id=2]
|
||||||
|
@ -7,10 +7,19 @@
|
||||||
size = 80
|
size = 80
|
||||||
font_data = ExtResource( 1 )
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=2]
|
||||||
|
size = 80
|
||||||
|
outline_size = 4
|
||||||
|
outline_color = Color( 1, 0, 0, 1 )
|
||||||
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Win-level01" type="Control"]
|
[node name="Win-level01" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
|
@ -21,6 +30,9 @@ margin_left = -802.5
|
||||||
margin_top = -166.0
|
margin_top = -166.0
|
||||||
margin_right = 802.5
|
margin_right = 802.5
|
||||||
margin_bottom = 166.0
|
margin_bottom = 166.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="VBoxContainer"]
|
[node name="Label" type="Label" parent="VBoxContainer"]
|
||||||
margin_right = 1605.0
|
margin_right = 1605.0
|
||||||
|
@ -49,5 +61,20 @@ margin_top = 252.0
|
||||||
margin_right = 1605.0
|
margin_right = 1605.0
|
||||||
margin_bottom = 332.0
|
margin_bottom = 332.0
|
||||||
custom_fonts/font = SubResource( 1 )
|
custom_fonts/font = SubResource( 1 )
|
||||||
text = "Press enter to see what's in store for your future!"
|
text = "Press to see what's in store for your future!"
|
||||||
align = 1
|
align = 1
|
||||||
|
|
||||||
|
[node name="VBoxContainer2" type="VBoxContainer" parent="."]
|
||||||
|
margin_left = 374.0
|
||||||
|
margin_top = 627.0
|
||||||
|
margin_right = 539.0
|
||||||
|
margin_bottom = 707.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Label5" type="Label" parent="VBoxContainer2"]
|
||||||
|
margin_right = 165.0
|
||||||
|
margin_bottom = 80.0
|
||||||
|
custom_fonts/font = SubResource( 2 )
|
||||||
|
text = "enter"
|
||||||
|
|
|
@ -6,6 +6,7 @@ export var muzzle_velocity = 25 # How fast the bullets are
|
||||||
export var g = Vector3.DOWN * 20
|
export var g = Vector3.DOWN * 20
|
||||||
|
|
||||||
var velocity = Vector3.ZERO
|
var velocity = Vector3.ZERO
|
||||||
|
var bulletdamagelocal = 0.5
|
||||||
|
|
||||||
###### CHEATS
|
###### CHEATS
|
||||||
var godmode = 0
|
var godmode = 0
|
||||||
|
@ -21,11 +22,19 @@ func _physics_process(delta):
|
||||||
print ("Found Player Tank")
|
print ("Found Player Tank")
|
||||||
self.queue_free()
|
self.queue_free()
|
||||||
if (godmode == 0):
|
if (godmode == 0):
|
||||||
body.queue_free()
|
Global.bulletdamage = bulletdamagelocal
|
||||||
Global.playerdead = 1
|
Global.playerhit = 1
|
||||||
Global.tankskilled = 0
|
if Global.playerhealthexecfinish:
|
||||||
Global.beforedeathscene = get_tree().current_scene.filename
|
if Global.playerhealthbarscale <= 0:
|
||||||
get_tree().change_scene("res://Levels/Dead.tscn")
|
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:
|
else:
|
||||||
if get_overlapping_bodies():
|
if get_overlapping_bodies():
|
||||||
if body.has_node("TankAI"):
|
if body.has_node("TankAI"):
|
||||||
|
|
|
@ -44,6 +44,13 @@ func _physics_process(delta):
|
||||||
direction = direction.normalized()
|
direction = direction.normalized()
|
||||||
# $Pivot.look_at(translation + direction, Vector3.UP)
|
# $Pivot.look_at(translation + direction, Vector3.UP)
|
||||||
|
|
||||||
|
if Global.playerhit == 1:
|
||||||
|
$HealthBar.scale.x = Global.playerhealthbarscale - Global.bulletdamage
|
||||||
|
Global.playerhealthbarscale = Global.playerhealthbarscale - Global.bulletdamage
|
||||||
|
Global.playerhit = 0
|
||||||
|
Global.bulletdamage = 0
|
||||||
|
Global.playerhealthexecfinish = 1
|
||||||
|
|
||||||
velocity.x = direction.x * speed
|
velocity.x = direction.x * speed
|
||||||
velocity.z = direction.z * speed
|
velocity.z = direction.z * speed
|
||||||
velocity.y -= gravity * delta
|
velocity.y -= gravity * delta
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=7 format=2]
|
[gd_scene load_steps=11 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Objects/Player-tank/Player.gd" type="Script" id=1]
|
[ext_resource path="res://Objects/Player-tank/Player.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Objects/Player-tank/model/textured/Bottom_tank_blender_player.glb" type="PackedScene" id=2]
|
[ext_resource path="res://Objects/Player-tank/model/textured/Bottom_tank_blender_player.glb" type="PackedScene" id=2]
|
||||||
|
@ -10,6 +10,18 @@ extents = Vector3( 1.29, 1, 2.428 )
|
||||||
|
|
||||||
[sub_resource type="BoxShape" id=2]
|
[sub_resource type="BoxShape" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=4]
|
||||||
|
flags_transparent = true
|
||||||
|
albedo_color = Color( 1, 1, 1, 0.117647 )
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=5]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=6]
|
||||||
|
flags_transparent = true
|
||||||
|
albedo_color = Color( 1, 0, 0, 0.529412 )
|
||||||
|
|
||||||
[node name="PlayerTank" type="KinematicBody"]
|
[node name="PlayerTank" type="KinematicBody"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
@ -35,3 +47,13 @@ transform = Transform( -6.24448e-08, 0, -1.42857, 0, 1.42857, 0, 1.42857, 0, -6.
|
||||||
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]
|
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]
|
||||||
stream = ExtResource( 4 )
|
stream = ExtResource( 4 )
|
||||||
unit_size = 20.0
|
unit_size = 20.0
|
||||||
|
|
||||||
|
[node name="HealthBarBack" type="CSGMesh" parent="."]
|
||||||
|
transform = Transform( 2.1, 0, 0, 0, 0.069, 0, 0, 0, 0.343, 0, 2.6666, -2.69651 )
|
||||||
|
mesh = SubResource( 3 )
|
||||||
|
material = SubResource( 4 )
|
||||||
|
|
||||||
|
[node name="HealthBar" type="CSGMesh" parent="."]
|
||||||
|
transform = Transform( 2, 0, 0, 0, 0.039, 0, 0, 0, 0.276, 0.000887275, 2.78065, -2.70032 )
|
||||||
|
mesh = SubResource( 5 )
|
||||||
|
material = SubResource( 6 )
|
||||||
|
|
|
@ -4,3 +4,18 @@ var playerdead = 0
|
||||||
var beforedeathscene
|
var beforedeathscene
|
||||||
var tankskilled = 0
|
var tankskilled = 0
|
||||||
var firstlevelcompleted = 0
|
var firstlevelcompleted = 0
|
||||||
|
var playerhit = 0
|
||||||
|
var playerhealthbarscale = 2
|
||||||
|
var bulletdamage = 0
|
||||||
|
var playerhealthexecfinish = 0
|
||||||
|
|
||||||
|
|
||||||
|
func _resetvars():
|
||||||
|
playerdead = 0
|
||||||
|
beforedeathscene
|
||||||
|
tankskilled = 0
|
||||||
|
firstlevelcompleted = 0
|
||||||
|
playerhit = 0
|
||||||
|
playerhealthbarscale = 2
|
||||||
|
bulletdamage = 0
|
||||||
|
playerhealthexecfinish = 0
|
||||||
|
|
Loading…
Reference in a new issue