From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Fri, 2 Jun 2023 12:21:28 +0000 (-0400) Subject: resolution + fullscrn + esc exit X-Git-Tag: game~26 X-Git-Url: http://git.skullheadx.com/about.html?a=commitdiff_plain;h=186e3333746c5f618a265eb6af60e14e03cee34a;p=fruit-ninja.git resolution + fullscrn + esc exit --- diff --git a/game.py b/game.py index ce812d3..5e91931 100644 --- a/game.py +++ b/game.py @@ -5,7 +5,7 @@ from bomb import Bomb class Game: - BOMB_CHANCE = 0.5 + BOMB_CHANCE = 0.1 def __init__(self): self.player = Player() @@ -17,6 +17,9 @@ class Game: for event in pygame.event.get(): if event.type == pygame.QUIT: return COMMAND_EXIT + if event.type == pygame.KEYUP: + if event.key == pygame.K_ESCAPE: + return COMMAND_EXIT self.player.update(delta) hits = [] for fruit in self.fruits: @@ -24,7 +27,7 @@ class Game: if self.player.hits(fruit): hits.append(fruit) fr = fruit.get_rect() - if (not -fruit.radius <= fr.x < WIDTH) or fr.y > HEIGHT: + if (not -fruit.radius < fr.x < WIDTH + fruit.radius) or fr.y > HEIGHT: self.fruits.remove(fruit) for hit in hits: @@ -35,7 +38,7 @@ class Game: if self.player.hits(bomb): return COMMAND_START br = bomb.get_rect() - if (not -bomb.RADIUS <= br.x < WIDTH) or br.y > HEIGHT: + if (not -bomb.RADIUS < br.x < WIDTH + bomb.RADIUS) or br.y > HEIGHT: self.bombs.remove(bomb) if len(self.fruits) == 0 and len(self.bombs) == 0: diff --git a/setup.py b/setup.py index b797d1a..5147b9a 100644 --- a/setup.py +++ b/setup.py @@ -2,9 +2,9 @@ import pygame import random pygame.init() -WIDTH, HEIGHT = 800, 500 +WIDTH, HEIGHT = pygame.display.Info().current_w, pygame.display.Info().current_h -screen = pygame.display.set_mode((WIDTH, HEIGHT)) +screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN) pygame.display.set_caption("Fruit Ninja")