def __init__(self, filename, framesperdir, initpos=[0, 0], initdir=None, speed=None, stats=None, id=None, width=32, height=64): self._images = [] self._start = pygame.time.get_ticks() self._delay = 250 self._last_update = 0 self.pos = initpos self.speed = speed self.moving = False self.direction = initdir self.framesperdir = framesperdir self.animoffset = initdir self.frame = 0 self._lastPos = initpos self._lastFacing = initdir self.stats = stats self.id = id self.width = width self.height = height self.colrect = pygame.Rect(initpos[0] + 2, initpos[1] + 36, 30, 28) # fullrect is for checking full body collision to geometry system self.fullrect = pygame.Rect(initpos[0], initpos[1], 32, 64) self.exploding_image = pygame.image.load("guts.png").convert() self.exploding_image.set_colorkey((0, 0, 0)) self.exploding = False self.exploding_seq = range(1, 640, 4) self.exploding_iterator = -1 self.exploded = False self.damage_iterator = 0 self.damage_threshhold = 30 self.hp_meter = meter(0, self.stats.hp, self.stats.hp, 1, width=30, height=4, x=initpos[0], y=initpos[1]) #Based on 32x64 sprites self.rect = (initpos[0], initpos[1], 32, 64) image = pygame.image.load(filename).convert() for j in range(0, (image.get_height() / 64)): for i in range(0, (image.get_width() / 32)): self._images.append( image.subsurface(Rect((i * 32, j * 32, 32, 64))).convert()) self._images[len(self._images) - 1].set_colorkey((0, 0, 0))
def __init__(self, filename, framesperdir, initpos = [0,0], initdir = None, speed = None, stats = None, id = None, width = 32, height = 64): self._images = [] self._start = pygame.time.get_ticks() self._delay = 250 self._last_update = 0 self.pos = initpos self.speed = speed self.moving = False self.direction = initdir self.framesperdir = framesperdir self.animoffset = initdir self.frame = 0 self._lastPos = initpos self._lastFacing = initdir self.stats = stats self.id = id self.width = width self.height = height self.colrect = pygame.Rect(initpos[0]+2, initpos[1]+36, 30,28) # fullrect is for checking full body collision to geometry system self.fullrect = pygame.Rect(initpos[0], initpos[1], 32, 64) self.exploding_image = pygame.image.load("guts.png").convert() self.exploding_image.set_colorkey((0, 0, 0)) self.exploding = False self.exploding_seq = range(1, 640, 4) self.exploding_iterator = -1 self.exploded = False self.damage_iterator = 0 self.damage_threshhold = 30 self.hp_meter = meter(0, self.stats.hp, self.stats.hp, 1, width = 30, height = 4, x = initpos[0], y = initpos[1]) #Based on 32x64 sprites self.rect = (initpos[0], initpos[1], 32,64) image = pygame.image.load(filename).convert() for j in range(0, (image.get_height()/64)): for i in range(0, (image.get_width()/32)): self._images.append(image.subsurface(Rect((i*32, j*32, 32, 64))).convert()) self._images[len(self._images) - 1].set_colorkey((0, 0, 0))
0] + " mapwidth mapheight maplayers tilesetfile mapname mapscript\n\n the above is to create a new map.\n\nTo load a map: " + sys.argv[ 0] + " mapfilename\n" sys.exit() currentLayer = 0 showDetails = True showScriptTiles = False offs_x, offs_y = (0, 0) currentScript = 0 scriptTiles = [] eventDelay = 750 timeTicks = 0 lastScriptEventTime = 0 map_renderer = MapRenderer(ourMap) map_renderer.prepare_layers() action_meter = meter(0, 300, 300, 1, True, color=(255, 0, 255)) geom_system = geom_draw_system() # code for testing animated line geometry #testLine = animated_line([(480, 32), (480, 32), (480, 32), (480, 32)], [(360, 64), (400, 98), (440, 128), (480, 164)], (255, 0, 0), 2, 10, anim_looping = True) for k in range(ourScript.header[0]): if k != 0: currTile = Surface((32, 32)).convert() currTile.fill((0, 255, 255)) currTile.set_alpha(75) gui.draw_text_block(1, 1, currTile, str(k + 1)) print ourScript.defs[k][1] scriptTiles.append(currTile) # just testing pathfinding with A* ourEntities._list[0].calculate_astar_path(astar.script_to_grid(ourScript))
elif(len(sys.argv)<7): print "\nUsage: " + sys.argv[0] + " mapwidth mapheight maplayers tilesetfile mapname mapscript\n\n the above is to create a new map.\n\nTo load a map: " + sys.argv[0] + " mapfilename\n" sys.exit() currentLayer = 0 showDetails = True showScriptTiles = False offs_x, offs_y = (0, 0) currentScript = 0 scriptTiles = [] eventDelay = 750 timeTicks = 0 lastScriptEventTime = 0 map_renderer = MapRenderer(ourMap) map_renderer.prepare_layers() action_meter = meter(0, 300, 300, 1, True, color = (255, 0, 255)) geom_system = geom_draw_system() # code for testing animated line geometry #testLine = animated_line([(480, 32), (480, 32), (480, 32), (480, 32)], [(360, 64), (400, 98), (440, 128), (480, 164)], (255, 0, 0), 2, 10, anim_looping = True) for k in range(ourScript.header[0]): if k != 0: currTile = Surface((32, 32)).convert() currTile.fill((0, 255, 255)) currTile.set_alpha(75) gui.draw_text_block(1, 1, currTile, str(k+1)) print ourScript.defs[k][1] scriptTiles.append(currTile) # just testing pathfinding with A*