How to use setDisplaySize method in fMBT

Best Python code snippet using fMBT_python

main.py

Source:main.py Github

copy

Full Screen

...1213 def setTitle(self, new_title: str = ""):14 pygame.display.set_caption(new_title)1516 def setDisplaySize(self, x: int = 0, y: int = 0):17 self.display = pygame.display.set_mode((x, y))1819 def loadBackground(self, path_to_image: str = ""):20 self.background = pygame.image.load(path_to_image)2122 def addObjectsToSpriteGroup(self, entities: list, group: object):23 for entity in entities:24 group.add(entity)2526 def startLevel(self):27 self.Level = Level()28 self.Level.loadObjects()29 self.SpritesGroup = pygame.sprite.Group()30 self.addObjectsToSpriteGroup(31 self.Level.getPlatfroms(), self.SpritesGroup)32 self.addObjectsToSpriteGroup(self.Level.getMonsters(), self.SpritesGroup)3334 self.Player = Player(55, 55)35 self.SpritesGroup.add(self.Player)36 self.Clock = pygame.time.Clock()37 self.Camera = Camera(self.Level.width, self.Level.height)38 def loop(self):39 #mn = monster.Monster(120, 200, 2, 3, 150, 15)4041 while True:4243 self.Clock.tick(60)44 for event in pygame.event.get():45 if event.type == pygame.QUIT:46 print("Exiting game...")47 exit()4849 if event.type == pygame.KEYUP or event.type == pygame.KEYDOWN:50 self.Player.setKey(event)5152 self.display.blit(self.background, (0, 0))53 self.Player.move(self.Level.getPlatfroms(), self.SpritesGroup)54 self.addObjectsToSpriteGroup(55 self.Level.getPlatfroms(), self.SpritesGroup)56 # mn.update(self.Level.getPlatfroms())5758 self.Camera.update(self.Player)59 for ent in self.SpritesGroup:60 self.display.blit(61 ent.image, self.Camera.applyCorrdinatesToObject(ent))62 ent.update(self.Level.getPlatfroms())63 6465 pygame.display.update()666768if __name__ == "__main__":69 main = Main()70 main.setTitle(Title)71 main.setDisplaySize(X, Y)72 main.loadBackground("./levels/bg.jpg")73 main.startLevel() ...

Full Screen

Full Screen

option.py

Source:option.py Github

copy

Full Screen

1#coding: utf82from OpenGL import GL3import sdl24import sdl2.ext5from program.const import *6from program.box import BOX7from sequence.locals import MenuItems, backimage8from sequence.keyconfig import KeyConfig9from sequence.setdisplaysize import SetDisplaySize10class Option(object):11 def __init__(self):12 self.texts = ["Key Config",13 "Display Size"]14 self.goto = [KeyConfig(),15 SetDisplaySize()]16 17 def init(self):18 self.menu = MenuItems(self.texts, BOX.Y/10, ret=True, title="Option")19 def mainloop(self):20 self.init()21 while True:22 choice = -123 for event in sdl2.ext.get_events():24 if event.type == sdl2.SDL_QUIT:25 BOX.game_quit()26 elif event.type == sdl2.SDL_KEYDOWN:27 key = event.key.keysym.sym28 if key in KS_ESC:29 if self.menu.choice == self.menu.RETURN:30 return31 else:32 choice = self.menu.RETURN33 break34 elif key == sdl2.SDLK_UP:35 self.menu.up()36 elif key == sdl2.SDLK_DOWN:37 self.menu.down()38 elif key in KS_RETURN:39 choice = self.menu.choice40 break41 elif event.type == sdl2.SDL_MOUSEBUTTONDOWN:42 mouse = event.button43 if mouse.button == 1:44 choice = self.menu.mouse_check(mouse.x, mouse.y)45 break46 if 0 <= choice:47 if choice == self.menu.RETURN:48 return49 else:50 self.goto[choice].mainloop()51 self.init()52 #self.menu.choice = self.menu.RETURN53 54 backimage.draw()55 self.menu.draw()56 sdl2.SDL_GL_SwapWindow(BOX.window)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful