]> Skullheadx's Git Forge - fruit-ninja.git/commitdiff
resolution + fullscrn + esc exit
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 2 Jun 2023 12:21:28 +0000 (08:21 -0400)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 2 Jun 2023 12:21:28 +0000 (08:21 -0400)
game.py
setup.py

diff --git a/game.py b/game.py
index ce812d3c3c748e62798eac4cf68437ff6e130d8d..5e919312614be8c43013808aaac5f12e259330f3 100644 (file)
--- 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:
index b797d1a8020b4e84ce99cc5ad9f559c7900f6714..5147b9aaba0b49581e0b5e2310220f7cfbbb75a9 100644 (file)
--- 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")