Mercurial > atc
view atc_single.py @ 6:f346ce878117 v0.10-pre1
GPL License
GPL headers
committer: Jeff Sipek <jeffpc@jeff.(none)> 1120698533 -0400
author | Jeff Sipek <jeffpc@jeff.(none)> |
---|---|
date | Thu, 07 Jul 2005 01:08:53 -0400 |
parents | 0e3a5cc5ce23 |
children | 8a4a829f1cc0 |
line wrap: on
line source
#/* # * ATC - Air Traffic Controller simulation game # * # * Copyright (C) 2004 Josef "Jeff" Sipek <jeffpc@optonline.net> # * # * This program is free software; you can redistribute it and/or modify # * it under the terms of the GNU General Public License as published by # * the Free Software Foundation; either version 2 of the License, or # * (at your option) any later version. # * # * This program is distributed in the hope that it will be useful, # * but WITHOUT ANY WARRANTY; without even the implied warranty of # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # * GNU General Public License for more details. # * # * You should have received a copy of the GNU General Public License # * along with this program; if not, write to the Free Software # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # * # * @(#) %M% %I% %E% %U% # */ 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!"