def save_surf(self, surf): image_name = ''.join([ self.klass, str(self.gender), '_', self.name, '_', self.pose, '_', str(self.counter), '.png' ]) Engine.save_surface(surf, image_name) self.counter += 1 return image_name
def run(gameStateObj, metaDataObj): gameStateObj.message.append(Dialogue.Dialogue_Scene('Data/fight_quote_info.txt', event_flag=False, if_flag=True)) gameStateObj.stateMachine.changeState('dialogue') counter = 0 while gameStateObj.message: Engine.update_time() counter += 1 if not counter%50: pyautogui.press('x') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update()
def __init__(self, klass, gender, name, item): self.unit = None # Dummy unit object since we probably don't need it if item and item.TYPE: magic = any([t in item.TYPE for t in ('Anima', 'Dark', 'Light')]) else: magic = False anim = GC.ANIMDICT.partake(klass, gender, item, magic) if anim: # Build animation script = anim['script'] frame_dir = anim['images'][name] anim = BattleAnimation.BattleAnimation(self.unit, frame_dir, script, name, item) anim.awake(owner=self, parent=None, partner=None, right=True, at_range=False) # Stand self.anim = anim self.anim_offset = 120 # For darken backgrounds and drawing self.darken_background = 0 self.target_dark = 0 self.darken_ui_background = 0 self.foreground = MenuFunctions.Foreground() self.combat_surf = Engine.create_surface((GC.WINWIDTH, GC.WINHEIGHT), transparent=True) self.counter = 1 self.timer = 0 self.klass, self.gender, self.name, self.item = klass, gender, name, item self.pose = 'Stand' self.outcom = 0 self.def_damag = 0
def run(gameStateObj, metaDataObj, fp): if os.path.exists(fp): print(fp) gameStateObj.message.append(Dialogue.Dialogue_Scene(fp, unit=gameStateObj.allunits[0], if_flag=True)) gameStateObj.stateMachine.changeState('dialogue') counter = 0 while gameStateObj.message: Engine.update_time() counter += 1 if not counter%50: pyautogui.press('x') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update()
def run(gameStateObj, metaDataObj): my_list = gameStateObj.stateMachine.state[-5:] while True: if cf.OPTIONS['debug']: my_new_list = gameStateObj.stateMachine.state[-5:] if my_new_list != my_list: logger.debug('Current states %s', [state.name for state in gameStateObj.stateMachine.state]) my_list = my_new_list # logger.debug('Active Menu %s', gameStateObj.activeMenu) Engine.update_time() # Get events eventList = Engine.build_event_list() # === UPDATE USER STATES === mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: # We don't need to process the eventList more than once I think mapSurf, repeat = gameStateObj.stateMachine.update([], gameStateObj, metaDataObj) # Update global sprite counters GC.PASSIVESPRITECOUNTER.update() GC.ACTIVESPRITECOUNTER.update() GC.CURSORSPRITECOUNTER.update() # Update global music thread Engine.music_thread.update(eventList) new_size = (GC.WINWIDTH * cf.OPTIONS['Screen Size'], GC.WINHEIGHT * cf.OPTIONS['Screen Size']) Engine.push_display(mapSurf, new_size, GC.DISPLAYSURF) # Keep gameloop (update, renders, etc) ticking Engine.update_display() gameStateObj.playtime += GC.FPSCLOCK.tick(GC.FPS)
def run(gameStateObj, metaDataObj, unit): print(unit.name) unit.isDying = True gameStateObj.stateMachine.changeState('dying') gameStateObj.message.append(Dialogue.Dialogue_Scene(metaDataObj['death_quotes'], unit, event_flag=False)) gameStateObj.stateMachine.changeState('dialogue') counter = 0 while gameStateObj.message: Engine.update_time() counter += 1 if not counter%50: pyautogui.press('x') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update()
def __init__(self, pos): self.x = pos[0] self.y = pos[1] rng = random.randint(0, 2) self.sprite = EditorUtilities.create_image( Engine.subsurface(GC.IMAGESDICT['Snow'], (0, rng * 8, 8, 8))) self.speed = random.choice([1.0, 1.5, 2.0, 2.5, 3.0]) self.remove_me = False self.floor = False
def run(gameStateObj, metaDataObj): while True: Engine.update_time() # Get events eventList = Engine.build_event_list() # Update global music thread Engine.music_thread.update(eventList) # === UPDATE USER STATES === mapSurf, repeat = gameStateObj.stateMachine.update( eventList, gameStateObj, metaDataObj) while repeat: # We don't need to process the eventList more than once I think mapSurf, repeat = gameStateObj.stateMachine.update([], gameStateObj, metaDataObj) # Update global sprite counters GC.PASSIVESPRITECOUNTER.update() GC.ACTIVESPRITECOUNTER.update() GC.CURSORSPRITECOUNTER.update() #new_size = (cf.OPTIONS['Screen Width'], cf.OPTIONS['Screen Height']) draw_rect = GC.TEMPCANVASRECT Engine.push_display(mapSurf, (draw_rect[2], draw_rect[3]), GC.TEMPCANVAS) GC.DISPLAYSURF.blit(GC.TEMPCANVAS, draw_rect) #Engine.push_display(mapSurf, new_size, GC.DISPLAYSURF) # Check for taking screenshot for event in eventList: if event.type == Engine.KEYDOWN and event.key == Engine.key_map[ '`']: current_time = str(datetime.now()).replace(' ', '_').replace( ':', '.') Engine.save_surface(mapSurf, "Lex_Talionis_%s.png" % current_time) # Keep gameloop (update, renders, etc) ticking Engine.update_display() gameStateObj.playtime += GC.FPSCLOCK.tick(GC.FPS)
def __init__(self, pos): self.x = pos[0] self.y = pos[1] self.full_sprite = GC.IMAGESDICT['FireParticle'] self.sprites = [ EditorUtilities.create_image( Engine.subsurface(self.full_sprite, (0, i * 2, 3, 2))) for i in range(6) ] self.speed = random.randint(1, 4) self.remove_me = False self.sprite = self.sprites[-1]
def draw(self): surf = Engine.create_surface((GC.WINWIDTH, GC.WINHEIGHT), transparent=True) Engine.fill(surf, (128, 160, 128)) if self.darken_background or self.target_dark: bg = Image_Modification.flickerImageTranslucent( GC.IMAGESDICT['BlackBackground'], 100 - abs(int(self.darken_background * 12.5))) surf.blit(bg, (0, 0)) if self.target_dark > self.darken_background: self.darken_background += 1 elif self.target_dark < self.darken_background: self.darken_background -= 1 # Make combat surf combat_surf = Engine.copy_surface(self.combat_surf) if self.darken_ui_background: self.darken_ui_background = min(self.darken_ui_background, 4) # bg = Image_Modification.flickerImageTranslucent(GC.IMAGESDICT['BlackBackground'], 100 - abs(int(self.darken_ui_background*11.5))) color = 255 - abs(self.darken_ui_background * 24) Engine.fill(combat_surf, (color, color, color), None, Engine.BLEND_RGB_MULT) # combat_surf.blit(bg, (0, 0)) self.darken_ui_background += 1 surf.blit(combat_surf, (0, 0)) self.anim.draw_under(surf, (0, 0)) self.anim.draw(surf, (0, 0)) self.anim.draw_over(surf, (0, 0)) self.foreground.draw(surf) return surf
def disp_unit(self, unit): self.current_unit = unit # Face self.smile() # Check these self.talk() unit.portrait.create_image() pixmap = create_pixmap( Engine.transform_scale(unit.portrait.image.convert_alpha(), (96 * 2, 80 * 2)), self.window) self.portrait.setPixmap(pixmap) self.portrait_pos_boxes[0].setValue(unit.portrait.blink_position[0]) self.portrait_pos_boxes[1].setValue(unit.portrait.blink_position[1]) self.portrait_pos_boxes[2].setValue(unit.portrait.mouth_position[0]) self.portrait_pos_boxes[3].setValue(unit.portrait.mouth_position[1]) # Char data self.name.setText(unit.name) # self.team.setCurrentIndex(self.teams.index(unit.team)) self.gender.setValue(unit.gender) self.level.setValue(unit.level) self.faction.setText(unit.faction) self.lord.setChecked('Lord' in unit.tags) self.boss.setChecked('Boss' in unit.tags) self.desc.setText(unit.desc) self.klass.setCurrentIndex([k['name'] for k in class_data].index(unit.klass)) for index, (stat_name, stat) in enumerate(unit.stats.iteritems()): self.stat_bases[index].setValue(stat.base_stat) self.stat_growths[index].setValue(unit.growths[index]) for index, wexp in enumerate(unit.wexp): self.wexp[index].setValue(wexp) self.clear_items() for index, item in enumerate(unit.items): self.add_item() item_box, drop_box, event_box = self.items[index] drop_box.setChecked(item.droppable) event_box.setChecked(item.event_combat) item_box.setCurrentIndex([i.name for i in item_data].index(item.name)) self.clear_skills() for index, skill in enumerate(unit.skills): self.add_skill() skill_box = self.skills[index] skill_box.setCurrentIndex([s.id for s in skill_data].index(skill.id))
class DefaultUnit(object): portrait = Engine.subsurface(GC.UNITDICT['GenericPortrait'], (0, 0, 96, 80)).convert_alpha() chibi = Engine.subsurface(GC.UNITDICT['GenericPortrait'], (96, 16, 32, 32)).convert_alpha() def __init__(self): self.id = 0 self.name = '' self.level = 1 self.gender = 0 self.faction = '' self.klass = 'Citizen' self.tags = set() self.desc = '' self.stats = SaveLoad.build_stat_dict(class_dict[self.klass]['bases']) self.growths = [0 for n in xrange(cf.CONSTANTS['num_stats'])] self.items = [] self.skills = [] self.wexp = [ 0 for n in xrange(len(CustomObjects.WEAPON_TRIANGLE.types)) ] self.team = 'player'
def tick(self): # Update global sprite counters current_time = self.elapsed_timer.elapsed() if GC.PASSIVESPRITECOUNTER.update(current_time): for index, klass in enumerate(class_data): klass['icon'] = create_icon( klass['images'][GC.PASSIVESPRITECOUNTER.count], window) self.klass.setItemIcon(index, klass['icon']) if self.current_unit: self.current_unit.portrait.update(current_time) self.current_unit.portrait.create_image() pixmap = create_pixmap( Engine.transform_scale( self.current_unit.portrait.image.convert_alpha(), (96 * 2, 80 * 2)), self.window) self.portrait.setPixmap(pixmap)
def __init__(self, info, portrait_data): self.id = info['id'] self.name = info['name'] self.level = int(info['level']) self.gender = int(info['gender']) self.faction = info['faction'] self.klass = info['klass'] self.tags = info['tags'] self.desc = info['desc'] self.stats = info['stats'] self.growths = info['growths'] self.wexp = info['wexp'] self.items = info['items'] self.skills = info['skills'] self.team = 'player' blink_pos = (0, 0) mouth_pos = (0, 0) try: # Ex: HectorPortrait if self.name in portrait_data: blink_pos = portrait_data[self.name]['blink'] mouth_pos = portrait_data[self.name]['mouth'] self.portrait = UnitPortrait(self.name, blink_pos, mouth_pos, (0, 0)) self.chibi = Engine.subsurface(GC.UNITDICT[self.name + 'Portrait'], (96, 16, 32, 32)).convert_alpha() except KeyError: self.portrait = UnitPortrait('Generic', blink_pos, mouth_pos, (0, 0)) self.chibi = GC.UNITDICT[self.faction + 'Emblem'].convert_alpha()
def __init__(self, view, window=None): super(TileInfoMenu, self).__init__(window) self.grid = QGridLayout() self.setLayout(self.grid) self.window = window self.view = view self.list = SignalList(self) self.list.setMinimumSize(128, 320) self.list.uniformItemSizes = True self.list.setIconSize(QSize(32, 32)) # Ingest Data self.info = sorted(kinds.values(), key=lambda x: x.num) for info in self.info: image = Engine.transform_scale(info.image, (32, 32)) pixmap = EditorUtilities.create_pixmap(image) item = QListWidgetItem(info.name) item.setIcon(QIcon(pixmap)) self.list.addItem(item) self.grid.addWidget(self.list, 0, 0)
def __init__(self, num, name, kind): self.num = num self.name = name self.kind = kind self.image = Engine.subsurface(GC.ICONDICT['TileInfoIcons'], (0, num * 16, 16, 16))
print('Or send the file "Saves/debug.log.1" to rainlash!') print('Thank you!') print("=== === === === === === \n") # ____________________________________________________________________________# # === START === START === START === START === START === START === START === # if __name__ == '__main__': #import logging, traceback #import trackeback #logging.logThreads = 0 #logging.logProcesses = 0 #logger = logging.getLogger(__name__) try: handle_debug_logs() except WindowsError: print( "Error! Debug logs in use -- Another instance of this is already running!" ) Engine.terminate() #if cf.OPTIONS['debug']: # my_level = logging.DEBUG #else: # my_level = logging.WARNING #logging.basicConfig(handlers=[logging.FileHandler('./Saves/debug.log.1', 'w', 'utf-8')], # level=my_level, format='%(relativeCreated)d %(levelname)7s:%(module)16s: %(message)s') print('*** Lex Talionis Engine Version %s ***' % GC.version) main() # === END === END === END === END === END === END === END === END === END === #
print('Damn. Another bug :(') print("Quick! Copy this error log and send it to rainlash!") print('Or send the file "Saves/debug.log.1" to rainlash!') print('Thank you!') print("=== === === === === === \n") # ____________________________________________________________________________# # === START === START === START === START === START === START === START === # if __name__ == '__main__': import logging, traceback logger = logging.getLogger(__name__) try: handle_debug_logs() except WindowsError: print("Error! Debug logs in use -- Another instance of this is already running!") Engine.terminate() if cf.OPTIONS['debug']: my_level = logging.DEBUG else: my_level = logging.WARNING logging.basicConfig(filename='./Saves/debug.log.1', filemode='w', level=my_level, disable_existing_loggers=False, format='%(levelname)8s:%(module)20s: %(message)s') try: main() except Exception as e: logger.exception(e) inform_error() print('Main Crash {0}'.format(str(e))) # Now print exception to screen import time
h = surface.get_height() self.data = surface.get_buffer().raw self.image = QtGui.QImage(self.data, w, h, QtGui.QImage.Format_RGB32) def paintEvent(self, event): qp = QtGui.QPainter() qp.begin(self) qp.drawImage(0, 0, self.image) qp.end() class MainWindow(QtGui.QMainWindow): def __init__(self, surface, parent=None): super(MainWindow, self).__init__(parent) self.setCentralWidget(ImageWidget(surface)) Engine.simple_init() # Display creation is necessary to use convert and convert alpha surf = Engine.build_display((240, 160)) IMAGESDICT, UNITDICT, ICONDICT, ITEMDICT, ANIMDICT = images.getImages(home='../') Engine.remove_display() surf = Engine.create_surface((640, 480)) Engine.fill(surf, (64, 128, 192, 224)) Engine.blit(surf, IMAGESDICT['Clearing'], (0, 0)) app = QtGui.QApplication(sys.argv) window = MainWindow(surf) def b1_clicked(): print("Button 1 clicked")
def create_chibi(name): return Engine.subsurface(GC.UNITDICT[name + 'Portrait'], (96, 16, 32, 32)).convert_alpha()
def create_cursor(): sprite = GC.IMAGESDICT['Cursor'] # Sprites are in 64 x 64 boxes activesprite = Engine.subsurface(sprite, (0, 64, 32, 32)).convert_alpha() return create_image(activesprite)
print('Damn. Another bug :(') print("Quick! Copy this error log and send it to rainlash!") print('Or send the file "Saves/debug.log.1" to rainlash!') print('Thank you!') print("=== === === === === === \n") # ____________________________________________________________________________# # === START === START === START === START === START === START === START === # if __name__ == '__main__': import logging, traceback logger = logging.getLogger(__name__) try: handle_debug_logs() except WindowsError: print("Error! Debug logs in use -- Another instance of this is already running!") Engine.terminate() if cf.OPTIONS['debug']: my_level = logging.DEBUG else: my_level = logging.WARNING logging.basicConfig(filename='./Saves/debug.log.1', filemode='w', level=my_level, disable_existing_loggers=False, format='%(levelname)8s:%(module)20s: %(message)s') try: main() except Exception as e: logger.exception(e) inform_error() print('Main Crash {0}'.format(str(e))) # Now print exception to screen import time
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() done = False for num in range(0, 12): if hasattr(gameStateObj, 'saving_thread'): gameStateObj.saving_thread.join() gameStateObj.save_slots = Transitions.load_saves() print('Level: %s' % num) gameStateObj.build_new() # Make the gameStateObj ready for a new game gameStateObj.set_generic_mode() gameStateObj.save_slot = 0 levelfolder = 'Assets/Lex-Talionis/Data/Level' + str(num) # Create a save for the first game gameStateObj.stateMachine.clear() gameStateObj.stateMachine.changeState('turn_change') SaveLoad.suspendGame(gameStateObj, "Start", slot=gameStateObj.save_slot) # Load the first level SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) # Set Casual Mode gameStateObj.mode['death'] = 0 # Run counter = 0 suspended_yet, dead_yet = False, False while not done: Engine.update_time() current_state = gameStateObj.stateMachine.getState() if current_state == 'free': units = [unit for unit in gameStateObj.allunits if unit.team == 'player' and not unit.dead and unit.name not in {'Sam', 'Ophie', 'Prim', 'Renae'}] if not dead_yet and units: unit = units[0] print(unit.name) unit.isDying = True gameStateObj.stateMachine.changeState('dying') gameStateObj.message.append(Dialogue.Dialogue_Scene(metaDataObj['death_quotes'], unit=unit)) gameStateObj.stateMachine.changeState('dialogue') dead_yet = True elif suspended_yet: gameStateObj.statedict['levelIsComplete'] = 'win' gameStateObj.message.append(Dialogue.Dialogue_Scene('Assets/Lex-Talionis/Data/seizeScript.txt')) gameStateObj.stateMachine.changeState('dialogue') suspended_yet = False else: SaveLoad.suspendGame(gameStateObj, 'Suspend', hard_loc='Suspend') gameStateObj.save_slots = None # Reset save slots gameStateObj.stateMachine.clear() gameStateObj.stateMachine.changeState('start_start') suspended_yet = True elif current_state == 'start_save' or current_state == 'start_start' or current_state == 'start_option': pyautogui.press('x') if current_state == 'start_save': dead_yet = False elif current_state == 'move': pyautogui.press('z') counter += 1 if not counter%20: pyautogui.press('s') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update() gameStateObj.playtime += GC.FPSCLOCK.tick(GC.FPS)