Example #1
0
def intro():
    ikalogo = ika.Image('%s/ika.png' % config.IMAGE_PATH)
    gbabg = ika.Image('%s/sky_bg.png' % config.IMAGE_PATH)
    gba = ika.Image('%s/gba.png' % config.IMAGE_PATH)
    yourmom = ika.Image('%s/yourmother.png' % config.IMAGE_PATH)
    isabitch = ika.Image('%s/yourmother2.png' % config.IMAGE_PATH)
    controls.attack1()  # unpress
    controls.joy_attack1()  # unpress
    controls.ui_accept()  # unpress
    v = ika.Video
    d = 40

    def stub():
        clearScreen()

    def showGba():
        gbabg.Blit(0, 0)
        v.Blit(gba, (v.xres - gba.width) / 2, (v.yres - gba.height) / 2)
        clouds.update()
        clouds.draw()

    try:
        delay(stub, 10)
        delay(showGba, 440)
        delay(lambda: v.Blit(ikalogo, 0, 0, ika.Opaque), 440)
        delay(lambda: v.Blit(yourmom, 0, 0, ika.Opaque), 450)
        delay(lambda: v.Blit(isabitch, 0, 0, ika.Opaque), 1)
    except _DoneException:
        return
Example #2
0
def intro():
    snow = Snow(velocity=(0, 0.5))

    i = ika.Random(0, 7)
    gba = ika.Image('gfx/gba' + str(i) + '.png')
    ikalogo = ika.Image('gfx/ika.png')
    hatchlogo = ika.Image('gfx/HatchetLogo2.png')

    v = ika.Video
    d = 50

    def showGba():
        v.ClearScreen()
        v.Blit(gba, (v.xres - gba.width) / 2, (v.yres - gba.height) / 2)

    try:
        delay(lambda: v.Blit(ikalogo, 0, 0, ika.Opaque), 200, snow)
        delay(lambda: v.ClearScreen(), d, snow)
        delay(lambda: v.Blit(hatchlogo, 0, 0, ika.Opaque), 200, snow)
        delay(lambda: v.ClearScreen(), d, snow)
        delay(showGba, 200, snow)
        delay(lambda: v.ClearScreen(), d, snow)

    except _DoneException:
        return
Example #3
0
    def __init__(self, nameTemplate):
        self.iTopleft, self.iTopright, self.iBottomleft, self.iBottomright = [
            ika.Image(nameTemplate % i)
            for i in ('top_left', 'top_right', 'bottom_left', 'bottom_right')
        ]
        self.iLeft, self.iRight, self.iTop, self.iBottom = [
            ika.Image(nameTemplate % i)
            for i in ('left', 'right', 'top', 'bottom')
        ]

        self.iCentre = ika.Image(nameTemplate % 'background')

        self.Blit = ika.Video.ScaleBlit
        self.border = 0
Example #4
0
def GetImage(name):

    if not name in ImageCache:

        if len(ImageCache) < MAX_IMAGES:

            ImageCache[name] = ika.Image(name)

        else:

            ImageCache.popitem()

            ImageCache[name] = ika.Image(name)

    return ImageCache[name]
Example #5
0
class text:

    blackbg = ika.Image("gfx\\blackbg.png")

    def __init__(self, x, y, text):

        self.x = x
        self.y = y
        self.fh = engine.font.height

        self.alive = True

        self.text = text

        while self.alive == True:
            self.Update()
            self.Render()
            ika.Input.Update()
            ika.Video.ShowPage()

    def Update(self):
        if ika.Input.enter.Pressed():
            self.alive = False

    def Render(self):
        ika.Video.Blit(self.blackbg, 0, 0)
        for a, b in enumerate(self.text):
            engine.font.Print(self.x, self.y + a * self.fh, b)
Example #6
0
def LoadFrames(x, y, img, width, height, span, xdist, ydist, numtiles):
    """
	This is a simple function that takes any image that's formatted like a tileset and rips the tiles into a
	list which is then returned. 
	img: image to rip from
	width/height: width and height of a single tile
	span: how many tiles per row
	numtiles: number of tiles to rip
	"""
    tiles = []
    bigImage = ika.Canvas(img)
    i2 = 0
    i3 = 0

    for i in range(numtiles):
        tile = ika.Canvas(width, height)
        bigImage.Clip((x + ((i2 * width) + (i2 * xdist))),
                      (y + ((i3 * height) + (i3 * ydist))), width, height)
        #bigImage.Blit(tile, -1-((width+1)*(i%span)), -1-((height+1)*(i%span)), ika.Opaque)
        bigImage.Blit(tile, 0, 0, ika.Opaque)
        tiles.append(ika.Image(tile))

        i2 += 1
        if i2 >= span:
            i3 += 1
            i2 = 0
    #ika.Exit(str(tiles))
    return tiles
