# HG changeset patch # User Jeff Sipek # Date 1120712901 14400 # Node ID 0e3a5cc5ce23d0e5c663a8825635f7fb285869f0 # Parent 1a8d3bc2974967f58082a64cd0d9d1f8bc82c7b7 Make single player selection start up a new single user game committer: Jeff Sipek 1120698501 -0400 diff -r 1a8d3bc29749 -r 0e3a5cc5ce23 atc.py --- a/atc.py Thu Jul 07 01:07:12 2005 -0400 +++ b/atc.py Thu Jul 07 01:08:21 2005 -0400 @@ -9,6 +9,8 @@ import atc_utils import atc_plane import atc_message + + import atc_single except ImportError, err: print "Couldn't load module %s" % (err) sys.exit() @@ -25,9 +27,7 @@ # background music pygame.mixer.init() - #pygame.mixer.music.load('data/sound/music.mp3') - #pygame.mixer.music.set_volume(0.1) - #pygame.mixer.music.play() + #atc_utils.playmusic("some.mp3"); # Set background background = pygame.Surface(screen.get_size()).convert() @@ -65,8 +65,9 @@ pygame.display.flip() if (optsel & 0x10): + optsel = optsel & 3 if (optsel == 0): # single player - pass + atc_single.single(screen) if (optsel == 1): # multi player pass diff -r 1a8d3bc29749 -r 0e3a5cc5ce23 atc_single.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atc_single.py Thu Jul 07 01:08:21 2005 -0400 @@ -0,0 +1,75 @@ +#!/usr/bin/python + +import pygame +import sys + +import atc_colors +import atc_utils +import atc_plane +import atc_message + +def single(screen): + """ Main fn to run the single player game """ + + # background music + #atc_utils.playmusic("some.mp3"); + + # Set background + background = pygame.Surface(screen.get_size()).convert() + background.fill(atc_colors.black) + + (back_image, back_rect) = atc_utils.load_png('data/image/background.png') + background.blit(back_image, (0, 0)) + + # Some text +# font = pygame.font.Font(None, 36) +# text = font.render("Air Traffic Controller", 1, atc_colors.red) +# textpos = text.get_rect() +# textpos.centerx = background.get_rect().centerx +# background.blit(text, textpos) + + #blit! + screen.blit(background, (0, 0)) + pygame.display.flip() + + planes = [atc_plane.Plane(callsign="N12422",vel=(atc_plane.m2pix(50), atc_plane.m2pix(50), atc_plane.m2pix(10))),] + + mess = atc_message.Message() + + cmd = "" + + while 1: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + mess.pickup_kill = 1 + sys.exit() + if event.type == pygame.KEYDOWN: + # commands + if event.key == pygame.K_q: + mess.pickup_kill = 1 + return + if event.key == pygame.K_a: + cmd += 'A' + if event.key == pygame.K_ESCAPE: + cmd = "" + if event.key == pygame.K_BACKSPACE: + cmd = cmd[:-1] + + screen.blit(background, (0, 0)) + + for plane in planes: + plane.display(screen) + plane.update() + if (plane.status == atc_plane.plane_CRASHED): + mess.write(screen,plane.callsign + ": PLANE CRASHED") + plane.status = atc_plane.plane_DEAD + + if (cmd): + font = pygame.font.Font(None, 18) + text = font.render(cmd, 1, atc_colors.white) + screen.blit(text, (25, 567)) + + pygame.display.flip() + +if (__name__ == '__main__'): + print "Don't do it!" diff -r 1a8d3bc29749 -r 0e3a5cc5ce23 atc_utils.py --- a/atc_utils.py Thu Jul 07 01:07:12 2005 -0400 +++ b/atc_utils.py Thu Jul 07 01:08:21 2005 -0400 @@ -19,3 +19,9 @@ def todeg(rad): """ Convert radians to degrees """ return rad*180.0/pi + +def playmusic(name,vol=0.1): + """ Start playing background music """ + pygame.mixer.music.load('data/sound/' + name) + pygame.mixer.music.set_volume(vol) + pygame.mixer.music.play()