Skip to content

Commit

Permalink
added quest objectives
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankman6 committed Jun 19, 2023
1 parent 73db516 commit b90de35
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 47 deletions.
3 changes: 2 additions & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def move_ai(self):
def collisions(self, direction, bullet_sprites, player_position):
for sprite in bullet_sprites:
if sprite.rect.colliderect(self.hitbox):
print("OCCIOJSDIOFJSDIOFJOIJDIOFSJ")
# return fire by the AI
self.return_fire = True
if self.already_said_enemy_contact is False:
Expand Down Expand Up @@ -103,7 +104,7 @@ def collisions(self, direction, bullet_sprites, player_position):
if self.y_direction < 0:
self.hitbox.top = sprite.hitbox.bottom

def update(self, dt, bullet_sprites, player_position, bot_group):
def update(self, dt, bullet_sprites, player_position, bot_group, actions):
if self.return_fire:
for bot in bot_group:

Expand Down
Binary file added graphics/UI/quest_completion_bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion map.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WIDTH = 3200
80WIDTH = 3200
HEIGHT = 3200
FPS = 60
TILESIZE = 32
Expand Down
64 changes: 24 additions & 40 deletions player.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ def keyboard_input(self):
# Reset mouse clicked to False
self.mouse_clicked = False

if pygame.mouse.get_pressed()[2]:
mouse_pos = pygame.mouse.get_pos()
for i in range(6):
if mouse_pos[0] in range(245 + 95 * i, 340 + 95 * i):
if mouse_pos[1] in range(600, 695):
if self.inventory.player_items[i] is not None:
self.inventory.remove_inventory_item(i)

def collisions(self, direction):
for sprite in self.obstacle_sprites.sprites():
if hasattr(sprite, 'hitbox'):
Expand Down Expand Up @@ -215,7 +223,7 @@ def move(self, dt):
self.rect.centery = self.hitbox.centery
self.collisions('vertical')

def update(self, dt, bullet_sprites, player_position, bot_group):
def update(self, dt, bullet_sprites, player_position, bot_group, actions):
if self.inventory.weapon and self.reload_pressed is not None:
if self.inventory.weapon.bullet_capacity != self.inventory.weapon.max_bullet_capacity:
self.inventory.weapon.reload()
Expand All @@ -241,7 +249,7 @@ def update(self, dt, bullet_sprites, player_position, bot_group):
self.animate(dt)

self.rect.center = self.hitbox.center
self.inventory.render_player_items(self.hitbox)
self.inventory.render_player_items(actions, bot_group)

self.bullet_sprites.draw(self.screen)
self.bullet_sprites.update()
Expand All @@ -262,6 +270,11 @@ def __init__(self, player_hitpoints, armor_value, screen):
self.hp_bars = pygame.transform.scale(pygame.image.load("./graphics/UI/health_bar.png"), (333, 45))
self.hp_bars_bg = pygame.Surface((333, 45))
self.hp_bars_bg.fill((64, 64, 64))
self.quest_bar_bg = pygame.transform.scale(pygame.image.load("./graphics/UI/quest_completion_bar.png"), (181,30))
self.objective_background_bar = pygame.transform.scale(pygame.image.load("./graphics/sprites/item_sprites/inventory_back.png"), (270, 100))
self.objective_font = pygame.font.SysFont("Arial",26)
self.objective_text = self.objective_font.render("Quest Objective: Kill 20 AI", True, (255, 255, 255))
self.objective_text_2 = self.objective_font.render("Quest Objective: Kill 30 AI", True, (255, 255, 255))
self.armor_value = armor_value
# Gun("pistol")
self.player_items = [Apple(), Gun("shotgun"), Gun("rifle"), Gun("sniper"), Gun("shotgun"), Gun("pistol")]
Expand Down Expand Up @@ -307,7 +320,7 @@ def use_inventory_item(self, item_pos, item_type):
def unequip_gun(self):
self.weapon = None

def render_player_items(self, player_hitbox):
def render_player_items(self, actions, bot_group):
inventory_slot_width = 50
inventory_slot_height = 50
inventory_margin = 10
Expand Down Expand Up @@ -353,6 +366,14 @@ def render_player_items(self, player_hitbox):
self.screen.blit(armor_value_bar, (356, 30 + 22))
self.screen.blit(self.hp_bars, (356, 30))

quest_completion_amount = (20 - len(bot_group)) / 20

quest_completion_bar = pygame.Surface((quest_completion_amount * 181, 30))
quest_completion_bar.fill ((0,255,0))
self.screen.blit(self.objective_background_bar, (750,30))
self.screen.blit(self.objective_text,(762,50))
self.screen.blit(quest_completion_bar,(796,90))
self.screen.blit(self.quest_bar_bg, (795,90))

# honestly this is kind of redundant
class Item(Player):
Expand Down Expand Up @@ -417,15 +438,6 @@ def __init__(self):
super().__init__(item_type, item_subtype, item_image, inventory_image)


class MRE(Item):
def __init__(self):
item_type = "heal"
item_subtype = 75
item_image = None
inventory_image = None # [/* inventory image directory here */]
super().__init__(item_type, item_subtype, item_image, inventory_image)


class Water(Item):
def __init__(self):
item_type = "heal"
Expand Down Expand Up @@ -461,34 +473,6 @@ def __init__(self):
inventory_image = "./graphics/sprites/item_sprites/apple_inventory.png"
super().__init__(item_type, item_subtype, item_image, inventory_image)


class Photograph(Item):
def __init__(self):
item_type = "other"
item_subtype = "photograph"
item_image = None
inventory_image = None # [/* inventory image directory here */]
super().__init__(item_type, item_subtype, item_image, inventory_image)


class Soap(Item):
def __init__(self):
item_type = "other"
item_subtype = "soap"
item_image = None
inventory_image = None # [/* inventory image directory here */]
super().__init__(item_type, item_subtype, item_image, inventory_image)


class Toothpaste(Item):
def __init__(self):
item_type = "other"
item_subtype = "toothpaste"
item_image = None
inventory_image = None # [/* inventory image directory here */]
super().__init__(item_type, item_subtype, item_image, inventory_image)


class Gun(Item):
def __init__(self, gun_type):
self.item_type = "gun"
Expand Down
4 changes: 2 additions & 2 deletions sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ def chest_click(self):
# else:
# pass

def run(self, dt):
def run(self, dt, actions):
self.screen.fill('black')
self.sprite_group.custom_draw(self.player)
self.chest_click()
# self.screen.blit(self.cursor_image, player.Player.print_crosshair(self.screen))
self.sprite_group.update(dt, self.bullet_sprites, self.player.hitbox, self.bot_group)
self.sprite_group.update(dt, self.bullet_sprites, self.player.hitbox, self.bot_group, actions)
if self.player.get_hitpoints() <= 0:
self.player.dead = True

Expand Down
4 changes: 1 addition & 3 deletions state.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def update(self, delta_time, actions):
self.sprites.update()

dt = self.clock.tick() / 1000
self.sprites.run(dt)
self.sprites.run(dt, actions)
self.game.reset_keys()

def render(self, screen):
Expand All @@ -231,8 +231,6 @@ def render(self, screen):
menu_btn.button_rect = menu_btn.button.get_rect()
menu_btn.draw()

self.sprites.player.inventory.render_player_items(self.screen)

if self.game.state_stack[0] == "Pause":
self.screen.blit(self.cursor_image, player.Player.print_crosshair(screen))

Expand Down

0 comments on commit b90de35

Please sign in to comment.