Example #7
0
    def __init__(self,
                 text,
                 x=None,
                 y=None,
                 duration=200,
                 delay=0,
                 r=255,
                 g=255,
                 b=255):
        self.r = r
        self.g = g
        self.b = b
        self.delay = delay
        font = system.engine.font
        width = font.StringWidth(text)
        height = font.height

        if x is None: self.x = (ika.Video.xres - width) / 2
        else: self.x = x

        if y is None: self.y = ika.Video.yres - height - 40
        else: self.y = y

        canv = ika.Canvas(width, height)
        canv.DrawText(font, 0, 0, text)

        self.img = ika.Image(canv)
        self.opacity = 0
        self.duration = duration
        self.update = self._update().next
Example #8
0
def LoadFrames(x,y,img, tileWidth, tileHeight, numtiles, padding = 0):    
	"""
	This is a simple function that takes any image that's formatted like a tileset and rips the tiles into a
	list which is then returned. 
	img: image to rip from
	tileWidth/tileHeight: tileWidth and tileHeight of a single tile
	span: how many tiles per row
	numtiles: number of tiles to rip
	padding: number of pixels between tiles
	"""
	tiles=[]
	bigImage = ika.Canvas(img)
	numFramesWide = int(bigImage.width /(tileWidth + padding)) 
	i2 = 0
	i3 = 0
	
	for i in range(numtiles):
		tile = ika.Canvas(tileWidth, tileHeight)
		bigImage.Clip( x+(i2*tileWidth + i2*padding), y+(i3*tileHeight+i3*padding) , tileWidth , tileHeight)
		#bigImage.Blit(tile, -1-((tileWidth+1)*(i%span)), -1-((tileHeight+1)*(i%span)), ika.Opaque)
		bigImage.Blit(tile, 0, 0, ika.Opaque)
		tiles.append(ika.Image(tile))
		
		i2+=1
		if i2 >= numFramesWide:
			i3+=1
			i2=0
	#ika.Exit(str(tiles))
	return tiles
Example #9
0
def loadMenu(fadeOut=True):
    title = gui.TextFrame(text='Load Game')
    title.Position = (12, 12)
    saves = readSaves()    
    m = SaveLoadMenu(saves, saving=False)
    if len(saves)==0:
        m.offset = 6 #hack to position cursor properly when no saves exist
    bg = ika.Image('gfx/mountains.png')
    
    def draw():
        ika.Video.TintBlit(bg, 0,0, ika.RGB(128, 128, 128, 255))
        m.draw()        
        title.draw()

    xi.effects.fadeIn(50, draw=draw)

    i = None
    while i is None:
        i = m.update()        
        draw()
        ika.Video.ShowPage()
                
    if fadeOut:
        xi.effects.fadeOut(50, draw=draw)

    draw()
    if i is Cancel or i >= len(saves):
        return None
    else:
        return saves[i]
Example #10
0
 def ss(x, y, w, h):
     '''
     Grabs a subsection of a canvas at (x,y) of size (w,h),
     creates an image from it, and returns it
     '''
     c = ika.Canvas(w, h)
     srcimage.Blit(c, -x, -y)
     return ika.Image(c)
Example #11
0
def getPortrait(name):
    if name in __portraits:
        return __portraits[name]
    else:
        fileName = 'gfx/portrait_%s.png' % name
        img = ika.Image(fileName)
        __portraits[name] = img
        return img
Example #12
0
class Car(Entity):

    img = ika.Image("car.png")

    def Update(self):
        self.y += 1
        if self.y > win_height:
            del self
Example #13
0
 def __init__(self,
              imageName,
              speed=(0.2, 0.05),
              tint=ika.RGB(255, 255, 255)):
     self.image = ika.Image(imageName)
     self.pos = [0.0, 0.0]
     self.speed = speed
     self.tint = tint
Example #14
0
class Darkglow(Thing):
    circleimage = ika.Image('gfx/circle_gradient.png')

    def draw(self):
        p = system.engine.player
        x = int(p.x + 8 - ika.Map.xwin) - 640
        y = int(p.y - ika.Map.ywin) - 480
        ika.Video.TintBlit(self.circleimage, x, y, ika.RGB(180, 210, 250, 200),
                           ika.SubtractBlend)
