|
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 | |
|---|
| 1 | import sys |
|---|
| 2 | import pygame |
|---|
| 3 | from pygame.locals import * |
|---|
| 4 | |
|---|
| 5 | # initialise |
|---|
| 6 | pygame.init() |
|---|
| 7 | oClock = pygame.time.Clock() |
|---|
| 8 | |
|---|
| 9 | # find best resolution and depth |
|---|
| 10 | for 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 |
|---|
| 17 | else: |
|---|
| 18 | print 'No modes found.' |
|---|
| 19 | sys.exit(1) |
|---|
| 20 | |
|---|
| 21 | # setup |
|---|
| 22 | pygame.display.set_caption("Nexus") |
|---|
| 23 | pygame.mouse.set_visible(1) |
|---|
| 24 | |
|---|
| 25 | # create background surface |
|---|
| 26 | background = pygame.Surface(oScreen.get_size()) |
|---|
| 27 | background = background.convert() |
|---|
| 28 | background.fill((200, 200, 250)) |
|---|
| 29 | |
|---|
| 30 | # display background while game loads |
|---|
| 31 | oScreen.blit(background, (0, 0)) |
|---|
| 32 | pygame.display.flip() |
|---|
| 33 | |
|---|
| 34 | # small event loop |
|---|
| 35 | while 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) |
|---|