Skip to content

Commit

Permalink
Added player inventory float text
Browse files Browse the repository at this point in the history
  • Loading branch information
666Savior committed Apr 27, 2021
1 parent c6f8011 commit 7c0205b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion FCT.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends Label

func _show_value(value, travel, duration, spread):
func _show_value(value, travel, duration, spread, size=12):

text = value
var movement = travel.rotated(rand_range(-spread/2, spread/2))
Expand Down
4 changes: 2 additions & 2 deletions FCTManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export var travel = Vector2(0, -80)
export var duration = 2
export var spread = PI/2

func _show_value(value):
func _show_value(value, size=12):
var fct = FCT.instance()
add_child(fct)
fct._show_value(str(value), travel, duration, spread)
fct._show_value(str(value), travel, duration, spread, size)
6 changes: 6 additions & 0 deletions character/PlayerCharacter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,18 @@ func _input(event: InputEvent) -> void:
return
if !inventory.has(current_lootable.loot1):
inventory[current_lootable.loot1] = 0
if current_lootable.loot1_amount != 0:
$FCTManager._show_value(str(Item.type_str(current_lootable.loot1)) + " (" + str(current_lootable.loot1_amount) + ")", 16)
inventory[current_lootable.loot1] += current_lootable.loot1_amount
if !inventory.has(current_lootable.loot2):
inventory[current_lootable.loot2] = 0
if current_lootable.loot2_amount != 0:
$FCTManager._show_value(str(Item.type_str(current_lootable.loot2)) + " (" + str(current_lootable.loot2_amount) + ")", 16)
inventory[current_lootable.loot2] += current_lootable.loot2_amount
if !inventory.has(current_lootable.loot3):
inventory[current_lootable.loot3] = 0
if current_lootable.loot3_amount != 0:
$FCTManager._show_value(str(Item.type_str(current_lootable.loot3)) + " (" + str(current_lootable.loot3_amount) + ")", 16)
inventory[current_lootable.loot3] += current_lootable.loot3_amount
# print("%s (%d)" % [Item.type_str(current_lootable.loot1), current_lootable.loot1_amount])
# print("%s (%d)" % [Item.type_str(current_lootable.loot2), current_lootable.loot2_amount])
Expand Down
6 changes: 5 additions & 1 deletion character/PlayerCharacter.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=2]
[gd_scene load_steps=21 format=2]

[ext_resource path="res://character/PlayerCharacter.gd" type="Script" id=1]
[ext_resource path="res://character/PlayerCharacter_SpriteFrames.tres" type="SpriteFrames" id=2]
Expand All @@ -18,6 +18,7 @@
[ext_resource path="res://sound/positional/SFX_SwordHit_5.wav" type="AudioStream" id=16]
[ext_resource path="res://sound/positional/SFX_SwordHit_1.wav" type="AudioStream" id=17]
[ext_resource path="res://character/AttackFx_SpriteFrames.tres" type="SpriteFrames" id=18]
[ext_resource path="res://character/FCTManager.tscn" type="PackedScene" id=19]

[sub_resource type="CircleShape2D" id=1]
radius = 16.0
Expand All @@ -43,6 +44,9 @@ frames = ExtResource( 18 )
animation = "idle"
offset = Vector2( 0, -16 )

[node name="FCTManager" parent="." instance=ExtResource( 19 )]
position = Vector2( 0, -45 )

[node name="AudioStreamPlayerWalk1" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 7 )
volume_db = -12.0
Expand Down

0 comments on commit 7c0205b

Please sign in to comment.