Tut18 Complete; hearts, shadows, etc.
This commit is contained in:
parent
7713127e27
commit
54f9772836
@ -1,10 +1,11 @@
|
|||||||
[gd_scene load_steps=56 format=2]
|
[gd_scene load_steps=57 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
|
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
|
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://Overlap/Hitbox.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://Overlap/Hitbox.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://Player/SwordHitbox.gd" type="Script" id=4]
|
[ext_resource path="res://Player/SwordHitbox.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=5]
|
||||||
|
[ext_resource path="res://Shadows/MediumShadow.png" type="Texture" id=6]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=1]
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
radius = 4.0
|
radius = 4.0
|
||||||
@ -650,6 +651,10 @@ height = 6.0
|
|||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="ShadowSprite" type="Sprite" parent="."]
|
||||||
|
position = Vector2( 0, 1 )
|
||||||
|
texture = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
position = Vector2( 0, -9 )
|
position = Vector2( 0, -9 )
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
export(int) var max_health = 1
|
export(int) var max_health = 1 setget set_max_health
|
||||||
onready var health = max_health setget set_health
|
var health = max_health setget set_health
|
||||||
|
|
||||||
signal no_health
|
signal no_health
|
||||||
signal health_changed(value)
|
signal health_changed(value)
|
||||||
|
signal max_health_changed(value)
|
||||||
|
|
||||||
|
func set_max_health(value):
|
||||||
|
max_health = value
|
||||||
|
self.health = min(health, max_health)
|
||||||
|
emit_signal("max_health_changed", max_health)
|
||||||
|
|
||||||
func set_health(value):
|
func set_health(value):
|
||||||
health = value
|
health = value
|
||||||
emit_signal("health_changed", health)
|
emit_signal("health_changed", health)
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
emit_signal("no_health")
|
emit_signal("no_health")
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
self.health = max_health
|
||||||
|
@ -3,17 +3,22 @@ extends Control
|
|||||||
var hearts = 4 setget set_hearts
|
var hearts = 4 setget set_hearts
|
||||||
var max_hearts = 4 setget set_max_hearts
|
var max_hearts = 4 setget set_max_hearts
|
||||||
|
|
||||||
onready var label = $Label
|
onready var heartUIFull = $HeartUIFull
|
||||||
|
onready var heartUIEmpty = $HeartUIEmpty
|
||||||
|
|
||||||
func set_hearts(value):
|
func set_hearts(value):
|
||||||
hearts = clamp(value, 0, max_hearts)
|
hearts = clamp(value, 0, max_hearts)
|
||||||
if label != null:
|
if heartUIFull != null:
|
||||||
label.text = "HP = " + str(hearts)
|
heartUIFull.rect_size.x = hearts * 15
|
||||||
|
|
||||||
func set_max_hearts(value):
|
func set_max_hearts(value):
|
||||||
max_hearts = max(value, 1)
|
max_hearts = max(value, 1)
|
||||||
|
self.hearts = min(hearts, max_hearts)
|
||||||
|
if heartUIEmpty != null:
|
||||||
|
heartUIEmpty.rect_size.x = max_hearts * 15
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
self.max_hearts = PlayerStats.max_health
|
self.max_hearts = PlayerStats.max_health
|
||||||
self.hearts = PlayerStats.health
|
self.hearts = PlayerStats.health
|
||||||
PlayerStats.connect("health_changed", self, "set_hearts")
|
PlayerStats.connect("health_changed", self, "set_hearts")
|
||||||
|
PlayerStats.connect("max_health_changed", self, "set_max_hearts")
|
||||||
|
@ -1,13 +1,25 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://UI/HealthUI.gd" type="Script" id=1]
|
[ext_resource path="res://UI/HealthUI.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://UI/HeartUIEmpty.png" type="Texture" id=2]
|
||||||
|
[ext_resource path="res://UI/HeartUIFull.png" type="Texture" id=3]
|
||||||
|
|
||||||
[node name="HealthUI" type="Control"]
|
[node name="HealthUI" type="Control"]
|
||||||
margin_right = 122.0
|
margin_left = 2.0
|
||||||
margin_bottom = 25.0
|
margin_top = 2.0
|
||||||
|
margin_right = 124.0
|
||||||
|
margin_bottom = 27.0
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="HeartUIEmpty" type="TextureRect" parent="."]
|
||||||
margin_right = 42.0
|
margin_right = 59.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 12.0
|
||||||
text = "HP = 4"
|
texture = ExtResource( 2 )
|
||||||
|
stretch_mode = 2
|
||||||
|
|
||||||
|
[node name="HeartUIFull" type="TextureRect" parent="."]
|
||||||
|
margin_right = 60.0
|
||||||
|
margin_bottom = 11.0
|
||||||
|
texture = ExtResource( 3 )
|
||||||
|
expand = true
|
||||||
|
stretch_mode = 2
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=63 format=2]
|
[gd_scene load_steps=64 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://World/Bush.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://World/Bush.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=2]
|
||||||
@ -9,6 +9,7 @@
|
|||||||
[ext_resource path="res://touch_controls/TouchControls.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://touch_controls/TouchControls.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://Enemies/Bat.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://Enemies/Bat.tscn" type="PackedScene" id=8]
|
||||||
[ext_resource path="res://UI/HealthUI.tscn" type="PackedScene" id=9]
|
[ext_resource path="res://UI/HealthUI.tscn" type="PackedScene" id=9]
|
||||||
|
[ext_resource path="res://World/Tree.tscn" type="PackedScene" id=10]
|
||||||
|
|
||||||
[sub_resource type="TileSet" id=1]
|
[sub_resource type="TileSet" id=1]
|
||||||
0/name = "DirtTileset.png 0"
|
0/name = "DirtTileset.png 0"
|
||||||
@ -595,6 +596,11 @@ position = Vector2( 48, 112 )
|
|||||||
[node name="Grass10" parent="YSort/Grass" instance=ExtResource( 6 )]
|
[node name="Grass10" parent="YSort/Grass" instance=ExtResource( 6 )]
|
||||||
position = Vector2( 128, 121 )
|
position = Vector2( 128, 121 )
|
||||||
|
|
||||||
|
[node name="Trees" type="YSort" parent="YSort"]
|
||||||
|
|
||||||
|
[node name="Tree" parent="YSort/Trees" instance=ExtResource( 10 )]
|
||||||
|
position = Vector2( 127, 40 )
|
||||||
|
|
||||||
[node name="Bat" parent="YSort" instance=ExtResource( 8 )]
|
[node name="Bat" parent="YSort" instance=ExtResource( 8 )]
|
||||||
position = Vector2( 198, 35 )
|
position = Vector2( 198, 35 )
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[gd_scene load_steps=3 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://World/Bush.png" type="Texture" id=1]
|
[ext_resource path="res://World/Bush.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://Shadows/LargeShadow.png" type="Texture" id=2]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=1]
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
radius = 7.99998
|
radius = 7.99998
|
||||||
@ -8,6 +9,10 @@ height = 12.0
|
|||||||
|
|
||||||
[node name="Bush" type="StaticBody2D"]
|
[node name="Bush" type="StaticBody2D"]
|
||||||
|
|
||||||
|
[node name="ShadowSprite" type="Sprite" parent="."]
|
||||||
|
position = Vector2( 0, 6 )
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
|
22
ActionRPG-HeartBeast/World/Tree.tscn
Normal file
22
ActionRPG-HeartBeast/World/Tree.tscn
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Shadows/LargeShadow.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://World/Tree.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
|
radius = 9.0
|
||||||
|
height = 8.0
|
||||||
|
|
||||||
|
[node name="Tree" type="StaticBody2D"]
|
||||||
|
|
||||||
|
[node name="ShadowSprite" type="Sprite" parent="."]
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
position = Vector2( 0, -16 )
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2( 0, -1 )
|
||||||
|
rotation = 1.5708
|
||||||
|
shape = SubResource( 1 )
|
@ -139,7 +139,7 @@
|
|||||||
<script type='text/javascript' src='index.js'></script>
|
<script type='text/javascript' src='index.js'></script>
|
||||||
<script type='text/javascript'>//<![CDATA[
|
<script type='text/javascript'>//<![CDATA[
|
||||||
|
|
||||||
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2283408,"index.wasm":13790961},"focusCanvas":true,"gdnativeLibs":[]};
|
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2289520,"index.wasm":13790961},"focusCanvas":true,"gdnativeLibs":[]};
|
||||||
var engine = new Engine(GODOT_CONFIG);
|
var engine = new Engine(GODOT_CONFIG);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user