Skip to content

Commit

Permalink
Thought bubbles (#122)
Browse files Browse the repository at this point in the history
* Thought Bubbles partially done Don Deal 7/27/2023

* Thought Bubbles but needs watering can to finish and to scale down some of the items Donald Deal 7/28/2023

* reversed an error Don Deal 7/28/2023

* fixed an error Donald Deal 7/28/2023

* more updates Donald Deal 7/28/2023

* Deleted duplicate status bars Donald Deal 7/29/2023

* items wont work when pet is dirty except the watering can

* Fixed location varibles Donald Deal

* changed shower animation fixed items going back to wrong location Donald Deal
  • Loading branch information
Donnyd88 authored Aug 1, 2023
1 parent 7bbc868 commit 3dd4595
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 94 deletions.
9 changes: 5 additions & 4 deletions game_util/scene_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_pet_thirst(self):
def get_pet_hunger(self):
return self.hunger_bar.hp

def get_pet_happieness(self):
def get_pet_happiness(self):
return self.happiness_bar.hp

def fill_health(self):
Expand Down Expand Up @@ -99,6 +99,7 @@ def __init__(self, item_id, pygame, screen, image, pet, x, y, is_movable = True)
self.interacting_pet = pet
self.item_location = [x,y]
self.offset = (0, 0)
self.is_rock_dirty = False

def is_mouse_selection(self, mouse_pos):
item_location = self.item_location
Expand All @@ -120,12 +121,12 @@ def get_collision_item(self):
self.interacting_pet.set_current_animation(config.RockActions.drinking.value, True)
return config.ItemID.full_cup
elif self.item_id==config.ItemID.watering_can and self.rect.collidepoint(self.interacting_pet.get_location()):
self.interacting_pet.set_current_animation(config.RockActions.clean.value,True)
self.interacting_pet.set_current_animation(config.RockActions.very_dirty_shower.value,True)
return config.ItemID.watering_can



def handle_event(self, event, item_loc):
def handle_event(self, event, item_loc, is_rock_dirty) :
if self.is_movable:
if event.type == pygame.MOUSEBUTTONDOWN:
if self.rect.collidepoint(event.pos):
Expand All @@ -145,6 +146,6 @@ def handle_event(self, event, item_loc):
else:
if event.type == pygame.MOUSEBUTTONDOWN:
mouse_pos = self.pygame.mouse.get_pos()
if self.is_mouse_selection(mouse_pos):
if self.is_mouse_selection(mouse_pos) and is_rock_dirty == False:
self.interacting_pet.set_location(self.item_location[0],self.item_location[1]+ self.rect.height/2.5)
self.interacting_pet.set_current_animation(config.RockActions.sleeping.value, True)
101 changes: 87 additions & 14 deletions house_screen.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import pygame
from pygame.locals import *
from game_util import PetConfig as Config
from pets import PetRaccoon, PetRock, PetMudskipper
from src import table as Table
from game_util import PetConfig as config, scene_items as scene_item
from pet_selection import PetSelection
from game_over import GameOver
from game_util.sprite_sheet import SpriteSheet
import os


class HouseScreen:
def __init__(self, screen):
self.house_screen = screen
self.thought_bubble_radius = 40
self.thought_bubble_color = (255, 255, 255)


def draw(self):
self.house_screen.fill(config.BLACK)
Expand All @@ -19,19 +24,21 @@ def draw(self):
self.house_screen.blit(screen_background, (0, 0))

class RockHouse:
def __init__(self):
self.pygame = pygame.init()

def __init__(self,screen):
self.house_screen = screen
self.thought_bubble_radius = 50
self.thought_bubble_color = config.WHITE


self.font = config.FONT
self.screen = pygame.display.set_mode((config.SCREEN_WIDTH, config.SCREEN_HEIGHT))
self.house = HouseScreen(self.screen)
self.pet_stats = scene_item.PetStats()
self.pet_stats_bar_icon = scene_item.BarIcons(pygame, self.screen)
self.sprite_sheet_img = pygame.image.load(config.ITEM_PATH).convert_alpha() #SpriteSheet('../my_pet/assets/items_sheet.png')
self.sprite_sheet = SpriteSheet(self.sprite_sheet_img)

self.last_update = pygame.time.get_ticks()

self.last_update = pygame.time.get_ticks()
self.animation_cooldown = 100

self.my_rock = PetRock(pygame, self.screen)
Expand Down Expand Up @@ -61,23 +68,59 @@ def __init__(self):
self.rock_misbehaving_time = 10 #seconds
self.game_over = GameOver(pygame, self.screen, self.my_rock)

#scaled thought bubble objects
self.thought_of_watering_can = self.sprite_sheet.get_image(0, 288, 96, 96, 1, config.BG_BLACK)
self.thought_of_ball = self.sprite_sheet.get_image(2, 288, 96, 96, 1, config.BG_BLACK)
self.thought_of_full_cup = self.sprite_sheet.get_image(0,864,96,96,1, config.BG_BLACK)

self.rock_made_a_mess = False
self.pet_died = False
self.is_rock_dirty = False
self.is_hungry = False
self.is_thirsty = False
self.is_sad = False

def draw_thought_bubble(self, screen, pet_rock_location, image):
bubble_offset = (0, 50) # Offset for the first bubble (above the rock)
bubble_x = pet_rock_location[0] + bubble_offset[0] - self.thought_bubble_radius
bubble_y = pet_rock_location[1] + bubble_offset[1] - self.thought_bubble_radius

# Draw the first bubble (above the rock)
pygame.draw.circle(screen, config.WHITE, (bubble_x + self.thought_bubble_radius, bubble_y + self.thought_bubble_radius), self.thought_bubble_radius//2)

# Update the bubble_offset for the second bubble (below the first bubble)
bubble_offset = (0, -50)
bubble_x = pet_rock_location[0] + bubble_offset[0] - self.thought_bubble_radius
bubble_y = pet_rock_location[1] + bubble_offset[1] - self.thought_bubble_radius

# Draw the second bubble (below the first bubble)
pygame.draw.circle(screen, config.WHITE, (bubble_x + self.thought_bubble_radius, bubble_y + self.thought_bubble_radius), self.thought_bubble_radius)

# Draw the broccoli sprite inside the main thought bubble
item_x = bubble_x + (self.thought_bubble_radius - self.broccoli_item.rect.width // 2)
item_y = bubble_y + (self.thought_bubble_radius - self.broccoli_item.rect.height // 2)
screen.blit(image, (item_x, item_y))

def handle_event(self):



def handle_event(self, is_rock_dirty):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()

self.watering_can_item.handle_event(event,self.watering_can_location)
self.broccoli_item.handle_event(event, self.broccoli_location)
self.ball_item.handle_event(event, self.ball_location)
self.bed_item.handle_event(event, self.bed_location)
self.full_cup_item.handle_event(event, self.cup_item_location)

if is_rock_dirty == False:
self.broccoli_item.handle_event(event,self.broccoli_location, is_rock_dirty)
self.ball_item.handle_event(event, self.ball_location, is_rock_dirty)
self.bed_item.handle_event(event, self.bed_location, is_rock_dirty)
self.full_cup_item.handle_event(event, self.cup_item_location, is_rock_dirty)

self.watering_can_item.handle_event(event, self.watering_can_location, is_rock_dirty)

if(self.watering_can_item.get_collision_item() == config.ItemID.watering_can):
self.started_game_time = pygame.time.get_ticks()
# self.pet_stats.fill_thirst()
#self.is_rock_dirty = False
#self.pet_stats.fill_happiness()
elif(self.broccoli_item.get_collision_item() == config.ItemID.broccoli):
self.started_game_time = pygame.time.get_ticks()
self.pet_stats.fill_hunger()
Expand Down Expand Up @@ -118,11 +161,41 @@ def main_frames(self):
self.screen.blit(self.bed, self.bed_item.rect.topleft)
self.screen.blit(self.full_cup,self.full_cup_item.rect.topleft)
self.screen.blit(self.lamp_table.get_current_frame(), self.lamp_table.get_location())
self.current_frame = self.my_rock.get_current_frame()
self.my_rock_rect = self.current_frame.get_rect()
self.my_rock_rect.topleft = self.my_rock.get_location()

if self.pet_stats.get_pet_hunger() < 50:
self.is_hungry = True
if self.pet_stats.get_pet_hunger() > 49:
self.is_hungry = False
if self.pet_stats.get_pet_thirst() < 50:
self.is_thirsty = True
if self.pet_stats.get_pet_thirst() > 49:
self.is_thirsty = False
if self.pet_stats.get_pet_happiness() < 50:
self.is_sad = True
if self.pet_stats.get_pet_happiness() > 49:
self.is_sad = False

if self.is_rock_dirty == True:
self.draw_thought_bubble(self.screen, self.my_rock.get_location(),self.thought_of_watering_can)
if self.is_rock_dirty == False and self.is_hungry == True:
self.draw_thought_bubble(self.screen, self.my_rock.get_location(),self.broccoli_item.image)
if self.is_rock_dirty == False and self.is_hungry == False and self.is_thirsty == True:
self.draw_thought_bubble(self.screen, self.my_rock.get_location(), self.thought_of_full_cup)
if self.is_rock_dirty == False and self.is_hungry == False and self.is_thirsty == False and self.is_sad == True:
self.draw_thought_bubble(self.screen, self.my_rock.get_location(), self.thought_of_ball)


if (self.not_interacted and not self.is_rock_dirty) and self.my_rock.get_location()[0] < 1100:
self.my_rock.set_location(self.my_rock.get_location()[0]+30, self.my_rock.get_location()[1])
elif (self.not_interacted and not self.is_rock_dirty) and self.my_rock.get_location()[0] >= 1100:
self.my_rock.set_current_animation(Config.RockActions.dirty.value, False)
self.is_rock_dirty = True

#elif self.my_rock.get_location()[0] >= 1100 and self.is_rock_dirty == False:
#pass
self.my_rock.updated_frame()
if self.rock_collide_table():
self.lamp_table.update()
Expand All @@ -131,7 +204,7 @@ def main_frames(self):
self.my_rock.set_current_animation(Config.RockActions.jumping.value, True)
self.started_game_time = pygame.time.get_ticks() + (self.rock_misbehaving_time*1000)
self.not_interacted = True
self.handle_event()
self.handle_event(self.is_rock_dirty)
pygame.display.flip()

else:
Expand Down
4 changes: 2 additions & 2 deletions main_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self):
self.my_rock.set_location(x_location, y_location)
self.game_over_screen = GameOver(pygame, screen, self.my_rock)
self.current_screen = "start"
self.pet_rock_house = RockHouse()
self.pet_rock_house = None

def run(self):
running = True
Expand Down Expand Up @@ -148,7 +148,7 @@ def run(self):
scan_clicked_pet = self.my_pet_screen.handle_events()
if scan_clicked_pet is not None and scan_clicked_pet.get_pet_id() == self.my_rock.get_pet_id():
self.current_screen = "rock_house"
self.pet_rock_house = RockHouse()
self.pet_rock_house = RockHouse(screen)
elif self.current_screen == "rock_house":
self.pet_rock_house.main_frames()
else:
Expand Down
74 changes: 0 additions & 74 deletions status_bars.py

This file was deleted.

0 comments on commit 3dd4595

Please sign in to comment.