def show_city_score(city, city2): clock = pg.time.Clock() waiting = True time = 5 while waiting: dt = clock.tick(1) / 1000 time -= dt print(time) if time <= 0: waiting = False screen.blit(background, (0, 0)) text_speech( screen, "RobotoSlab-Medium.ttf", 30, f"Gunnar got {calc_mood_score(mood=gunnar.mood, city=city, live=False)} added to its health!", BLACK, 389, 150, True) text_speech(screen, "RobotoSlab-Medium.ttf", 30, f"Gunnar got his moodscore from {city}", BLACK, 389, 180, True) text_speech( screen, "RobotoSlab-Medium.ttf", 30, f"Ada got {calc_mood_score(mood=ada.mood, city=city2, live=False)} added to its health!", BLACK, 389, 300, True) text_speech(screen, "RobotoSlab-Medium.ttf", 30, f"Ada got her moodscore from {city2}", BLACK, 389, 330, True) pg.display.update()
def text_speech(screen, font: str, size: int, text: str, color, x, y, bold: bool): font = pg.font.Font(font, size) font.set_bold(bold) text = font.render(text, True, color) textRect = text.get_rect() textRect.center = (x, y) screen.blit(text, textRect)
def render(self, screen): pygame.draw.rect(screen, QUIZ_DARKGREEN, self.button_frame_rect, 4) # button frame mouse_pos = pygame.mouse.get_pos() if self.button_rect.collidepoint( mouse_pos ) and self.enabled: # If mouse on button - highlight button if len(self.highlight) == 4: s = pygame.Surface( (self.button_rect.width, self.button_rect.height), pygame.SRCALPHA) # per-pixel alpha s.fill(self.highlight) # notice the alpha value in the color screen.blit(s, self.button_rect) else: pygame.draw.rect(screen, self.highlight, self.button_rect) else: if len(self.color) == 4: s = pygame.Surface( (self.button_rect.width, self.button_rect.height), pygame.SRCALPHA) # per-pixel alpha s.fill(self.color) # notice the alpha value in the color screen.blit(s, self.button_rect) else: pygame.draw.rect(screen, self.color, self.button_rect) self.text.render(screen)
def render(self, screen): screen.fill(WHITE) screen.blit(background, (0, 0)) textbox_gunnar = TextBox((0.5, 0.2), "RobotoSlab-Medium.ttf", 25, False, YELLOW, self.text_gunnar) textbox_gunnar.render(screen) textbox_ada = TextBox((0.5, 0.2), "RobotoSlab-Medium.ttf", 25, False, RED, self.text_ada) textbox_ada.render(screen) x_off, y_off = periodic_movement(1, 5) if self.turn == "user": glada_gunnar(24, 144 + y_off, 122, 45) aggressive_ada(504, 156, 650, 550) else: glada_gunnar(24, 144, 122, 45) aggressive_ada(504, 156 + y_off, 650, 550) quit_button() # back_button() # Rotate sword depending on whose turn it is sword(self.turn)
def render(self, screen): screen.fill(WHITE) screen.blit(start_background, (0, 0)) screen.blit(logo, (215, -55)) start_game_button() instructions_button() quit_button_start()
def sword(turn): sword = pg.image.load("images/sword_resized.png") x_off, y_off = periodic_movement(1, 5) if turn == "user": rotate_image = pg.transform.rotozoom(sword, 0 + x_off, 1) else: rotate_image = pg.transform.rotozoom(sword, 70 + x_off, 1) new_rect = rotate_image.get_rect(center=(400, 300)) screen.blit(rotate_image, new_rect)
def crossed_sword(): double_sword = pg.image.load("images/Sword_crossed_01.PNG") double_sword = pg.transform.smoothscale(double_sword, (230, 230)) x_off, y_off = periodic_movement(1, 7) rect = double_sword.get_rect() shield = pg.transform.smoothscale( double_sword, (rect.width + int(x_off), rect.height + int(x_off))) blit_rect = shield.get_rect() blit_rect.center = (420, 280) screen.blit(shield, blit_rect)
def render(self, screen): # shadow for idx, text_surface_shadow in enumerate(self.text_lines_shadow): text_rect_shadow = text_surface_shadow.get_rect() text_rect_shadow.center = self.position[0] + 1, self.position[1] + 2 + idx * (self.font_size + 15) screen.blit(text_surface_shadow, text_rect_shadow) for idx, text_surface in enumerate(self.text_lines): text_rect = text_surface.get_rect() text_rect.center = self.position[0], self.position[1] + idx * (self.font_size + 15) screen.blit(text_surface, text_rect)
def render(self, screen): screen.blit(background, (0, 0)) # aggressive_ada(520, 300, 640, 300) # glada_gunnar(8, 30, 122, 45) choose_city_button() battle_time_button() quit_button() text_speech( screen, "RobotoSlab-Medium.ttf", 25, "Press battle to get a random mood score, or choose a city!", BLACK, 400, 200, True) pg.display.update()
def aggressive_ada(x, y, a, b): screen.blit(ada.image, (x, y)) text_speech(screen, "RobotoSlab-Medium.ttf", 15, f"{ada.name}", ada.color, a, b, True) text_speech(screen, "RobotoSlab-Medium.ttf", 15, f"Attack: {ada.attack} Mood: {ada.mood}", WHITE, 630, 575, True) bg_bar1 = pg.Rect(50, 530, 2 * ada.max_health, 50) hp_bar1 = pg.Rect(50, 530, 200 * (ada.health * 0.01), 50) if ada.health > 0: pg.draw.rect(screen, (255, 0, 0), bg_bar1) pg.draw.rect(screen, (0, 255, 0), hp_bar1) text_speech(screen, "RobotoSlab-Medium.ttf", 15, f"HP: {ada.health}/{ada.max_health}", BLACK, 125, 555, True)
def glada_gunnar(x, y, a, b): screen.blit(gunnar.image, (x, y)) text_speech(screen, "RobotoSlab-Medium.ttf", 15, f"{gunnar.name}", gunnar.color, a, b, True) text_speech(screen, "RobotoSlab-Medium.ttf", 15, f" Attack: {gunnar.attack}, Mood: {gunnar.mood}", WHITE, 170, 20, True) bg_bar1 = pg.Rect(200, 50, 2 * gunnar.max_health, 50) hp_bar1 = pg.Rect(200, 50, 200 * (gunnar.health * 0.01), 50) if gunnar.health > 0: pg.draw.rect(screen, (255, 0, 0), bg_bar1) pg.draw.rect(screen, (0, 255, 0), hp_bar1) text_speech(screen, "RobotoSlab-Medium.ttf", 15, f"HP: {gunnar.health}/{gunnar.max_health}", BLACK, 275, 75, True)
def render(self, screen): screen.fill(WHITE) screen.blit(background, (0, 0)) x_off, y_off = periodic_movement(1, 5) aggressive_ada(504, 156, 650, 550) glada_gunnar(24, 144 + y_off, 122, 45) screen.blit(vs_sign1, (300, 225)) quit_button() block_button() attack_button() special_attack_button() quiz_button() textbox_gunnar = TextBox((0.5, 0.2), "RobotoSlab-Medium.ttf", 30, False, WHITE, "It's your turn!") textbox_gunnar.render(screen)
def render(self, screen): screen.fill(WHITE) screen.blit(background_win, (0, 0)) ada_win_pic = pg.image.load("images/Pink_dragon_08.png") ada_win_pic = pg.transform.scale(ada_win_pic, (350, 350)) screen.blit(ada_win_pic, (205, 285)) winning_crown_ada_moving() gunnar_lose = pg.transform.scale(gunnar.image, (200, 200)) screen.blit(gunnar_lose, (25, 355)) tear_drop = pg.image.load("images/tear-png-20.png") tear_drop = pg.transform.scale(tear_drop, (25, 25)) screen.blit(tear_drop, (90, 430)) screen.blit(logo, (215, -55)) text_speech(screen, "RobotoSlab-Medium.ttf", 30, "Better luck next time,", YELLOW_LIGHT, 386, 150, True) text_speech(screen, "RobotoSlab-Medium.ttf", 30, f"{ada.name} won!", YELLOW_LIGHT, 385, 200, True) quit_button()
def render(self, screen): screen.fill(WHITE) screen.blit(background_win, (0, 0)) x_off, y_off = periodic_movement(1, 5) #CL gunnar_bigger = pg.transform.scale(gunnar.image, (350, 350)) screen.blit(gunnar_bigger, (220, 235 + y_off)) winning_crown_hasse_moving() pink_dragon_sad = pg.image.load("images/Pink_dragon_05.png") pink_dragon_sad = pg.transform.scale(pink_dragon_sad, (204, 235)) screen.blit(pink_dragon_sad, (25, 340)) screen.blit(logo, (213, -55)) tear_drop = pg.image.load("images/tear-png-20.png") tear_drop = pg.transform.scale(tear_drop, (25, 25)) screen.blit(tear_drop, (120, 410)) text_speech(screen, "RobotoSlab-Medium.ttf", 30, "Congratulations,", YELLOW_LIGHT, 389, 150, True) text_speech(screen, "RobotoSlab-Medium.ttf", 30, f"{gunnar.name} won!", YELLOW_LIGHT, 388, 200, True) quit_button()
def right_chat_bubble(mood_score): right_bubble = pg.image.load("images/Chat_bubble_right.png") right_bubble = pg.transform.scale(right_bubble, (300, 170)) screen.blit(right_bubble, (260, 350)) text_speech(screen, "RobotoSlab-Medium.ttf", 15, f"Moodscore: {mood_score}", BLACK, 370, 435, True)
def left_chat_bubble(mood_score): left_bubble = pg.image.load("images/Chat_bubble_left.png") left_bubble = pg.transform.scale(left_bubble, (300, 170)) screen.blit(left_bubble, (250, 50)) text_speech(screen, "RobotoSlab-Medium.ttf", 15, f"Moodscore: {mood_score}", BLACK, 390, 135, True)
def winning_crown_hasse_moving(): winning_crown = pg.image.load("images/crown.png") winning_crown = pg.transform.scale(winning_crown, (170, 140)) x_off, y_off = periodic_movement(1, 5) screen.blit(winning_crown, (270, 180 + y_off))
def winning_crown_ada_moving(): winning_crown = pg.image.load("images/crown.png") winning_crown = pg.transform.scale(winning_crown, (151, 124)) x_off, y_off = periodic_movement(1, 5) screen.blit(winning_crown, (340, 245 + y_off))
def render(self, screen): screen.fill(WHITE) screen.blit(start_background, (0, 0)) screen.blit(instructions_frame, (75, 75)) back_button() quit_button()
def render(self, screen): screen.blit(background, (0, 0)) for city in self.city_buttons: city.render(screen)
def shield(): shield_pic = pg.image.load("images/shield_white.png") x_off, y_off = periodic_movement(1, 5) rotate_image = pg.transform.rotozoom(shield_pic, 0 + x_off, 1) new_rect = rotate_image.get_rect(center=(400, 300)) screen.blit(rotate_image, new_rect)