def __init__(self, pos, rot=0, vel=(0, 0), player=False, sprite=None, size=None, expiry=-1, interact=True, health=HEALTH_PLANE, owner=None): self.age = 0 self.expiry = expiry self.health = health self.owner = owner self.pos = pos # if rotation and velocity is given, use only the magnitude of the velocity if rot: self.rot = ROT_PLANE_INT * round(rot / ROT_PLANE_INT) else: self.rot = ROT_PLANE_INT * round( vectors.anglex(vel) / ROT_PLANE_INT) self.vel = vectors.component(vectors.length(vel), self.rot) self.ctlfunc = control.ctlPlane(self) self.player = player if self.player: Entity.players.append(self) self.interact = interact #if not Texture.textures.has_key("OBJ_PLANE"): # Texture("OBJ_PLANE", IMGDIR + "OBJ_PLANE" + IMGEXT) #self.texture = Texture.textures["OBJ_PLANE"] #self.size = (40, 40)#(self.image.w, self.image.h) if not sprite: self.sprite = sprclass.plane else: self.sprite = sprite if not size: self.size = len(self.sprite[0]), len(self.sprite) else: self.size = size self.cells = [] if self.interact: cell.add(self) Entity.entities.append(self)
def __init__(self, pos, vel=None, rot=0, owner=None, sprite=None, size=None, expiry=EXPIRY_BULLET, health=100): self.age = 0 self.expiry = expiry self.health = health self.pos = pos self.rot = rot self.player = False self.interact = True if not vel: if owner: self.vel = vector.component(SPD_BULLET, owner.rot) else: self.vel = (SPD_BULLET, 0) else: self.vel = vel self.owner = owner self.ctlfunc = control.Control(self) #if not Image.images.has_key("OBJ_BULLET"): # Image("OBJ_BULLET", IMGDIR + "OBJ_BULLET" + IMGEXT) #self.image = Image.images["OBJ_BULLET"] #self.size = (self.image.w, self.image.h) if not sprite: self.sprite = sprclass.bullet else: self.sprite = sprite if not size: self.size = len(self.sprite[0]), len(self.sprite) else: self.size = size self.cells = [] cell.add(self) Entity.entities.append(self)
def __init__(self, pos = None, rot = 0, vel = (0, 0), size = None, \ ctlfunc = None, interact = True, player = False, sprite = None, colour = (255, 255, 255), health = 100, owner = None): self.age = 0 self.expiry = -1 self.health = health self.owner = owner self.pos = pos # centre of entity. if this remains None, interact should probably remain False. god help you if it doesn't self.rot = rot self.vel = vel self.sprite = sprite if not size: if sprite: self.size = len(self.sprite[0]), len(self.sprite) else: self.size = (0, 0) else: self.size = size if not ctlfunc: self.ctlfunc = control.Control(self) else: self.ctlfunc = ctlfunc # collision check flag if not self.pos: self.interact = False else: self.interact = interact self.player = player if self.player: Entity.players.append(self) self.colour = colour self.cells = [] if self.interact: cell.add(self) Entity.entities.append(self)
def __init__(self, pos, rot = 0, vel = (0, 0), player = False, sprite = None, size = None, expiry = -1, interact = True, health = HEALTH_PLANE, owner = None): self.age = 0 self.expiry = expiry self.health = health self.owner = owner self.pos = pos # if rotation and velocity is given, use only the magnitude of the velocity if rot: self.rot = ROT_PLANE_INT * round(rot / ROT_PLANE_INT) else: self.rot = ROT_PLANE_INT * round(vectors.anglex(vel) / ROT_PLANE_INT) self.vel = vectors.component(vectors.length(vel), self.rot) self.ctlfunc = control.ctlPlane(self) self.player = player if self.player: Entity.players.append(self) self.interact = interact #if not Texture.textures.has_key("OBJ_PLANE"): # Texture("OBJ_PLANE", IMGDIR + "OBJ_PLANE" + IMGEXT) #self.texture = Texture.textures["OBJ_PLANE"] #self.size = (40, 40)#(self.image.w, self.image.h) if not sprite: self.sprite = sprclass.plane else: self.sprite = sprite if not size: self.size = len(self.sprite[0]), len(self.sprite) else: self.size = size self.cells = [] if self.interact: cell.add(self) Entity.entities.append(self)
def __init__(self, pos, vel = None, rot = 0, owner = None, sprite = None, size = None, expiry = EXPIRY_BULLET, health = 100): self.age = 0 self.expiry = expiry self.health = health self.pos = pos self.rot = rot self.player = False self.interact = True if not vel: if owner: self.vel = vector.component(SPD_BULLET, owner.rot) else: self.vel = (SPD_BULLET, 0) else: self.vel = vel self.owner = owner self.ctlfunc = control.Control(self) #if not Image.images.has_key("OBJ_BULLET"): # Image("OBJ_BULLET", IMGDIR + "OBJ_BULLET" + IMGEXT) #self.image = Image.images["OBJ_BULLET"] #self.size = (self.image.w, self.image.h) if not sprite: self.sprite = sprclass.bullet else: self.sprite = sprite if not size: self.size = len(self.sprite[0]), len(self.sprite) else: self.size = size self.cells = [] cell.add(self) Entity.entities.append(self)
def _move(self, pos): self.pos = pos cell.delete(self) cell.add(self)