feat(item): add cost attribute and getter function
This commit is contained in:
@@ -11,6 +11,7 @@ class Item:
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.item_type = item_type
|
||||
self.cost = random.randint(5, 10)
|
||||
|
||||
# collision rect for player (2 times item size for width and height)
|
||||
self.rect = pygame.Rect(self.x, self.y, ITEM_SIZE, ITEM_SIZE)
|
||||
@@ -50,6 +51,9 @@ class Item:
|
||||
pygame.draw.rect(screen, color, draw_rect)
|
||||
pygame.draw.rect(screen, COLOR_HP_BAR_BG, draw_rect, 2)
|
||||
|
||||
def get_cost(self):
|
||||
return self.cost
|
||||
|
||||
|
||||
# try 50 times to find a free position to spawn item
|
||||
def _random_position(room_rect, blocked_rects):
|
||||
|
||||
Reference in New Issue
Block a user