added initial item class

fixed formatting in globals
added itemtype enum into globals
reworked in_inventory logic
master
Zac 3 years ago
parent 835be4dff3
commit b519724aaf
  1. 14
      scripts/Globals.gd
  2. 3
      scripts/Item.gd
  3. 3
      scripts/MainGame.gd
  4. 8
      scripts/PlayerInfo.gd

@ -1,8 +1,14 @@
extends Node
enum Directions {
N = 1,
S = 2,
E = 4,
W = 8
N = 1,
S = 2,
E = 4,
W = 8
}
enum ItemType {
WEAPON,
AMMO,
HEALTH
}

@ -0,0 +1,3 @@
var name = ""
var description = ""
var type = null # Globals.ItemType

@ -37,9 +37,6 @@ func _ready():
# test data
LocalPlayer.set_position(Vector2(0,0))
# call this *after* generating the rooms duh
update_display_info(LocalPlayer.position)
#!! make sure to call player functions every frame !!
func _process(delta):

@ -17,9 +17,13 @@ func update_player_health(HealthBar):
elif HP > 20 and HealthBar.texture_progress != normal_health:
HealthBar.texture_progress = normal_health
# check if an item is in the players inventory
func in_inventory(item):
return Inventory.has(item)
for held_item in Inventory:
return true if held_item.name == item.name else ''
return false
# add an item to the inventory
func add_to_inventory(item):
Inventory.append(item)
@ -36,8 +40,10 @@ func move(direction):
emit_signal("player_moved", position)
# manually set the players position
func set_position(pos):
position = pos
emit_signal("player_moved", position)
# returns the player's position
func get_position():

Loading…
Cancel
Save