def __init__(self): #FIXME: remove these defaults self.to_remove = False self.sprite = sprite.get_sprite( FOE_BITMAP ) self.bullet_sprite = sprite.get_sprite( BULLET_BITMAP ) self.life = FOE_LIFE self.frame = 0
def __init__(self): #FIXME: remove these defaults self.to_remove = False self.sprite = sprite.get_sprite(FOE_BITMAP) self.bullet_sprite = sprite.get_sprite(BULLET_BITMAP) self.life = FOE_LIFE self.frame = 0
def create(self, ml, x, y, frame, bullet, sprite_name): foe = BulletMLFoe(BEHAV_PATH + ml) foe.x = x foe.y = y foe.sprite = sprite.get_sprite(BITMAP_PATH + sprite_name) foe.bullet_sprite = sprite.get_sprite(BITMAP_PATH + bullet) foe.frame = frame self.launch_list.append(foe)
def __init__(self, context): self._context = context self.x = 0.0 self.y = - context._field_height * .25 self.frame = 0 self.id = len(context.player_list) # Won't work when a death occurs context.update_list.append(self) context.player_list.append(self) self.to_remove = False self.speed = PLAYER_SPEED self.sprite = sprite.get_sprite(SHIP_BITMAP) i = 1 while gl.glIsList(i): i += 1 gl.glNewList(i, gl.GL_COMPILE) gl.glColor4f(1.0, 0.0, 1.0, 0.5) gl.glDisable(gl.GL_TEXTURE_2D) gl.glBegin(gl.GL_TRIANGLE_FAN) NB_STRIPS = 32 gl.glVertex2f(0., 0.) for k in xrange(NB_STRIPS+1): gl.glVertex2f(RADIUS * math.cos(2 * math.pi * k / NB_STRIPS), RADIUS * math.sin(2 * math.pi * (-k) / NB_STRIPS)) gl.glEnd() gl.glColor4f(1., 1., 1., 1.) gl.glEndList() self.circle_list = i self.t=0
def __init__(self, context): self._context = context self.x = 0.0 self.y = -context._field_height * .25 self.frame = 0 self.id = len(context.player_list) # Won't work when a death occurs context.update_list.append(self) context.player_list.append(self) self.to_remove = False self.speed = PLAYER_SPEED self.sprite = sprite.get_sprite(SHIP_BITMAP) i = 1 while gl.glIsList(i): i += 1 gl.glNewList(i, gl.GL_COMPILE) gl.glColor4f(1.0, 0.0, 1.0, 0.5) gl.glDisable(gl.GL_TEXTURE_2D) gl.glBegin(gl.GL_TRIANGLE_FAN) NB_STRIPS = 32 gl.glVertex2f(0., 0.) for k in xrange(NB_STRIPS + 1): gl.glVertex2f(RADIUS * math.cos(2 * math.pi * k / NB_STRIPS), RADIUS * math.sin(2 * math.pi * (-k) / NB_STRIPS)) gl.glEnd() gl.glColor4f(1., 1., 1., 1.) gl.glEndList() self.circle_list = i self.t = 0
def __init__(self, context): self._context = context context.update_list.append(self) self.index = len(self._context.bullet_list) context.bullet_list.append(self) self.controller = BulletMLController() self.controller.game_object = self self.wait = 0 self.sprite = sprite.get_sprite(BULLET_BITMAP)
def export_chr(chr_file, png_file, palette=palette, width=8): sprs = sprite.load_sprites(chr_file) spr_len = sprite.length(sprs) height = spr_len / width size = (width * 8, height * 8) img = Image.new('RGB', size) draw = ImageDraw.Draw(img) for s_index in range(spr_len): spr = sprite.get_sprite(s_index, sprs) dx = s_index % width dy = s_index / width for y in range(8): for x in range(8): color = spr[y][x] draw.point((x+(8*dx),y+(8*dy)), palette[color]) img.save(png_file, 'PNG')
def export_nametable(nametable_file, chr_file, png_file, palette=palette): nts = nametable.load_nametable(nametable_file) sprs = sprite.load_sprites(chr_file) nt = nametable.get_nametable(0, nts) size = (256, 256) img = Image.new('RGB', size) draw = ImageDraw.Draw(img) nt_index = 0 num_nt = nametable.length(nts) for y in range(32): for x in range(32): dx = nt_index / 32 dy = nt_index % 32 spr_index = nt[y][x] + 256 spr = sprite.get_sprite(spr_index, sprs) draw_sprite(spr, dx, dy, draw, palette) nt_index += 1 img.save(png_file, 'PNG')