2023-05-11 15:24:17 -04:00
|
|
|
import pygame
|
2023-05-13 13:11:47 -04:00
|
|
|
from pocket_friends.elements import sprites
|
|
|
|
from pocket_friends.elements import surface
|
2023-05-11 15:24:17 -04:00
|
|
|
|
|
|
|
|
2023-05-13 13:07:33 -04:00
|
|
|
class Surface(surface.GameSurface):
|
|
|
|
def __init__(self, game_res, resources_dir, game_fps, **kwargs):
|
|
|
|
super().__init__(game_res, resources_dir, game_fps)
|
2023-05-12 11:20:00 -04:00
|
|
|
|
2023-05-13 13:07:33 -04:00
|
|
|
preselected_color = None
|
|
|
|
for key in kwargs.keys():
|
|
|
|
if key == 'selected_color':
|
|
|
|
preselected_color = kwargs.get(key)
|
2023-05-11 15:24:17 -04:00
|
|
|
|
|
|
|
self.selected_egg = None
|
|
|
|
for key in kwargs.keys():
|
|
|
|
if key == 'selected_egg':
|
|
|
|
self.selected_egg = kwargs.get(key)
|
|
|
|
|
|
|
|
egg = sprites.SelectionEgg(self.selected_egg, resources_dir)
|
|
|
|
egg.rect.x = 8
|
|
|
|
egg.rect.y = 3
|
|
|
|
self.sprites.add(egg)
|
|
|
|
|
2023-05-13 13:07:33 -04:00
|
|
|
self.info_text = sprites.InfoText(resources_dir, game_res[0], egg.description)
|
2023-05-11 15:24:17 -04:00
|
|
|
self.info_icons = sprites.EggInfo(resources_dir, egg.contentedness, egg.metabolism, (32, 4))
|
|
|
|
|
|
|
|
def update(self):
|
2023-05-13 13:07:33 -04:00
|
|
|
self.preprocess()
|
2023-05-11 15:24:17 -04:00
|
|
|
|
|
|
|
self.info_text.draw(self)
|
|
|
|
self.info_icons.draw(self)
|
|
|
|
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.KEYDOWN:
|
2023-05-13 10:46:34 -04:00
|
|
|
if event.key == pygame.K_DOWN:
|
2023-05-11 15:24:17 -04:00
|
|
|
# Scroll down on the info screen.
|
|
|
|
self.info_text.scroll_down()
|
2023-05-13 10:46:34 -04:00
|
|
|
if event.key == pygame.K_UP:
|
2023-05-11 15:24:17 -04:00
|
|
|
# Scroll up on the info screen.
|
|
|
|
self.info_text.scroll_up()
|
2023-05-13 10:46:34 -04:00
|
|
|
if event.key == pygame.K_a:
|
2023-05-12 17:34:13 -04:00
|
|
|
self.running = False
|
|
|
|
self.additional_args = {'selected_color': self.selected_egg}
|
|
|
|
self.next_surface = 'playground'
|
2023-05-13 10:46:34 -04:00
|
|
|
if event.key == pygame.K_b:
|
2023-05-11 15:24:17 -04:00
|
|
|
self.running = False
|
|
|
|
self.additional_args = {'selected_color': self.selected_egg}
|
|
|
|
self.next_surface = 'egg_select'
|