From a3743007c2619356e4ed4146ee9c840cf9d20e89 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 19 Oct 2020 22:44:21 +0200 Subject: [PATCH] Almost working animations for picking up items --- KinematicBody2D.gd | 11 +++++++++++ MiscCodes/Item.gd | 12 +++++++++++- MiscScenes/Equipment.tscn | 3 +++ addons/godot-sqlite/godot-sqlite.gd | 4 ++-- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 MiscScenes/Equipment.tscn diff --git a/KinematicBody2D.gd b/KinematicBody2D.gd index f51c275..be116ab 100644 --- a/KinematicBody2D.gd +++ b/KinematicBody2D.gd @@ -40,6 +40,7 @@ func InteractWithCell(): if plant_cell == 1: Global.AddInventoryItem(3, 1) plants_map.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), 4) + AnimationOnInteraction(1) # plants_map.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), 4) func _interaction_process(): @@ -49,6 +50,16 @@ func _interaction_process(): func _input(event): pass + +func AnimationOnInteraction(Item): + print(Item, "Animation") + var img = load("res://pictures/inventory_iconpictures/food_items/herbs/saffron.png") + $Sprite.draw_texture(img, Vector2(self.position.x/cell_size.x, self.position.y/cell_size.y)) + + #This works, but changes the sprite.. + #$Sprite.set_texture(img) + #img.create(128, 128, false, "res://pictures/inventory_iconpictures/food_items/herbs/saffron.png") + pass func _ready(): Global.player_inventory_items = Database.GetInventoryItems() diff --git a/MiscCodes/Item.gd b/MiscCodes/Item.gd index 955c088..af67796 100644 --- a/MiscCodes/Item.gd +++ b/MiscCodes/Item.gd @@ -7,15 +7,25 @@ func _ready(): match Global.player_inventory_items[self.id].item_id: 0: pass + + # Id 0-40 - Map foraging - 'Random' spawning 1: $TextureRect.texture = load("res://pictures/inventory_iconpictures/miscellaneous/magic_formulae.png") 2: $TextureRect.texture = load("res://pictures/inventory_iconpictures/tools_and_weapons/tools/ploeg.png") 3: $TextureRect.texture = load("res://pictures/inventory_iconpictures/food_items/herbs/saffron.png") + + # Id 41-80 - Tools - Every tool map interaction NOT weapons + 41: + $TextureRect.texture = load("res://pictures/inventory_iconpictures/tools_and_weapons/tools/ploeg.png") + + # Id 81-160 - Armour/Clothing + + # Id 161-240 - Farming and planting if Global.player_inventory_items[self.id].amount > 0: var amountlbl = Label.new() - amountlbl.set_position(Vector2(self.position.x+102, self.position.y+102)) + amountlbl.set_position(Vector2(self.position.x+105, self.position.y+105)) amountlbl.text = str(Global.player_inventory_items[self.id].amount) add_child(amountlbl) diff --git a/MiscScenes/Equipment.tscn b/MiscScenes/Equipment.tscn new file mode 100644 index 0000000..b171e8d --- /dev/null +++ b/MiscScenes/Equipment.tscn @@ -0,0 +1,3 @@ +[gd_scene format=2] + +[node name="Node2D" type="Node2D"] diff --git a/addons/godot-sqlite/godot-sqlite.gd b/addons/godot-sqlite/godot-sqlite.gd index 60196ec..9b486b7 100644 --- a/addons/godot-sqlite/godot-sqlite.gd +++ b/addons/godot-sqlite/godot-sqlite.gd @@ -8,7 +8,7 @@ tool extends EditorPlugin func _enter_tree(): - pass + pass func _exit_tree(): - pass \ No newline at end of file + pass