Mercurial > atc
view atc_utils.py @ 18:aa0391c55f93
TODO update
committer: Jeff Sipek <jeffpc@jeff.(none)> 1120878980 -0400
author | Jeff Sipek <jeffpc@jeff.(none)> |
---|---|
date | Sat, 09 Jul 2005 03:16:20 -0400 |
parents | d9c394a5ef77 |
children | c93c3c910c85 |
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 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()