def editActor(self, path, column, new_text): """Edit the actor in the list view""" row = int(path) world = self.engine.getCurrentWorld() actor = world.findActorByName(self.view_actors.model[path][1]) world.removeActor(actor) data = self.view_actors.model[row] if column in (4, 5): data[column] = int(new_text) else: data[column] = new_text tag, name, sprite, layer, x, y = data new_actor = serge.actor.Actor(tag, name) if sprite: new_actor.setSpriteName(sprite) if layer: new_actor.setLayerName(layer) new_actor.moveTo(x, y) world.addActor(new_actor) self.view_actors.model[row] = data
def editActor(self, path, column, new_text): """Edit the actor in the list view""" row = int(path) world = self.engine.getCurrentWorld() actor = world.findActorByName(self.view_actors.model[path][1]) world.removeActor(actor) data = self.view_actors.model[row] if column in (4, 5): data[column] = int(new_text) else: data[column] = new_text tag, name, sprite, layer, x, y = data new_actor = serge.actor.Actor(tag, name) if sprite: new_actor.setSpriteName(sprite) if layer: new_actor.setLayerName(layer) new_actor.moveTo(x, y) world.addActor(new_actor) self.view_actors.model[row] = data
def updateActor(self, interval, world): """Update the actor""" # self.growth += float(interval)/self.rate if self.growth >= len(self.colours): # We have died self.log.info('Removing dead guy at %d, %d. Left is %d' % (self.x, self.y, len(world.getActors())-1)) world.removeActor(self) return # self.visual.growth = self.growth self.visual.size = self.width self.visual.x = self.x self.visual.y = self.y # #if random.random() < self.grow_prob: # self.resizeTo(self.width+1, self.height+1) if random.random() < self.spawn_prob*interval: new_x = self.x + random.randint(-self.spawn_dist, self.spawn_dist) new_y = self.y + random.randint(-self.spawn_dist, self.spawn_dist) new = self.__class__(self.colours, self.rate, self.grow_prob, self.spawn_prob, self.spawn_dist, self.blue) new.setSpatial(new_x, new_y, random.randint(1, 5), 20) new.setLayerName('base') world.addActor(new)