def draw(self): for thing in self.background_things: thing.draw() #if self.background: # ika.Video.Blit(self.background, 0, 0) for i in range(ika.Map.layercount): ika.Map.Render(i) for ent in self.entities: if ent.layer == i and ent.visible: ent.draw() #inefficient as it loops through each entity multiple times depending on # of layers, but works for now... #if performance becomes an issue will refactor to multiple lists per layer. for eff in self.effects: if eff.layer == i and eff.visible: eff.draw() #for special effects, may behave differntly for entities so putting them here instead. #video.clear(ika.RGB(0, 255, 0)) #ika.Map.Render() for thing in self.foreground_things: try: thing.draw() except AttributeError: # This is retarded. pass if self.lights: #lightmap check #self.lightcanvas.Clear() p=self.player x=int(p.x + p.width/2 - ika.Map.xwin)# - 320 y=int(p.y + p.height/2 - ika.Map.ywin)# - 240 #print >> fonts.tiny(0,80), 'x: '+str(x) #print >> fonts.tiny(0,90), 'y: '+str(y) #self.bigcircle.Blit(self.lightcanvas, 0, 0, ika.AddBlend) #self.smallcircle.Blit(self.lightcanvas, x-10, y-80, ika.AddBlend) #if controls.confirm.Pressed(): # self.lightcanvas.Save("test.png") #self.lightcanvas.Blit(self.image, x , y, ika.RGB(255, 255, 255, self.opacity), ika.SubtractBlend) #img=ika.Image(self.lightcanvas) #ika.Video.DrawRect(0,0,319,219,ika.RGB(0,0,64,128), ika.SubtractBlend) #ika.Video.TintBlit(img, 0,0, ika.RGB(255,255,255,128), ika.AddBlend) #the one that always works #ika.Video.DrawEllipse(x+160, y+160, 50, 40, ika.RGB(100,100,100,128), 1, ika.AddBlend) #ika.Video.TintBlit(img, 0 , 0, ika.RGB(255, 255, 255, 128)) #ika.Video.TintBlit(img, 0 , 0) self.hud.draw() x = 10 y = 230 for m in self.messages: print >> fonts.one(x, y), m.text y -= 10
def draw_menu(self): #main menu draw #ika.Video.Blit(self.face, 11, 25) ika.Map.Render() ika.Video.Blit(self.menu1, 0, 0) ika.Video.Blit(self.menu3, 0, 190) ika.Video.Blit(self.menu4, 100, 190) if self.menuselected == 0: #map ika.Video.Blit(self.mapw, 0, 22) print >> fonts.two(160, 30, align='center'), self.mapname engine.automap.draw_automap(self.mapx, self.mapy) else: ika.Video.Blit(self.menu2, 0, 22) if self.menuselected == 3: #control config self.draw_options() if self.menuselected == 4: #quit print >> fonts.one(50, 100), "Press "+controls.confirm.buttons['key'].value+" to quit the game." x = 10 y = 10 for i, option in enumerate(self.options): #if option in self.enabled: # if i == self.menuselected: # f = fonts.three # else: f = fonts.two #else: # f = fonts.five f = [fonts.five, fonts.two][option in self.enabled] f = [f, fonts.three][i == self.menuselected] print >> f(x, y), option x += (len(option) + 1) * 10 print >> fonts.one(10, 200), 'HEALTH' print >> fonts.tiny(40, 208), '%i/%i' % (engine.player.hp, engine.player.maxhp) print >> fonts.one(10, 216), 'ENERGY' print >> fonts.tiny(40, 224), '%i/%i' % (engine.player.mp, engine.player.maxmp) print >> fonts.one(105, 200), 'TIME:', engine.time
def SavePrompt(self, heal=True): if heal: self.player.dhp = self.player.maxhp self.player.dmp = self.player.maxmp selected = 0 while not controls.confirm.Pressed(): self.player.update() self.draw() Window(150, 0).draw(52, 60) print >> fonts.one(68, 80), 'Do you want to save?' x = 100 y = 98 for i, option in enumerate(['Yes', 'No']): f = [fonts.five, fonts.three][i == selected] print >> f(x, y), option x += 100 self.hud.draw() #ika.Video.DrawRect(80 + 110 * selected, 92, 120 + 110 * selected, # 108, ika.RGB(128, 192, 128)) ika.Video.ShowPage() ika.Input.Update() if controls.left.Pressed(): sound.play('Menu') selected -= 1 if selected < 0: selected = 1 if controls.right.Pressed(): sound.play('Menu') selected += 1 if selected > 1: selected = 0 #for c in controls.control_list: # c.Release() if selected == 0: self.Save() return True return False
def Run(self): self.title.show() self.newgame() #only comment out if not showing title self.hud.resize() self.automap.update_room() time = ika.GetTime() done = False self.music = ika.Music('%s/00_-_zaril_-_close_to_the_core.xm' % config.music_path) self.music.loop = True self.music.Play() while not done: t = ika.GetTime() while t > time: # Uncomment for slow motion. #ika.Delay(2) self.tick() time += 1 time = ika.GetTime() self.update_time() self.camera.update() self.draw() print >> fonts.one(0, 40), 'FPS:', ika.GetFrameRate() #for i, e in enumerate(self.entities): # print >> fonts.one(0, 50 + 10*i), 'sprite', e.sprite ika.Input.Update() if controls.pause.Pressed(): self.pause.menu() ika.Input.Unpress() # Make sure the engine doesn't have to play 'catchup'. time = ika.GetTime() #screenshot key if False: #controls.confirm.Pressed(): #screenshot #self.text('This is a textbox.') ika.Input.Unpress() time = ika.GetTime() c = ika.Video.GrabCanvas(0, 0, ika.Video.xres, ika.Video.yres) c2 = ika.Image(c) c2.Blit(0, 0) c.Save('blah1.png') ika.Video.ShowPage()
def draw_options(self, selected=-1): print >> fonts.three(70, 34), 'CONTROL CONFIGURATION' print >> fonts.three(30, 47), 'ACTION' print >> fonts.three(132, 47), 'KEY' f = [fonts.five, fonts.three][controls.usejoystick] print >> f(196, 47), 'GAMEPAD' # x-pos of key name, x-pos of key, y-pos of first, y-inc, space # between first and '-' x1, x2, x3, y, h, optlen = 20, 140, 220, 60, 12, 11 for i, option in enumerate(self.configkeys): print >> fonts.one(x1, y + i * h), '%s' % option.ljust(optlen) f = [fonts.one, fonts.three][selected == i] #select the item that's been highlighted print >> f(x2, y + i * h), controls.control_list[option].buttons['key'].value if controls.usejoystick: print >> f(x3, y + i * h), controls.control_list[option].buttons['joy'].value
def text(self, txt): #ooold code... done = 0 state = 0 h = 0 arrow = ika.Image('%s/arrow.png' % config.image_path) lines = wrap(txt, 360, fonts.big) scrolling = 1 scroll = [0] * len(lines) current = 0 offset = 0 t = ika.GetTime() while not done: #ika.Map.Render() self.draw() while t == ika.GetTime(): pass for i in range(ika.GetTime() - t): for entity in self.entities: entity.update() if state == 0: h += 2 if state == 1 and scrolling == 1: scroll[current + offset] += 1 if state == 2: h -= 2 t = ika.GetTime() if state == 0: if h >= 40: h = 40 state = 1 self.window.resize(h * 8, h) else: self.window.resize(h * 8, h) self.window.draw(168 - h * 4, 200 - h / 2) if state == 1: self.window.draw(8, 180) for i in range(len(lines[offset:])): print >> fonts.big(20, 190 + 12 * i), lines[i + offset][:scroll[i + offset]] if scroll[current + offset] >= \ len(lines[current + offset]): if current + offset < len(lines) - 1: current += 1 else: scrolling = 0 if current == 7: scrolling = 0 # Put blinking arrow or whatever here. if ika.GetTime() % 50 < 40: ika.Video.Blit(arrow, 192, 280 + ika.GetTime() % 50 / 10) if state == 2: if h <= 0: done = True else: self.window.resize(h * 8, h) self.window.draw(168 - h * 4, 200 - h / 2) print >> fonts.one(0, 0), 'lines:', '%s' ika.Video.ShowPage() ika.Input.Update() if ika.Input.keyboard['RETURN'].Pressed() and state == 1 and \ scrolling == 0: ika.Input.Unpress() if current + offset < len(lines) - 1: scrolling = 1 offset += 7 current = 0 else: state = 2