# HG changeset patch # User Josef "Jeff" Sipek # Date 1124496567 18000 # Node ID 05245904f9973f404e34c5bd6833599237767a51 # Parent df92ec9825a6744cc3371c6a980a628fec128a11 Slight change in map specs Map parsing is more OOP-ish diff -r df92ec9825a6 -r 05245904f997 atc_game.py --- a/atc_game.py Fri Aug 19 16:58:43 2005 -0500 +++ b/atc_game.py Fri Aug 19 19:09:27 2005 -0500 @@ -60,7 +60,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(MAPS[0].image) self.screen_map.blit(back_image, (0, 0)) #blit! diff -r df92ec9825a6 -r 05245904f997 atc_maps.py --- a/atc_maps.py Fri Aug 19 16:58:43 2005 -0500 +++ b/atc_maps.py Fri Aug 19 19:09:27 2005 -0500 @@ -31,13 +31,11 @@ s = s.split("\n") - m = { "centerx": float(s[0]), - "centery": float(s[1]), - "mperpix": float(s[2]), - "towerx": float(s[3]), - "towery": float(s[4])} - - return m + return Map( float(s[0]), # centerx + float(s[1]), # centery + float(s[2]), # mperpix + float(s[3]), # atcx + float(s[4])) # atcy def get_navaids(file, m): fd = open(file, 'r') @@ -46,26 +44,32 @@ s = s.split("\n") - NAVS = [] - for line in s: if (line.__len__() == 0): continue line = line.split(" ") - nav = { "xoff": float(line[0]), + m.ninfo.append({ + "xoff": float(line[0]), "yoff": float(line[1]), "freq": float(line[2]), "name": line[3], "type": line[4], - "output": float(line[5])} - - NAVS.append(nav) - - m["navs"] = NAVS - - return m + "output": float(line[5])}) + +class Map: + def __init__(self, centerx, centery, mperpix, atcx, atcy): + self.centerx = centerx + self.centery = centery + self.mperpix = mperpix + self.atcx = atcx + self.atcy = atcy + + self.ninfo = [] + self.navs = [] + + self.image = "" MAPS = [] @@ -87,11 +91,11 @@ sys.exit(1) map_info = get_map_info(atc_config.maps_dir + "/" + map_dir + "/map.info") - map_info = get_navaids(atc_config.maps_dir + "/" + map_dir + "/navaid.info", map_info) + get_navaids(atc_config.maps_dir + "/" + map_dir + "/navaid.info", map_info) - map_info["image"] = atc_config.maps_dir + "/" + map_dir + "/map.png" + map_info.image = atc_config.maps_dir + "/" + map_dir + "/map.png" MAPS.append(map_info) - print "Parsed and added '" + map_dir + "' map (" + str(map_info["navs"].__len__()) + " navaids)" + print "Parsed and added '" + map_dir + "' map (" + str(map_info.ninfo.__len__()) + " navaids)" print "Added " + str(MAPS.__len__()) + " maps" diff -r df92ec9825a6 -r 05245904f997 atc_plane.py --- a/atc_plane.py Fri Aug 19 16:58:43 2005 -0500 +++ b/atc_plane.py Fri Aug 19 19:09:27 2005 -0500 @@ -33,7 +33,7 @@ from atc_plane_specs import * from atc_maps import * -mperpix = MAPS[0]["mperpix"] +mperpix = MAPS[0].mperpix mperdeg = 1852.0*60.0 # == 1852 m/min * 60 min/deg def m2pix(m): diff -r df92ec9825a6 -r 05245904f997 docs/Maps.txt --- a/docs/Maps.txt Fri Aug 19 16:58:43 2005 -0500 +++ b/docs/Maps.txt Fri Aug 19 19:09:27 2005 -0500 @@ -39,8 +39,10 @@ center of the image is (0,0), but to allow different geographic locations this number is simply added whenever we want to display the true latitude * number (decimal) of meters per pixel -* tower offset from the left edge of the background image (pixels) -* tower offset from the top edge of the background image (pixels) +* ATC offset from the center of the background image, left is negative, right + is positive (pixels) +* ATC offset from the center of the background image, down is negative, up is + positive (pixels) map.png: ======== @@ -53,8 +55,8 @@ Contains an unlimited number of navigation aiding beacons. Each beacon takes up one line (separated by "\n"). Each line can be split by spaces into six parts: -* beacon offset from the left edge (pixels) -* beacon offset from the top edge (pixels) +* beacon offset from the center, left is negative, right is positive (pixels) +* beacon offset from the center, down is negative, up is positive (pixels) * beacon frequency (MHz) * beacon name (string) * beacon range (meters) diff -r df92ec9825a6 -r 05245904f997 maps/default/map.info --- a/maps/default/map.info Fri Aug 19 16:58:43 2005 -0500 +++ b/maps/default/map.info Fri Aug 19 19:09:27 2005 -0500 @@ -1,5 +1,5 @@ 0 0 37.5 -512 -384 +323 +324 diff -r df92ec9825a6 -r 05245904f997 maps/default/navaid.info --- a/maps/default/navaid.info Fri Aug 19 16:58:43 2005 -0500 +++ b/maps/default/navaid.info Fri Aug 19 19:09:27 2005 -0500 @@ -1,2 +1,2 @@ -200 200 112.825 N1 VOR 7500 -400 400 112.225 N2 VOR 7500 +100 100 112.825 N1 VOR 7500 +-50 200 112.225 N2 VOR 7500