Skip to content

Commit

Permalink
hid infoboxes, replaced fullscreen for windowed max
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoch2 committed Apr 16, 2024
1 parent 681ad93 commit f142462
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
64 changes: 44 additions & 20 deletions src/PlantEd/client/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ def return_to_menu(self):
config.write_options(self.get_options())
self.manager.go_to(TitleScene(self.manager))

def set_full_screen(self, fullscreen: bool):
options = config.load_options()
options["fullscreen"] = fullscreen
config.write_options(options)

def init_labels(self):
center_w, center_h = config.SCREEN_WIDTH / 2, config.SCREEN_HEIGHT / 2

Expand Down Expand Up @@ -447,10 +452,10 @@ def handle_events(self, events: List[pygame.event.Event]):
self.ui.handle_event(e)
if self.ui.pause or self.ui.infobox_manager.visible:
continue

if e.type == WIN:
self.quit()

if e.type == pygame.QUIT:
self.quit()
self.shop.handle_event(e)
# self.floating_shop.handle_event(e)
self.plant.handle_event(e)
Expand Down Expand Up @@ -574,7 +579,6 @@ async def send_and_get_response(self, dt):
if self.frames_waited >= MAX_TIME_RESPONSE:
self.soft_stopp_timer = BUFFER_TIMER
self.gametime.pause()
print(f"FRAMES WAITED: {self.frames_waited}")

def update(self, dt):
self.fps = 1 / dt
Expand Down Expand Up @@ -666,13 +670,13 @@ def render(self, screen):
self.shop.draw(screen)
self.ui.draw(screen)

if self.soft_stopp_timer > 0:
pygame.draw.rect(screen, config.RED, (200, 200, 200, 200))
#if self.soft_stopp_timer > 0:
# pygame.draw.rect(screen, config.RED, (200, 200, 200, 200))

fps_label = self.asset_handler.FONT_24.render(f"{self.fps:.2f}", True, config.WHITE)
frames_waited = self.asset_handler.FONT_24.render(f"{self.frames_waited:.2f}", True, config.WHITE)
screen.blit(frames_waited, (self.screen_width / 5 * 3 + 100, self.screen_height / 15))
screen.blit(fps_label, (self.screen_width / 5 * 3, self.screen_height / 15))
#fps_label = self.asset_handler.FONT_24.render(f"{self.fps:.2f}", True, config.WHITE)
#frames_waited = self.asset_handler.FONT_24.render(f"{self.frames_waited:.2f}", True, config.WHITE)
#screen.blit(frames_waited, (self.screen_width / 5 * 3 + 100, self.screen_height / 15))
#screen.blit(fps_label, (self.screen_width / 5 * 3, self.screen_height / 15))

self.narrator.draw(screen)

Expand Down Expand Up @@ -1207,14 +1211,41 @@ def render(self, screen):

class SceneMananger(object):
def __init__(self):
display_info = pygame.display.Info()
options = config.load_options()
options["aspect_ratio"] = (display_info.current_w, display_info.current_h)
self.screen = pygame.display.set_mode(
options["aspect_ratio"], pygame.RESIZABLE | pygame.DOUBLEBUF, 16
)
display_info = pygame.display.Info()
options["aspect_ratio"] = (display_info.current_w, display_info.current_h)
self.screen = pygame.display.set_mode(
options["aspect_ratio"], pygame.RESIZABLE | pygame.DOUBLEBUF, 16
)
config.write_options(options)
self.go_to(TitleScene(self))

def on_resize(self):
display_info = pygame.display.Info()
options = config.load_options()
options["aspect_ratio"] = (display_info.current_w, display_info.current_h)

self.screen = pygame.display.set_mode(
options["aspect_ratio"], pygame.RESIZABLE | pygame.DOUBLEBUF, 16
)

config.write_options(options)
#self.go_to(TitleScene(self))

def handle_events(self, events):
self.scene.handle_events(events)

def go_to(self, scene):
self.scene = scene
self.scene.manager = self

def render(self, screen):
self.scene.render(screen)
def render(self):
self.scene.render(self.screen)
# screen.blit(screen_high,(0,-100))
# self.camera.render(screen_high, screen)

Expand All @@ -1233,14 +1264,7 @@ async def main():
pygame.init()
# screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), pygame.HWSURFACE | pygame.DOUBLEBUF)

display_info = pygame.display.Info()
options = config.load_options()
options["aspect_ratio"] = (display_info.current_w, display_info.current_h)

screen = pygame.display.set_mode(
options["aspect_ratio"], pygame.DOUBLEBUF, 16
)
config.write_options(options)
timer = pygame.time.Clock()
running = True
# camera = Camera()
Expand All @@ -1255,9 +1279,9 @@ async def main():
break

# manager handles the current scene
manager.scene.handle_events(pygame.event.get())
manager.handle_events(pygame.event.get())
manager.scene.update(dt)
manager.scene.render(screen)
manager.render()
pygame.display.update()
await asyncio.sleep(0)

Expand Down
3 changes: 2 additions & 1 deletion src/PlantEd/client/gameobjects/infobox_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def handle_event(self, e):
self.show_button.handle_event(e)

def draw(self, screen):
self.show_button.draw(screen)
pass
#self.show_button.draw(screen)
if self.visible:
if len(self.boxes) > 0:
self.boxes[self.active_box].draw(screen)
Expand Down
2 changes: 1 addition & 1 deletion src/PlantEd/options.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"aspect_ratio": [2560, 1440], "music_volume": 0.0, "sfx_volume": 0.14444444444444443, "narator_volume": 0.0, "icon_name": "penguin", "name": "Cheeky Merrygig", "score": 29}
{"aspect_ratio": [1850, 1016], "music_volume": 0.0, "sfx_volume": 0.14444444444444443, "narator_volume": 0.0, "icon_name": "chick", "name": "Dandy Grinner", "score": 29}

0 comments on commit f142462

Please sign in to comment.