Mercurial > rinkhals
view gamelib/misc.py @ 113:55105d3bdab1
Renamed fire-rifle to fire-machinegun, and added a single-shot rifle
Adjusted convert_audio so you can specify a converter, namely oggenc, as nothing else seems to handle fire-rifle.wav
author | David Fraser <davidf@sjsoft.com> |
---|---|
date | Wed, 02 Sep 2009 19:13:54 +0000 |
parents | 672cc5598e77 |
children | 1a7000c8211c |
line wrap: on
line source
# Holder for misc useful classes class Position(object): """2D position / vector""" def __init__(self, x, y): self.x = x self.y = y def to_tuple(self): return self.x, self.y def dist(self, b): """Gives the distance to another position""" return max(abs(self.x - b.x), abs(self.y - b.y)) def __sub__(self, b): return Position(self.x - b.x, self.y - b.y) def __add__(self, b): return Position(self.x + b.x, self.y + b.y) def left_of(self, b): return self.x < b.x def right_of(self, b): return self.x > b.x def __eq__(self, b): return self.x == b.x and self.y == b.y