root/hodgestar/PythonCode/SmallScripts/nexus.py

Revision 375, 1.0 kB (checked in by simon, 4 years ago)

Miscellaneous small scripts.

  • Property svn:mime-type set to text/python-source
  • Property svn:eol-style set to native
Line 
1import sys
2import pygame
3from pygame.locals import *
4
5# initialise
6pygame.init()
7oClock = pygame.time.Clock()
8
9# find best resolution and depth
10for iDepth in [32,24,16,8]:
11    aModes = pygame.display.list_modes(iDepth)
12    if aModes:
13        print 'Using Pixel Depth:' , iDepth
14        print 'Using Resolution:' , aModes[0]
15        oScreen = pygame.display.set_mode(aModes[0], FULLSCREEN, iDepth)
16        break
17else:
18    print 'No modes found.'
19    sys.exit(1)
20
21# setup
22pygame.display.set_caption("Nexus")
23pygame.mouse.set_visible(1)
24
25# create background surface
26background = pygame.Surface(oScreen.get_size())
27background = background.convert()
28background.fill((200, 200, 250))
29
30# display background while game loads
31oScreen.blit(background, (0, 0))
32pygame.display.flip()
33
34# small event loop
35while 1:
36    oClock.tick(60)
37    for event in pygame.event.get():
38        if event.type == QUIT:
39            sys.exit(0)
40        elif event.type == KEYDOWN and event.key == K_ESCAPE:
41            sys.exit(0)
Note: See TracBrowser for help on using the browser.