view atc_utils.py @ 45:c93c3c910c85

Updated headers/copyrights ATC is now licensed under GPLv2 only
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 01 Jun 2007 02:04:37 -0400
parents d9c394a5ef77
children
line wrap: on
line source

#/*
# * ATC - Air Traffic Controller simulation game
# *
# * Copyright (C) 2004-2007 Josef "Jeff" Sipek <jeffpc@josefsipek.net>
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License version 2 as
# * published by the Free Software Foundation.
# *
# * 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.
# */

import pygame
import os
from math import *

def load_png(name):
	""" Load image and return image object"""
	fullname = os.path.join('', name)
	try:
		image = pygame.image.load(fullname)
		if image.get_alpha() is None:
			image = image.convert()
		else:
			image = image.convert_alpha()
	except pygame.error, message:
        	print 'Cannot load image:', fullname
        	raise SystemExit, message
	return image, image.get_rect()

def todeg(rad):
	""" Convert radians to degrees """
	return rad*180.0/pi

def torad(deg):
	""" Convert degrees to radians """
	return deg*pi/180.0

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()