development infernusrpg

New item manager in infernusrpg

I continued adding features to infernusrpg, this time i have added a item manager. I have added a new item group and a single item stats as well as a single item scene with its itemscript attached.

In i have added new part in the try_move() func

	#collect items
		var item = _ref_DungeonBoard.get_sprite(_new_GroupName.ITEM, x, y)
		if item!=null:
			print("item collected")

The item manager calls the item instance method collected_by()

func collect(_pc:Sprite,item:Sprite,_group:String ,_x:int,_y:int) -> void:

And the item script pick up the call:

func collected_by(_pc:Sprite) -> void:
	_pc = _pc as PC
	_pc.hp += _new_ChickenStats.RECOVERY_HP
	#set the maximum hp
	if _pc.hp>_new_PCStats.HP:

So every item have their own call to collected_by() then it can increase hp, decrease hp or whatever it wants.

github repository

Leave a Reply

Your email address will not be published. Required fields are marked *