Example #15
0
def title():
    splash = ika.Image('splash.png')
    while not ika.Input.keyboard['RETURN'].Pressed():
        ika.Video.Blit(splash, 0, 0, False)
        ika.Video.ShowPage()
        ika.Input.Update()

    # TODO: menu
    newGame()
Example #16
0
    def __init__(self):
        manager.render.append(self.Render)
        manager.update.append(self.Update)

        self.difficulty = 0
        self.level = 0
        self.max_level = 1
        self.blackbg = ika.Image("gfx\\blackbg.png")

        self.killcount = 0
Example #17
0
    def __init__(self, x=0, y=0, width=0, height=0, **kwargs):
        Widget.__init__(self, x, y, width, height)
        assert 'img' in kwargs, 'Must specify an img argument to Picture constructor.'
        self.img = kwargs['img']
        if isinstance(self.img, str):
            self.img = ika.Image(self.img)

        self.Size = (width or self.img.width), (height or self.img.height)

        self.drawImage = Picture.drawImage
Example #18
0
    def __init__(self, font, t = '>'):
        Cursor.__init__(self)

        self.width = font.StringWidth(t)
        self.height = font.height
        self.hotspot = self.width, self.height / 2

        c = ika.Canvas(self.width, self.height)
        c.DrawText(font, 0, 0, t)
        self.img = ika.Image(c)
Example #19
0
    def __init__(self, font, t='>'):
        width = font.StringWidth(t)
        height = font.height
        hotspot = width, height / 2

        Cursor.__init__(self, width, height, hotspot)

        c = ika.Canvas(self.width, self.height)
        c.DrawText(font, 0, 0, t)
        self._img = ika.Image(c)
Example #20
0
    def __init__(self, img, hotspot=None):
        if isinstance(img, (str, ika.Canvas)):
            img = ika.Image(img)
        elif not isinstance(img, ika.Image):
            assert False, 'image argument must be an image, a canvas, or a string.'

        if hotspot is None:
            hotspot = img.width, img.height / 2

        Cursor.__init__(self, img.width, img.height, hotspot)

        self._img = img
Example #21
0
    def __init__(self, x, y, layer, direction):
        super(_GrappleEntity,
              self).__init__(ika.Entity(x, y, layer, self.SPRITE), self.ANIM)

        self.ent.entobs = False
        self.ent.isobs = False

        self.ent.renderscript = self.__render

        self.direction = direction
        self.image = ika.Image(self.IMAGE)
        self.speed = 250
Example #22
0
    def createFromImageStrip(canvas, numFrames, delay = 10, hotspot = None):
        assert canvas.height % numFrames == 0, \
            "Image's height is not an even multiple of the number of frames."

        frames = [None] * numFrames
        # cut up the canvas, and create our images
        for i in range(numFrames):
            c = ika.Canvas(self.width, self.height)
            canvas.Blit(c, 0, -(i * self.height), ika.Opaque)
            frames[i] = ika.Image(c)

        return AnimatedCursor(frames, delay, hotspot)
Example #23
0
class game:
    entities = []
    frogs = []
    brownbg = ika.Image("gfx\\brownbg.png")

    def __init__(self):
        manager.render.append(self.Render)
        manager.update.append(self.Update)

    def Update(self):
        pos = 0
        specialfrogs = 0
        for x in self.entities:
            x.Update()
            if x.dead == True:
                del self.entities[pos]
            pos += 1

            if hasattr(x, 'special') and x.special == True:
                specialfrogs += 1

        if specialfrogs >= 2:
            text.text(10, 10, [
                "Well done, stalactites.  Frogs now inhabit the",
                "bottom of our cavern."
            ])
            ika.Exit()

        frogsalive = False
        for x in self.frogs:
            x.Update()
            if x.alive == True:
                frogsalive = True
        if frogsalive == False:
            text.text(10, 10,
                      ["You were unable to keep the frogs moist long enough."])
            self.reset()
            engine.startgame(0)

    def Render(self):
        ika.Video.Blit(self.brownbg, 0, 0)
        for x in self.entities:
            if hasattr(x, 'Render'):
                x.Render()
        for x in self.frogs:
            x.Render()

    def reset(self):
        length = len(self.entities)
        for x in self.entities:
            self.entities.pop(length - 1)
            length -= 1
Example #24
0
def AutoExec():
    engine.background = ika.Image('gfx/sky_bg.png')
    engine.bgThings.append(
        Clouds('gfx/sky_clouds.png',
               speed=(0.1, 0.025),
               tint=ika.RGB(255, 255, 255, 220)))
    engine.mapThings.append(
        ClippedClouds('stencils/green_00.ika-map.png',
                      'gfx/sky_shadows.png',
                      tint=ika.RGB(255, 5, 5, 255)))

    if 'firstconvo' in engine.saveData:
        engine.things.append(Caption("Anastasia's House", font=engine.font2))
