Classes for coords and blocks

develop
RusAnon 2010-05-03 13:49:51 +11:00
parent fcc2cbfa09
commit 2a095cdc52
1 changed files with 40 additions and 0 deletions

@ -0,0 +1,40 @@
class Point(object):
x = None
y = None
z = None
block = False
def __init__(self, x, y, z, block=False):
self.x = x
self.y = y
self.z = z
self.block = block
def get_block(self):
return Point(self.x/16, self.y/16, self.z, True)
class Block(object):
"""
16x16 tiles block
"""
api = None
tiles = None
coords = None
def __init__(self, api, coords):
"""
api is instance of API, which is used for read/write operations
coords is Point object
"""
self.api = api
if not isinstance(Point, coords):
raise Exception(u"coords parameter should be Point")
if not coords.block:
coords = coords.get_block()
self.coords = coords
def reload(self):
pass
def save(self):
pass