Mercurial > atc
changeset 43:1757b7e8d09f
Create instances of all the beacons at game load, and destroy them when we
are done using the game object.
author | Josef "Jeff" Sipek <jeffpc@optonline.net> |
---|---|
date | Fri, 19 Aug 2005 21:18:14 -0500 |
parents | 05245904f997 |
children | 42c29f11e42a |
files | atc_beacon.py atc_game.py atc_maps.py |
diffstat | 3 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/atc_beacon.py Fri Aug 19 19:09:27 2005 -0500 +++ b/atc_beacon.py Fri Aug 19 21:18:14 2005 -0500 @@ -31,6 +31,7 @@ import atc_colors import atc_utils +# FIXME: power output/range? class Beacon: """ Class to manage a generic beacon """ def __init__(self, name, freq, loc):
--- a/atc_game.py Fri Aug 19 19:09:27 2005 -0500 +++ b/atc_game.py Fri Aug 19 21:18:14 2005 -0500 @@ -43,6 +43,9 @@ "menus": 0, "planes": 1} + self.map = MAPS[0] # FIXME: add param to chose map + self.map.bootstrap() + # set up the display layers as much as possible self.screen = screen self.screen_void = pygame.Surface(self.screen.get_size()).convert_alpha() @@ -60,7 +63,7 @@ self.screen_menus.fill (atc_colors.transparent) self.screen_cmd.fill (atc_colors.transparent) - (back_image, back_rect) = atc_utils.load_png(MAPS[0].image) + (back_image, back_rect) = atc_utils.load_png(self.map.image) self.screen_map.blit(back_image, (0, 0)) #blit! @@ -76,6 +79,9 @@ self.cmd = "" + def __del__(self): + self.map.cleanup() + def __proc_cmd(self): flno = cmd_plane(self.cmd) com = cmd_cmd(self.cmd)
--- a/atc_maps.py Fri Aug 19 19:09:27 2005 -0500 +++ b/atc_maps.py Fri Aug 19 21:18:14 2005 -0500 @@ -23,6 +23,7 @@ import os import sys import atc_config +import atc_beacon def get_map_info(file): fd = open(file, 'r') @@ -71,6 +72,17 @@ self.image = "" + def bootstrap(self): + for nav in self.ninfo: + if nav["type"] == "VOR": + self.navs.append(atc_beacon.VOR_Beacon(nav["name"], nav["freq"], (nav["xoff"], nav["yoff"]))) + elif nav["type"] == "ILS": + pass # FIXME: ILS beacons are little complicated + + def cleanup(self): + while self.navs.__len__(): + self.navs.pop() + MAPS = [] maps_dir = os.listdir(atc_config.maps_dir)