changeset 24:aa7332d16d82

Added loading of maps at start up/Multimap support Added maps directory config option committer: Jeff <jeffpc@batlh.(none)> 1121710237 -0400
author Jeff <jeffpc@batlh.(none)>
date Mon, 18 Jul 2005 18:10:37 -0400
parents b2ed1770081f
children dde511571317
files TODO atc_config.py atc_maps.py atc_plane.py atc_single.py data/image/background.png data/image/background.xcf maps/default/map.info maps/default/map.png maps/default/map.xcf maps/default/navaid.info
diffstat 11 files changed, 113 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Mon Jul 18 17:23:35 2005 -0400
+++ b/TODO	Mon Jul 18 18:10:37 2005 -0400
@@ -7,3 +7,4 @@
 * Implement communication breakdown
 * Implement emergency situations
 * Implement nav beacons
+* Fix no available sound device error
--- a/atc_config.py	Mon Jul 18 17:23:35 2005 -0400
+++ b/atc_config.py	Mon Jul 18 18:10:37 2005 -0400
@@ -8,3 +8,6 @@
 
 # relative location of the plane specs directory
 plane_spec_dir	= "planes"
+
+# relative location of the maps directory
+maps_dir	= "maps"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/atc_maps.py	Mon Jul 18 18:10:37 2005 -0400
@@ -0,0 +1,97 @@
+#/*
+# * ATC - Air Traffic Controller simulation game
+# *
+# * Copyright (C) 2005 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 os
+import sys
+import atc_config
+
+def get_map_info(file):
+	fd = open(file, 'r')
+	s = fd.read()
+	fd.close()
+	
+	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
+
+def get_navaids(file, m):
+	fd = open(file, 'r')
+	s = fd.read()
+	fd.close()
+	
+	s = s.split("\n")
+	
+	NAVS = []
+	
+	for line in s:
+		if (line.__len__() == 0):
+			continue
+		
+		line = line.split(" ")
+		
+		nav = {	"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
+
+MAPS	= []
+
+maps_dir = os.listdir(atc_config.maps_dir)
+
+for map_dir in maps_dir:
+	files = os.listdir(atc_config.maps_dir + "/" + map_dir)
+	
+	if (files.count("map.info") == 0):
+		print "Missing " + atc_config.maps_dir + "/" + map_dir + "/map.info"
+		sys.exit(1)
+	
+	if (files.count("map.png") == 0):
+		print "Missing " + atc_config.maps_dir + "/" + map_dir + "/map.png"
+		sys.exit(1)
+	
+	if (files.count("navaid.info") == 0):
+		print "Missing " + atc_config.maps_dir + "/" + map_dir + "/navaid.info"
+		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)
+	
+	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 "Added " + str(MAPS.__len__()) + " maps"
--- a/atc_plane.py	Mon Jul 18 17:23:35 2005 -0400
+++ b/atc_plane.py	Mon Jul 18 18:10:37 2005 -0400
@@ -31,8 +31,9 @@
 import atc_colors
 import atc_utils
 from atc_plane_specs import *
+from atc_maps import *
 
-mperpix		= 30000.0/800.0		# 800 px == 30 km
+mperpix		= MAPS[0]["mperpix"]
 mperdeg		= 1852.0*60.0		# == 1852 m/min * 60 min/deg
 
 def m2pix(m):
--- a/atc_single.py	Mon Jul 18 17:23:35 2005 -0400
+++ b/atc_single.py	Mon Jul 18 18:10:37 2005 -0400
@@ -28,6 +28,8 @@
 import atc_plane
 import atc_message
 
+from atc_maps import *
+
 def single(screen):
 	""" Main fn to run the single player game """
 	
@@ -38,7 +40,7 @@
 	background = pygame.Surface(screen.get_size()).convert()
 	background.fill(atc_colors.black)
 	
-	(back_image, back_rect) = atc_utils.load_png('data/image/background.png')
+	(back_image, back_rect) = atc_utils.load_png(MAPS[0]["image"])
 	background.blit(back_image, (0, 0))
 
 	# Some text
Binary file data/image/background.png has changed
Binary file data/image/background.xcf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/maps/default/map.info	Mon Jul 18 18:10:37 2005 -0400
@@ -0,0 +1,5 @@
+0
+0
+37.5
+512
+384
Binary file maps/default/map.png has changed
Binary file maps/default/map.xcf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/maps/default/navaid.info	Mon Jul 18 18:10:37 2005 -0400
@@ -0,0 +1,2 @@
+200 200 112.825 N1 VOR 7500
+400 400 112.225 N2 VOR 7500