Added rescale button

This commit is contained in:
theo@manjaro 2021-09-19 20:29:24 +02:00
parent 5066d84f8d
commit fbe647ad78
3 changed files with 21 additions and 2 deletions

View File

@ -12,8 +12,8 @@ class Game():
self.realwindow = pygame.Surface((self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT)) 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.screen = pygame.display.set_mode((self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT),pygame.RESIZABLE)
self.screenw,self.screenh = self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT 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.screenoffx,self.screenoffy = 0,0
self.resizescreenw,self.resizescreenh = self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT
pygame.display.set_caption("Pinmik Panik !") pygame.display.set_caption("Pinmik Panik !")
pygame.init() pygame.init()
pygame.mixer.init() pygame.mixer.init()

View File

@ -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

View File

@ -10,6 +10,7 @@ from gamedata.objects.gameover import GameOver
from gamedata.objects.ingame.skies import Skies from gamedata.objects.ingame.skies import Skies
from gamedata.objects.ingame.clouds import Clouds from gamedata.objects.ingame.clouds import Clouds
from gamedata.objects.resetbutton import Reset from gamedata.objects.resetbutton import Reset
from gamedata.objects.rescalebutton import Rescale
def main(game): def main(game):
game.scaleCamera() game.scaleCamera()
@ -39,11 +40,13 @@ def options(game):
game.globals["cameray"] = 0 game.globals["cameray"] = 0
s = BGMSlider(40,40,game,400,40) s = BGMSlider(40,40,game,400,40)
s2 = SFXSlider(40,100,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)) 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(s)
game.gameloop.summon(s2) game.gameloop.summon(s2)
game.gameloop.summon(btn) game.gameloop.summon(btn)
game.gameloop.summon(btn2)
game.gameloop.summon(menu) game.gameloop.summon(menu)
def gameover(game): def gameover(game):