From fbe647ad78ef7cbe6e3febb73ad1b766b7bd3951 Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Sun, 19 Sep 2021 20:29:24 +0200 Subject: [PATCH] Added rescale button --- gamedata/game.py | 2 +- gamedata/objects/rescalebutton.py | 16 ++++++++++++++++ gamedata/scenes.py | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 gamedata/objects/rescalebutton.py diff --git a/gamedata/game.py b/gamedata/game.py index 21954ff..dc75c76 100644 --- a/gamedata/game.py +++ b/gamedata/game.py @@ -12,8 +12,8 @@ class Game(): self.realwindow = pygame.Surface((self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT)) self.screen = pygame.display.set_mode((self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT),pygame.RESIZABLE) self.screenw,self.screenh = self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT - self.resizescreenw,self.resizescreenh = self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT self.screenoffx,self.screenoffy = 0,0 + self.resizescreenw,self.resizescreenh = self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT pygame.display.set_caption("Pinmik Panik !") pygame.init() pygame.mixer.init() diff --git a/gamedata/objects/rescalebutton.py b/gamedata/objects/rescalebutton.py new file mode 100644 index 0000000..fc0284c --- /dev/null +++ b/gamedata/objects/rescalebutton.py @@ -0,0 +1,16 @@ +from gamedata.objects.button import Button + +class Rescale(Button): + + def __init__(self,x,y,game,w,h): + + super().__init__(x,y,game,w,h) + + self.text = "Reset window scale" + + def reset(self,game): + game.screen = game.pygame.display.set_mode((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT),game.pygame.RESIZABLE) + game.screenw,game.screenh = game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT + game.screenoffx,game.screenoffy = 0,0 + + self.click = reset diff --git a/gamedata/scenes.py b/gamedata/scenes.py index 7b10c32..2c9015e 100644 --- a/gamedata/scenes.py +++ b/gamedata/scenes.py @@ -10,6 +10,7 @@ from gamedata.objects.gameover import GameOver from gamedata.objects.ingame.skies import Skies from gamedata.objects.ingame.clouds import Clouds from gamedata.objects.resetbutton import Reset +from gamedata.objects.rescalebutton import Rescale def main(game): game.scaleCamera() @@ -39,11 +40,13 @@ def options(game): game.globals["cameray"] = 0 s = BGMSlider(40,40,game,400,40) s2 = SFXSlider(40,100,game,400,40) - btn = Reset(40,160 ,game,400,40) + btn = Rescale(40,160 ,game,400,40) + btn2 = Reset(40,220,game,400,40) menu = OptionMenu(round(game.DISPLAY_WIDTH/8),round(game.DISPLAY_HEIGHT*9/10),game,round(game.DISPLAY_WIDTH*6/8),round(game.DISPLAY_HEIGHT/10-game.DISPLAY_HEIGHT/30)) game.gameloop.summon(s) game.gameloop.summon(s2) game.gameloop.summon(btn) + game.gameloop.summon(btn2) game.gameloop.summon(menu) def gameover(game):