def FireEmblem(screen): inGame = True nbSave = 0 state = ["Title", "Scene1", 1] characters = [] while inGame: if state[0] == "Dialogue": state = DialogueScene.Dialogue(screen, state[1], state[2]) elif state[0] == "Battle": infosBattle = utils.loadBattle(state[1], nbSave) endBattle = Battle.battle(screen, infosBattle[0], infosBattle[1], infosBattle[2], infosBattle[3]) state = endBattle[0] characters = endBattle[1] if state[0] not in ["Quit", "Title"]: utils.save("auto", state[0], state[1], state[2], pygame.Surface((600, 600)), characters) elif state[0] == "Title": state = TitleScreen.TitleScreen(screen) elif state[0] == "Load": state = LoadMenu.loadMenu(screen) elif state[0] == "Save": state = SaveMenu.SaveMenu(screen, state[1], state[2], state[3], state[4], characters) elif state[0] == "Options": state = Options.Options(screen) elif state[0] == "Quit": inGame = False
def RunningTheLoop(Loop): NextLocation = False if Loop == 'Ocean': NextLocation = OceanOverworld.OceanOverworldFunc(True) return NextLocation if Loop == 'Island': NextLocation = ExploreIsland.IslandExploration(True) return NextLocation if Loop == 'Title': NextLocation = TitleScreen.TitleScreen(True) return NextLocation if Loop == 'EXIT': pygame.quit() exit()
def main(): # Array of scenes that shall be passed to the director scenes = [] # The "Director" of the game. It takes in the array of scenes and holds most of the "background" data for the game dire = Director(scenes) # The Scenes of the game. They all take the director object as an argument titlescr = TitleScreen(dire) onep = EdiblesOnePlayer(dire) twop = EdiblesTwoPlayer(dire) config = Config(dire) # Here the scenes are being appended to the end of the array scenes.append(titlescr) scenes.append(onep) scenes.append(twop) scenes.append((config)) # Changes/Sets the first scene of the game to be the Title Screen. dire.change_scene(titlescr) # Starts the game loop dire.loop()
def create_title_screen(self): title_screen = TitleScreen.TitleScreen() title_stage = Stage(self.game_engine) title_stage.add_object(title_screen) self.game_engine.add_stage(title_stage) self.game_engine.set_active_stage(title_stage)
def __init__(self): pygame.init() #start up pygame self.window = pygame.display.set_mode( (640, 790)) #set window size to 512, 512 pygame.display.set_caption("Search") #title window pygame.key.set_repeat(1, 80) import objects self.all_sprites = pygame.sprite.Group() self.all_tiles = pygame.sprite.Group() self.active_tiles = pygame.sprite.Group() self.inventoryWindow = pygame.sprite.Group( ) #create a sprite group for the inventory window self.doors = pygame.sprite.Group() self.active_doors = pygame.sprite.Group( ) #make sprite group for this room's doors that Horace can walk through self.inactive_doors = pygame.sprite.Group( ) #make sprite group for this room's doors that are closed so that they will change appearance but still be drawn (removing them #from self.active_doors won't actually cause them to disappear) self.status_bar = pygame.sprite.Group() self.entities = pygame.sprite.Group() self.props = pygame.sprite.Group() self.active_props = pygame.sprite.Group() self.active_message_boxes = pygame.sprite.Group( ) #sprite group to hold active message boxes self.active_option_boxes = pygame.sprite.Group() self.active_enemies = pygame.sprite.Group() self.title_screen = pygame.sprite.Group() self.minimap_group = pygame.sprite.Group() self.active_ground_items = pygame.sprite.Group() self.message_box_active = False #check if there are active message boxes self.active_battle = pygame.sprite.Group() self.active_enemy_status_bar = pygame.sprite.Group() #for prop in objects.cave_plants: # self.props.add(prop) self.clock = pygame.time.Clock() apple = item( self, 91, 91, "img/items/misc/apple_2.png", 'Apple', 2, 'Here is an unnecessarily long description of an apple. It is entirely to test the function of the textWrapper class', True, 'common', 1) apple2 = item(self, 64, 64, "img/items/misc/apple_2.png", 'Apple', 2, 'Another apple', True, 'common', 1) apple3 = item(self, 64, 64, "img/items/misc/apple_2.png", 'Apple', 2, 'A third apple', True, 'common', 1) broken_gauntlets_statreq = {"STR": 1, "DEX": 0, "AGL": 0, "INT": 0} broken_cuirass_statreq = {"STR": 2, "DEX": 0, "AGL": 0, "INT": 0} broken_gauntlets_elembonus = { "LIGHT": 12, "DARK": 0, "FIRE": 0, "ICE": 0 } broken_cuirass_elembonus = {"LIGHT": 2, "DARK": 3, "FIRE": 0, "ICE": 0} broken_greaves_statreq = {"STR": 0, "DEX": 0, "AGL": 0, "INT": 0} broken_greaves_elembonus = {"LIGHT": 0, "DARK": 0, "FIRE": 0, "ICE": 0} cracked_helmet_elembonus = { "LIGHT": 12, "DARK": 0, "FIRE": 0, "ICE": 0 } cracked_helmet_statreq = {"STR": 0, "DEX": 0, "AGL": 0, "INT": 0} self.broken_gauntlets = Armor(self, "Broken gauntlets", 64, 64, 2, "Plate", broken_gauntlets_elembonus, broken_gauntlets_statreq, "arms", "broken", "gauntlets", 10, "A pair of broken gauntlets") self.broken_cuirass = Armor(self, "Broken cuirass", 64, 64, 3, "Plate", broken_cuirass_elembonus, broken_cuirass_statreq, "torso", "broken", "cuirass", 6, "A broken cuirass.") self.broken_greaves = Armor(self, "Broken greaves", 64, 64, 2, "Plate", broken_greaves_elembonus, broken_greaves_statreq, "legs", "broken", "greaves", 8, "A pair of broken greaves.") self.cracked_helmet = Armor(self, "Cracked helmet", 64, 64, 3, "Plate", cracked_helmet_elembonus, cracked_helmet_statreq, "head", "broken", "helmet", 8, "A cracked helmet.") broken_sword_statreq = {"STR": 2, "DEX": 0, "AGL": 0, "INT": 0} broken_sword_elembonus = {"LIGHT": 5} self.broken_sword = Weapon( self, "Broken sword", 64, 64, "Straight sword", "right", "medium", "piercing", 8, 8, broken_sword_elembonus, broken_sword_statreq, None, None, "broken_sword", 15, "Horace's guardsman's sword. Mostly ornamental, its blade is now broken in two by falling rubble." ) inventory = [ apple, apple2, apple3, self.broken_gauntlets, self.broken_cuirass, self.broken_greaves, self.cracked_helmet, self.broken_sword ] #create very basic inventory array self.player = Player(self, 64, 64, inventory, 50, 50, 20, 20, 3, 5, 5, 3, 5, None, None, None, None, None, None) goblin_targetable_areas = [ "Target: head", "Target: arms", "Target: legs", "Target: torso" ] self.goblin = Enemy(self, self.player, 384, 384, 2, "Goblin", 20, 20, 3, None, None, None, None, "Beast", "goblin", goblin_targetable_areas) self.goblin_2 = Enemy(self, self.player, 256, 384, 2, "Goblin", 20, 20, 3, None, None, None, None, "Beast", "goblin", goblin_targetable_areas) room_1_enemies = [self.goblin, self.goblin_2] self.rightDoor = Door( self, 9, 4, "right", True, "img/tile/chasm/chasm_door_right.png", "img/tile/chasm/chasm_wall_right.png" ) #initialize doors. There will be only four doors, each representing a cardinal direction. A room can have 1-4 doors. self.leftDoor = Door(self, 0, 4, "left", True, "img/tile/chasm/chasm_door_left.png", "img/tile/chasm/chasm_wall_left.png") self.forwardDoor = Door(self, 4, 0, "forward", True, "img/tile/chasm/chasm_door_top.png", "img/tile/chasm/chasm_wall_top.png") self.backwardDoor = Door(self, 4, 9, "backward", True, "img/tile/chasm/chasm_door_bottom.png", "img/tile/chasm/chasm_wall_top.png") self.display_inventory = False #flag to check whether the inventory window is open or not self.z1r1 = Room( self, "base", [self.backwardDoor], "img/tile/chasm/chasm_01.png", "img/tile/chasm/chasm_01_full.png", objects.props_z1r1, room_1_enemies ) #initialize some basic rooms, each with a different background image to tell them apart. #enter a list of doors to represent the doors of the room. self.z2r2 = Room(self, "base", [self.backwardDoor, self.forwardDoor, self.rightDoor], "img/tile/chasm/chasm_01.png", "img/tile/chasm/chasm_01_full.png", objects.props_z1r2, []) self.z3r3 = Room(self, "base", [self.forwardDoor], "img/tile/chasm/chasm_01.png", "img/tile/chasm/chasm_01_full.png", objects.props_z1r3, []) self.z4r4 = Room(self, "base", [self.leftDoor], "img/tile/chasm/chasm_01.png", "img/tile/chasm/chasm_01_full.png", objects.props_z1r4, []) self.ZONE1 = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, self.z1r1, 0, 0, 0, 0], [0, self.z2r2, self.z4r4, 0, 0, 0], [0, self.z3r3, 0, 0, 0, 0]] self.battle = False self.titlescreen = TitleScreen(self, 0, 0) self.clock_group = pygame.sprite.Group() #create a 2D array of rooms to represent this zone. #self.currentLocation = #self.z1r1 = Room(self, "base", "door", "img/tile/chasm/chasm_01.png") #create a new Room object (see assets.py) #for x in range(0, 8): # for y in range(0, 8): # self.active_tiles.add(self.z1r1.tiles[x][y]) #fill the active_tiles sprite group with the tiles from the room object #create some random items #messages = ["Yes", "No", None, None] #dialogBox = optionBox(self, 64, 512, self.player, messages, "Will you accept the blessing?") #dialogBox.add(self.active_option_boxes) pygame.font.init() self.clock = pygame.time.Clock() self.prevKey = None self.minimap = Minimap(self, 500, 500, "minimap", self.player)
import TitleScreen as titlescreen if __name__ == "__main__": t = titlescreen.TitleScreen()