10 examples of 'pygame.display.init' in Python

Every line of 'pygame.display.init' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
24def __init__(self, pygame, screenWidth, screenHeight, numberOfJoysticks):
25 DisplayScreen.__init__(self, pygame, screenWidth, screenHeight)
26 margin = 20
27 self.numberOfJoysticks = numberOfJoysticks
28 self.rect = [(margin,margin,(self.screenWidth-margin*3)/2,(self.screenHeight-margin*3)/2), ((self.screenWidth-margin*3)/2 + 40,20,(self.screenWidth-margin*3)/2,(self.screenHeight-margin*3)/2), (20,(self.screenHeight-margin*3)/2+40,(self.screenWidth-margin*3)/2,(self.screenHeight-margin*3)/2), ((self.screenWidth-margin*3)/2 + 40,(self.screenHeight-margin*3)/2 + 40,(self.screenWidth-margin*3)/2,(self.screenHeight-margin*3)/2)]
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

65def init_screen(width, height):
66 return pygame.display.set_mode((width, height), pygame.RESIZABLE)
7def __init__(self):
8 pygame.display.init()
9 infoObject = pygame.display.Info()
10 self.screen = pygame.display.set_mode((infoObject.current_w, infoObject.current_h), pygame.FULLSCREEN)
11 self.player = Player([300,300])
12 self.game_running = True
214def _init_pygame(self):
215 # Initialize pygame, open screen and fill screen with background color
216 #os.environ['SDL_VIDEODRIVER'] = self.video_driver # Set video driver
217 pygame.init()
218 if self.fullscreen:
219 #use opts = pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.FULLSCREEN to use doublebuffer and vertical sync
220 opts = pygame.FULLSCREEN
221 self.screen = pygame.display.set_mode((self.screenWidth,self.screenHeight),opts)
222 else:
223 self.screen = pygame.display.set_mode((self.screenWidth,self.screenHeight))
224 self.background = pygame.Surface( (self.canvasWidth,self.canvasHeight) )
225 self.background.fill(self.bgcolor)
226 self.background_rect = self.background.get_rect(center = (self.screenWidth/2,self.screenHeight/2) )
227 # Background for whole screen (needs lots of time to paint, use self.background in most cases)
228 self.all_background = pygame.Surface( (self.screenWidth,self.screenHeight) )
229 self.all_background.fill(self.bgcolor)
230 self.all_background_rect = self.all_background.get_rect(center = (self.screenWidth/2,self.screenHeight/2) )
231 self.screen.blit(self.all_background,self.all_background_rect)
232 pygame.display.flip()
233 self.screen.blit(self.all_background,self.all_background_rect)
234 self.clock = pygame.time.Clock()
235 pygame.mouse.set_visible(False)
236 # init sound engine
237 pygame.mixer.init()
238 if self.pygame_info: # If true, give some information
239 inf = pygame.display.Info()
240 driver = pygame.display.get_driver()
241 text = "PYGAME SYSTEM INFO\n\n"
242 text += "Display driver: "+str(driver)+"\nFullscreen: "+str(self.fullscreen)
243 text += "\nhw: "+str(inf.hw)+"\nwm: "+str(inf.wm)
244 text += "\nvideo_mem: "+str(inf.video_mem) +"\nbytesize: "+str(inf.bytesize)
245 text += "\nblit_hw: "+str(inf.blit_hw) +"\nblit_hw_CC: "+str(inf.blit_hw_CC)+"\nblit_hw_A: "+str(inf.blit_hw_A)
246 text += "\nblit_sw: "+str(inf.blit_sw) +"\nblit_sw_CC: "+str(inf.blit_sw_CC)+"\nblit_sw_A: "+str(inf.blit_sw_A)
247 show_message(self,text,box=True)
248 wait_for_key()
100def __init__(self, width=640, height=400, fps=30):
101 """Initialize pygame, window, background, font,...
102 default arguments
103 """
104
105 pygame.mixer.pre_init(44100, -16, 2, 2048)
106
107 pygame.init()
108
109 #self.cash = pygame.mixer.Sound(os.path.join("data","cash.wav"))
110 #jump = pygame.mixer.Sound(os.path.join('data','jump.wav')) #load sound
111 #self.sound1 = pygame.mixer.Sound(os.path.join('data','Pickup_Coin.wav'))
112 #self.sound2 = pygame.mixer.Sound(os.path.join('data','Jump.wav'))
113 #self.sound3 = pygame.mixer.Sound(os.path.join('data','mix.wav'))
114 pygame.display.set_caption("Press ESC to quit")
115 PygView.width = width
116 PygView.height = height
117 self.set_resolution()
118 self.clock = pygame.time.Clock()
119 self.fps = fps
120 self.playtime = 0.0
121 self.font = pygame.font.SysFont('mono', 24, bold=True)
336def __init__(self):
337 # It seems, in Linux buffersize=512 is not enough, use 4096 to prevent:
338 # ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred
339 mixer.pre_init(44100, -16, 1, 4096)
340 init()
341 self.caption = display.set_caption('Space Invaders')
342 self.screen = SCREEN
343 self.background = image.load(IMAGE_PATH + 'background.jpg').convert()
344 self.startGame = False
345 self.mainScreen = True
346 self.gameOver = False
347 # Counter for enemy starting position (increased each new round)
348 self.enemyPosition = ENEMY_DEFAULT_POSITION
88def setup():
89 pygame.init()
90 pygame.display.set_mode((width, height), OPENGL | DOUBLEBUF)
91 pygame.display.set_caption('Look, an OpenGL window!')
119def __init__(self, width, height, blocksize, fullscreen=False):
120 Interface.__init__(self, width, height, blocksize)
121 self.flags = pygame.DOUBLEBUF | pygame.HWSURFACE
122 if fullscreen:
123 self.flags |= pygame.FULLSCREEN
124 self.window = self.pygame.display.set_mode((self.width, self.height),
125 self.flags)
40def initialize_game(): # loading settings into memory
41 pygame.font.init()
42 pygame.display.init()
43
44 pygame.event.clear() #event queue settings
45 pygame.event.set_allowed(None)
46 pygame.event.set_allowed(pygame.KEYDOWN)
47 pygame.event.set_allowed(pygame.QUIT)
11def __init__(s, fr_height, fr_width, filename=None, img=None, random=False, biased=False):
12 if filename is not None:
13 s.img = pygame.image.load(filename)
14 else:
15 s.img = pygame.surfarray.make_surface(np.swapaxes(img,0,True))
16 s.textureData = pygame.image.tostring(s.img, "RGB", 1)
17 s.aspect_ratio = fr_width/fr_height
18 s.width = s.img.get_width()
19 s.height = s.img.get_height()
20 s.z_angle = 0
21
22 # 3d coordinates of image
23 s.vert = np.array([[0, 0, 0],
24 [0, s.height, 0],
25 [s.width, s.height, 0],
26 [s.width, 0, 0]], dtype=np.float32)
27
28 #opengl boilerplate code
29 s.im = glGenTextures(1)
30 glBindTexture(GL_TEXTURE_2D, s.im)
31
32 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
33 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, s.width, s.height, 0, GL_RGB, GL_UNSIGNED_BYTE, s.textureData)
34 glEnable(GL_TEXTURE_2D)
35
36 glLoadIdentity()
37 gluPerspective(45, s.aspect_ratio, 0.05, 10000)
38
39 #initial adjustments
40 s.translate(0,0,-s.height/10) #lift the camera slightly
41 s.random_settings = {}
42 if biased:
43 s.deg_bias = np.random.uniform(-1/5,1/5) # degrees
44 s.x_bias = np.random.uniform(-1,1) #track pixels
45 s.y_bias = np.random.uniform(-1,1) #track pixles
46 else:
47 s.deg_bias = 0
48 s.x_bias = 0
49 s.y_bias = 0
50
51 if random:
52 s.deg_stddev = 1/10
53 s.x_stddev = 1/10
54 s.y_stddev = 1/10
55 else:
56 s.deg_stddev = 0
57 s.x_stddev = 0
58 s.y_stddev = 0

Related snippets