Example #25
0
 def __init__(self, text, x=None, y=None, duration=200, font=None):
     super(Caption, self).__init__()
     if not font:
         font = engine.font
     width = font.StringWidth(text)
     height = font.height
     self.x = x or (ika.Video.xres - width) / 2
     self.y = y or ika.Video.yres - height - 30
     canvas = ika.Canvas(width, height)
     canvas.DrawText(font, 0, 0, text)
     self.img = ika.Image(canvas)
     self.opacity = 0
     self.duration = duration
     self.update = self._update().next
Example #26
0
class Stalactite:
	
	stalacimg = ika.Image("gfx\\stalactite.png")
	
	def __init__(self, x, y, name):
		
		
		
		self.x = x
		self.y = y
		
		self.name = name
		self.water = 0
		self.max_water = 32
		self.notladen = True
		self.dead = False
		
	def Render(self):
		ika.Video.Blit(self.stalacimg, self.x, self.y) #stalac
		ika.Video.DrawRect(self.x-20, self.y, self.x-10, self.y+self.water, ika.RGB(50,70,150), 1, 2) #water
		engine.font.Print(self.x+ 35, self.y + 10, self.name) #print name, too
		
	def Update(self):
		self.increasewater(1)
		if ika.Input.keyboard[self.name].Pressed():
			if self.water >= 0.5*self.max_water:
				self.dropwater()
		
	def increasewater(self, dif):
		self.water += dif
		if self.water > 32:
			self.water = 32
			if self.notladen == True:
				self.next_update = ika.GetTime()+250
				self.notladen = False
			if ika.GetTime() > self.next_update:
				self.dropwater()
				self.notladen = True
		
	def dropwater(self):
		#if self.notladen == False:
		engine.rungame.entities.append(water.Water(self.x-engine.TILE_SIZE, self.y, \
			self.water, 3*engine.TILE_SIZE)) 	#make water splash
		'''
		else:
			engine.rungame.entities.append(water.Water(self.x, self.y+engine.TILE_SIZE, \
				self.water, engine.TILE_SIZE))
		'''
		self.water = 0
		#give water to frog below
Example #27
0
    def __init__(self, *args, **kw):
        super(IconTableWindow, self).__init__(*args, **kw)

        self.items = []
        
        self.iconWidth = 16
        self.iconHeight = 16

        self.cursor = ika.Image('gfx/ui/hud_box.png')
        self.cursorPos = 0

        self.layout = self.createLayout()
        
        self.addChild(self.layout)
Example #28
0
def AutoExec():
    system.engine.mapThings.append(Snow(4000, velocity=(-1, 1.5)))

    system.engine.background = ika.Image('gfx/mountains.png')

    if 'bridge_broken' not in savedata.__dict__:
        for x in range(19, 22):
            ika.Map.SetTile(x, 28, 4, 152)
            ika.Map.SetTile(x, 29, 4, 158)
            ika.Map.SetTile(x, 30, 4, 164)
            ika.Map.entities['break_gap'].x = -100

    if 'windguard' not in savedata.__dict__ and 'nearend' in savedata.__dict__:
        system.engine.things.append(RuneListener())
Example #29
0
    def __init__(self, x, y):

        Enemy.__init__(self, x, y, 16, 1)  #self, xpos, ypos, radius, max_hp

        self.dmgdealt = 2

        self.speed = 1

        self.img_en1 = ika.Image("gfx\\en1.png")

        start = Point(self.corner.x, self.corner.y)
        end = Point(self.PLANET_CENTER_X, self.PLANET_CENTER_Y)
        self.path = line.Line(start, end)

        self.points = self.path.points_on_line(1)
        self.num_points = len(self.points)
Example #30
0
 def __init__(self, imageName, x, y, justify='bottom',
              colour=ika.RGB(255, 255, 255)):
     """imageName - name of the image series to use.
        (ie 'gfx/ui/hud_%sbar.png')
        x, y are position
        justify is either 'top' or 'bottom'
     """
     
     super(VerticalGauge, self).__init__()
     
     (self.span, self.top, self.bottom) = [
         ika.Image("gfx/ui/hud_%s%s.png" % (imageName, ['bar','top','bot'][i])) for i in range(3)
     ]
     self.x, self.y = x,y
     self.justify = justify.lower()
     self.colour = ika.GetRGB(colour)[:-1]
     self.height = None