def __init__(self, options): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.menu = Menu(options) self.menu.set_pos(650, 420) self.add_to_engine()
def __init__(self, callback): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.menu = None self.callback = callback self.background = DrawableObject([pygame.image.load( MENU_PATH + "battleMenubackground.gif")], '') self.background.setPosition(0,286) self.add_to_scene([self.background])
def __init__(self, menu_options, x, y, spell_type): GameEngineElement.__init__(self, has_draw=True, has_event=True) magic_list = self.game_engine.get_object('battle').magic_list self.menu = Menu(menu_options, spell_type, magic_list, self.game_engine.get_scene()) self.menu.set_pos(x, y) self.add_to_engine()
def __init__(self, callback, background=None, width=952, height=732): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.menu = None self.callback = callback bg = pygame.image.load(background).convert() self.background = pygame.transform.scale(bg, (width, height)) self.width = width self.height = height
def __init__(self, callback): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.menu = None self.callback = callback self.background = DrawableObject( [pygame.image.load(MENU_PATH + "battleMenubackground.gif")], '') self.background.setPosition(0, 286) self.add_to_scene([self.background])
def __init__(self, game_menu, width=800, height=400): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.menu = ezmenu.EzMenu(game_menu) self.menu.center_at(width - (width/3), height/2) self.menu.help_text_at( 0, height-(height/8)) self.menu.set_font(pygame.font.SysFont("Arial", 20)) self.menu.set_highlight_color((0, 255, 0)) self.menu.set_normal_color((255, 255, 255)) self.add_to_engine()
def __init__(self, callback, background=None, width=1200, height=900): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.menu = None self.callback = callback self.background = DrawableObject([pygame.image.load(background).convert()], '') self.background.scale(width, height) self.add_to_scene([self.background]) self.width = width self.height = height
def __init__(self, callback, background=None, width=1200, height=900): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.menu = None self.callback = callback self.background = DrawableObject( [pygame.image.load(background).convert()], '') self.background.scale(width, height) self.add_to_scene([self.background]) self.width = width self.height = height
def __init__(self): GameEngineElement.__init__(self, has_draw=False, has_event=True) self.add_to_engine() game_size_ratio_x = self.game_engine.width / 1200.0 game_size_ratio_y = self.game_engine.height / 900.0 term_width_offset = game_size_ratio_x * 200 term_height = game_size_ratio_y * 200 term_height_offset = game_size_ratio_y * 700 term_width = game_size_ratio_x * 1000
def __init__(self): GameEngineElement.__init__(self, has_draw=False, has_event=True) self.add_to_engine() game_size_ratio_x = self.game_engine.width/1200.0 game_size_ratio_y = self.game_engine.height/900.0 term_width_offset = game_size_ratio_x * 200 term_height = game_size_ratio_y * 200 term_height_offset = game_size_ratio_y * 700 term_width = game_size_ratio_x * 1000
def __init__(self, callback): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.menu = None self.callback = callback self.background = DrawableObject([pygame.image.load( MENU_PATH + "battleMenubackground.gif")], '') self.font = pygame.font.SysFont("cmr10",18,False,False) self.disp = DrawableFontObject("", self.font) self.sec_disp = DrawableFontObject("", self.font) self.add_to_scene([self.background]) self.add_to_scene([self.disp]) self.add_to_scene([self.sec_disp])
def __init__(self): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.__font = self.game_engine.get_object('font') self.add_to_engine() self.game_mode = 0 self.__input_keys = [ITEMS.keys(), CURRENCY.keys(), [None]] self.__input_mode = [0, 0, 0] self.__input_string = [] for key in self.__input_keys: self.__input_string.append(['0'] * len(key))
def __init__(self): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.__font = self.game_engine.get_object('font') self.add_to_engine() self.game_mode = 2 self.__input_keys = [ITEMS.keys(), CURRENCY.keys(), [None]] self.__input_mode = [0, 0, 0] self.__input_string = [] for key in self.__input_keys: self.__input_string.append(['0'] * len(key))
def __init__(self, id): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.id = id self.rooms = {} self.__images = {} self.__load_dungeon() self.__load_images() profile = self.game_engine.get_object('profile') if profile.position == (-1, -1): x, y = self.start profile.move_to(x, y) self.doorsList = [] self.game_engine.get_scene().addObject( DrawableObject([self.__images['Room']], '')) self.doorsList.append( DrawableObject([self.__images['L']], '', True, 0, 0)) self.doorsList.append( DrawableObject([self.__images['F']], '', True, 360, 0)) self.doorsList.append( DrawableObject( [pygame.transform.flip(self.__images['L'], True, False)], '', True, 990, 0)) #for door in self.doorsList: door.makeTransparent(True) self.add_to_scene(self.doorsList) self.itemsList = [] for i in range(4): surf = pygame.Surface((10, 10)) surf.fill((0, 0, 0)) tempItem = DrawableObject([surf], "", True) self.itemsList.append(tempItem) self.itemsList[0].setPosition( self.game_engine.art_scale(270, 1200, True), self.game_engine.art_scale(330, 900, False)) self.itemsList[1].setPosition( self.game_engine.art_scale(100, 1200, True), self.game_engine.art_scale(600, 900, False)) self.itemsList[2].setPosition( self.game_engine.art_scale(1100, 1200, True), self.game_engine.art_scale(600, 900, False)) self.itemsList[3].setPosition( self.game_engine.art_scale(900, 1200, True), self.game_engine.art_scale(330, 900, False)) self.add_to_scene(self.itemsList) self.add_to_engine()
def __init__(self, callback): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.menu = None self.callback = callback self.background = DrawableObject( [pygame.image.load(MENU_PATH + "battleMenubackground.gif")], '') self.font = pygame.font.SysFont("cmr10", 18, False, False) self.disp = DrawableFontObject("", self.font) self.sec_disp = DrawableFontObject("", self.font) self.add_to_scene([self.background]) self.add_to_scene([self.disp]) self.add_to_scene([self.sec_disp])
def __init__(self, dgn): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.dgn = dgn self.current_room = dgn.get_current_room() self.font = pygame.font.SysFont("cmr10", 18, False, False) self.enemy_list = [] #Holds the list of enemies self.magic_list = [] #Holds list of magic used? self.spellType = 0 #0 = non, 1-4 are spells in order, 5 is special self.isMagic = False self.correct = False self.state = PLAYER_WAIT self.player_input = '0' self.active_target = 1 self.battleTimer = -1.0 self.tIndex = 0 for i in range(0, 4): e_index = self.current_room.get_enemy(i) if e_index != '0': curE = get_enemy(e_index) self.enemy_list.append(curE) self.add_to_scene([curE.get_sprite()]) # Preload images self.__drawableObjects = {} for i in ['arrow_select']: self.__drawableObjects[i] = DrawableObject( [pygame.image.load(HUD_PATH + i + ".gif")], '') self.add_to_scene([self.__drawableObjects[i]]) self.__drawableObjects['hp'] = DrawableObject( Spritesheet(HUD_PATH + "hp.gif").img_extract( 11, 1, 100, 100, [255, 0, 255]), '') self.__drawableObjects['bt'] = DrawableObject( Spritesheet(HUD_PATH + "bt.gif").img_extract( 1, 11, 100, 25, [255, 0, 255]), '', True) self.__drawableObjects['hp'].setColorKey((255, 0, 255)) self.__drawableObjects['bt'].setColorKey((255, 0, 255)) self.add_to_scene([self.__drawableObjects['hp']]) self.add_to_scene([self.__drawableObjects['bt']]) self.add_to_engine() self.game_engine.add_object('battlemenu', BattleMenuHolder(self.menu_callback)) self.game_engine.get_object('battlemenu').show_menu('selection') self.game_engine.get_object('mesg').add_line( _('Enemies present, prepare to fight!'))
def __init__(self): GameEngineElement.__init__(self, has_draw=True, has_event=True) sound = pygame.mixer.music.load(SOUND_PATH+ 'background_music.wav') #pygame.mixer.music.play(100, 0) self.score = [0,0] #[correct, incorrect] self.lastCorrect = 2 #0 = wrong, 1 = right, 2 = skip drawing, 3 = enter a guess! self.images = {} self.__load_images() self.player_input = '' self.__setup() self.add_to_engine()
def __init__(self): GameEngineElement.__init__(self, has_draw=True, has_event=True) sound = pygame.mixer.music.load(SOUND_PATH + 'background_music.wav') #pygame.mixer.music.play(100, 0) self.score = [0, 0] #[correct, incorrect] self.lastCorrect = 2 #0 = wrong, 1 = right, 2 = skip drawing, 3 = enter a guess! self.images = {} self.__load_images() self.player_input = '' self.__setup() self.add_to_engine()
def __init__(self, recall_string=None, name_entry_cb=None): GameEngineElement.__init__(self) self.name = "" self.dungeon_id = "al1.txt" self.position = (-1, -1) self.playerFacing = NORTH self.hero = Hero() # 4 types of stats and difficulties self.problem_stats = {} self.difficulty = {} for stat in ['mult', 'div', 'geo', 'shop']: # Each type of stat has 3 "levels" easy, medium, hard # Shop uses level for too much, too little, exact self.problem_stats[stat] = [(0, 0), (0, 0), (0, 0)] #Difficulty: 1=Easy 2=Meduim(default) 3=Hard self.difficulty[stat] = 2 self.puzzlesSolved = 0 self.inventory = [] bg = pygame.image.load(MENU_PATH + "mafh_splash.gif").convert() self.background = DrawableObject([bg], '') self.background.scale(self.game_engine.width, self.game_engine.height) self.add_to_scene([self.background]) #create background rect draw_width = self.game_engine.width / 4 draw_height = self.game_engine.height / 4 surf = pygame.Surface((draw_width + 60, draw_height + 60)) surf.fill((150, 150, 255)) self.blueRect = DrawableObject([surf], "") self.add_to_scene([self.blueRect]) font = pygame.font.Font(None, 16) self.text_list = [] self.text_list.append(DrawableFontObject("1", font)) self.text_list.append(DrawableFontObject("2", font)) self.text_list.append(DrawableFontObject("name", font)) self.add_to_scene(self.text_list) if recall_string: self.load_from_json_string(recall_string) if self.name == "": self.name_cb = name_entry_cb self.add_to_engine()
def __init__(self, dgn): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.dgn = dgn self.current_room = dgn.get_current_room() self.font = pygame.font.SysFont("cmr10", 18, False, False) self.enemy_list = [] # Holds the list of enemies self.magic_list = [] # Holds list of magic used? self.spellType = 0 # 0 = non, 1-4 are spells in order, 5 is special self.isMagic = False self.correct = False self.state = PLAYER_WAIT self.player_input = "0" self.active_target = 1 self.battleTimer = -1.0 self.tIndex = 0 for i in range(0, 4): e_index = self.current_room.get_enemy(i) if e_index != "0": curE = get_enemy(e_index) self.enemy_list.append(curE) self.add_to_scene([curE.get_sprite()]) # Preload images self.__drawableObjects = {} for i in ["arrow_select"]: self.__drawableObjects[i] = DrawableObject([pygame.image.load(HUD_PATH + i + ".gif")], "") self.add_to_scene([self.__drawableObjects[i]]) self.__drawableObjects["hp"] = DrawableObject( Spritesheet(HUD_PATH + "hp.gif").img_extract(11, 1, 100, 100, [255, 0, 255]), "" ) self.__drawableObjects["bt"] = DrawableObject( Spritesheet(HUD_PATH + "bt.gif").img_extract(1, 11, 100, 25, [255, 0, 255]), "", True ) self.__drawableObjects["hp"].setColorKey((255, 0, 255)) self.__drawableObjects["bt"].setColorKey((255, 0, 255)) self.add_to_scene([self.__drawableObjects["hp"]]) self.add_to_scene([self.__drawableObjects["bt"]]) self.add_to_engine() self.game_engine.add_object("battlemenu", BattleMenuHolder(self.menu_callback)) self.game_engine.get_object("battlemenu").show_menu("selection") self.game_engine.get_object("mesg").add_line(_("Enemies present, prepare to fight!"))
def __init__(self, recall_string=None, name_entry_cb=None): GameEngineElement.__init__(self) self.name = "" self.dungeon_id = "al1.txt" self.position = (-1, -1) self.playerFacing = NORTH self.hero = Hero() # 4 types of stats and difficulties self.problem_stats = {} self.difficulty = {} for stat in ["mult", "div", "geo", "shop"]: # Each type of stat has 3 "levels" easy, medium, hard # Shop uses level for too much, too little, exact self.problem_stats[stat] = [(0, 0), (0, 0), (0, 0)] # Difficulty: 1=Easy 2=Meduim(default) 3=Hard self.difficulty[stat] = 2 self.puzzlesSolved = 0 self.inventory = [] bg = pygame.image.load(MENU_PATH + "mafh_splash.gif").convert() self.background = DrawableObject([bg], "") self.background.scale(self.game_engine.width, self.game_engine.height) self.add_to_scene([self.background]) # create background rect draw_width = self.game_engine.width / 4 draw_height = self.game_engine.height / 4 surf = pygame.Surface((draw_width + 60, draw_height + 60)) surf.fill((150, 150, 255)) self.blueRect = DrawableObject([surf], "") self.add_to_scene([self.blueRect]) font = pygame.font.Font(None, 16) self.text_list = [] self.text_list.append(DrawableFontObject("1", font)) self.text_list.append(DrawableFontObject("2", font)) self.text_list.append(DrawableFontObject("name", font)) self.add_to_scene(self.text_list) if recall_string: self.load_from_json_string(recall_string) if self.name == "": self.name_cb = name_entry_cb self.add_to_engine()
def __init__(self, x,y,width,height,lines): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.max_lines = lines self.x = x self.y = y surf = pygame.Surface((int(width),int(height))) surf.fill([0,0,0]) self.box = DrawableObject([surf],"") self.box.setPosition(int(x),int(y)) self.font = pygame.font.Font(None, 28) self.__lines = [] for i in range(lines): self.__lines.append(DrawableFontObject('', self.font)) self.add_to_scene([self.box]) self.add_to_scene(self.__lines) self.add_to_engine()
def __init__(self, dgn): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.draw_macro_set = False #A boolean value to determine whether the large map should draw self.sizeX = dgn.sizeX #A variable that represents the number of rooms wide the dungeon is self.sizeY = dgn.sizeY #A variable that represents the number of rooms tall the dungeon is self.rectSizeX = 38 #A variable representing the X size of a given room on the mini map self.rectSizeY = 38 #A variable representing the Y size of a given room on the mini map self.rects = { } #A dictionary of rectangles that represent the rooms on the map self.fullRooms = {} #A dictionary representing nothing? self.totalSurface = pygame.Surface( (self.sizeX * 40, self.sizeY * 40)) #A rect representing the size of the map as a whole #A Two dimensional For Loop that goes through all of the positions on the map. for y in range(self.sizeY): for x in range(self.sizeX): curRect = pygame.Rect( x * 40, y * 40, self.rectSizeX, self.rectSizeX ) #Creating a rectangle for the current position on the map. self.rects[( x, y )] = curRect #Adds the rectangle associated with the current position to the dictionary using the position on the map as the key. #Each 'if' tests whether there is a door in a given direction at the current position. #If there is a door in the given direction, it fills the square associated with themeans that the position has a room and fills it accordingly. if dgn.rooms.get((x, y)).get_door('N') != '0': self.fullRooms[(x, y)] = True self.totalSurface.fill((255, 255, 255), curRect, 0) elif dgn.rooms.get((x, y)).get_door('S') != '0': self.fullRooms[(x, y)] = True self.totalSurface.fill((255, 255, 255), curRect, 0) elif dgn.rooms.get((x, y)).get_door('E') != '0': self.fullRooms[(x, y)] = True self.totalSurface.fill((255, 255, 255), curRect, 0) elif dgn.rooms.get((x, y)).get_door('W') != '0': self.fullRooms[(x, y)] = True self.totalSurface.fill((255, 255, 255), curRect, 0) self.add_to_engine() #Adds itself and all callbacks to the engine self.myDrawableObject = DrawableObject([pygame.Surface((0, 0))], '') self.add_to_scene([self.myDrawableObject])
def __init__(self, x, y, width, height, lines): GameEngineElement.__init__(self, has_draw=True, has_event=False) self.max_lines = lines self.x = x self.y = y surf = pygame.Surface((int(width), int(height))) surf.fill([0, 0, 0]) self.box = DrawableObject([surf], "") self.box.setPosition(int(x), int(y)) self.font = pygame.font.Font(None, 28) self.__lines = [] for i in range(lines): self.__lines.append(DrawableFontObject('', self.font)) self.add_to_scene([self.box]) self.add_to_scene(self.__lines) self.add_to_engine()
def __init__(self, id): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.id = id self.rooms={} self.__images={} self.__load_dungeon() self.__load_images() profile = self.game_engine.get_object('profile') if profile.position == (-1, -1): x,y = self.start profile.move_to( x, y ) self.doorsList = [] self.game_engine.get_scene().addObject(DrawableObject([self.__images['Room']], '')) self.doorsList.append(DrawableObject([self.__images['L']], '', True, 0 ,0)) self.doorsList.append(DrawableObject([self.__images['F']], '', True, 360 ,0)) self.doorsList.append(DrawableObject([pygame.transform.flip(self.__images['L'], True, False)], '', True, 990 ,0)) #for door in self.doorsList: door.makeTransparent(True) self.add_to_scene(self.doorsList) self.itemsList = [] for i in range(4): surf = pygame.Surface((10,10)) surf.fill((0,0,0)) tempItem = DrawableObject([surf],"", True) self.itemsList.append(tempItem) self.itemsList[0].setPosition(self.game_engine.art_scale(270, 1200, True), self.game_engine.art_scale(330, 900, False)) self.itemsList[1].setPosition(self.game_engine.art_scale(100, 1200, True),self.game_engine.art_scale(600, 900, False)) self.itemsList[2].setPosition(self.game_engine.art_scale(1100, 1200, True),self.game_engine.art_scale(600, 900, False)) self.itemsList[3].setPosition(self.game_engine.art_scale(900, 1200, True),self.game_engine.art_scale(330, 900, False)) self.add_to_scene(self.itemsList) self.add_to_engine()
def __init__(self,Folder,BGM,endcb): GameEngineElement.__init__(self) self.currentIndex = 0 self.images=[] self.endcb = endcb #load images into sprites i=0 for image in os.listdir(Folder): spt=pygame.sprite.Sprite() spt.image=pygame.image.load(Folder+image) spt.rect=pygame.Rect(0,0,1200,900) self.images.append(spt) i+=1 self.size=i #try to load music if BGM != None: pygame.mixer.muxic.stop() pygame.mixer.music.load(SOUND_PATH+BGM) pygame.mixer.music.play(-1) self.add_to_engine()
def __init__(self, Folder, BGM, endcb): GameEngineElement.__init__(self) self.currentIndex = 0 self.images = [] self.endcb = endcb #load images into sprites i = 0 for image in os.listdir(Folder): spt = pygame.sprite.Sprite() spt.image = pygame.image.load(Folder + image) spt.rect = pygame.Rect(0, 0, 1200, 900) self.images.append(spt) i += 1 self.size = i #try to load music if BGM != None: pygame.mixer.muxic.stop() pygame.mixer.music.load(SOUND_PATH + BGM) pygame.mixer.music.play(-1) self.add_to_engine()
def __init__(self, dgn): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.draw_macro_set = False #A boolean value to determine whether the large map should draw self.sizeX=dgn.sizeX #A variable that represents the number of rooms wide the dungeon is self.sizeY=dgn.sizeY #A variable that represents the number of rooms tall the dungeon is self.rectSizeX=38 #A variable representing the X size of a given room on the mini map self.rectSizeY=38 #A variable representing the Y size of a given room on the mini map self.rects={} #A dictionary of rectangles that represent the rooms on the map self.fullRooms={} #A dictionary representing nothing? self.totalSurface=pygame.Surface((self.sizeX*40,self.sizeY*40)) #A rect representing the size of the map as a whole #A Two dimensional For Loop that goes through all of the positions on the map. for y in range(self.sizeY): for x in range(self.sizeX): curRect=pygame.Rect(x*40,y*40,self.rectSizeX,self.rectSizeX) #Creating a rectangle for the current position on the map. self.rects[(x,y)]=curRect #Adds the rectangle associated with the current position to the dictionary using the position on the map as the key. #Each 'if' tests whether there is a door in a given direction at the current position. #If there is a door in the given direction, it fills the square associated with themeans that the position has a room and fills it accordingly. if dgn.rooms.get((x,y)).get_door('N') != '0': self.fullRooms[(x,y)]=True self.totalSurface.fill((255,255,255),curRect,0) elif dgn.rooms.get((x,y)).get_door('S') != '0': self.fullRooms[(x,y)]=True self.totalSurface.fill((255,255,255),curRect,0) elif dgn.rooms.get((x,y)).get_door('E') != '0': self.fullRooms[(x,y)]=True self.totalSurface.fill((255,255,255),curRect,0) elif dgn.rooms.get((x,y)).get_door('W') != '0': self.fullRooms[(x,y)]=True self.totalSurface.fill((255,255,255),curRect,0) self.add_to_engine() #Adds itself and all callbacks to the engine self.myDrawableObject = DrawableObject([pygame.Surface((0,0))], '') self.add_to_scene([self.myDrawableObject])
def __init__(self): GameEngineElement.__init__(self, has_draw=False, has_event=True) self.add_to_engine() game_size_ratio_x = self.game_engine.width/1200.0 game_size_ratio_y = self.game_engine.height/900.0 term_width_offset = game_size_ratio_x * 200 term_height = game_size_ratio_y * 200 term_height_offset = game_size_ratio_y * 700 term_width = game_size_ratio_x * 1000 """ term_width_offset = self.game_engine.width/4 term_height = self.game_engine.height/6 term_height_offset = self.game_engine.height - term_height term_width = self.game_engine.width - term_width_offset """ self.game_engine.add_object('mesg', TermBox(term_width_offset, term_height_offset,term_width,term_height,5) ) self.game_engine.get_object('mesg').add_line("Welcome to Fortune Hunter") self.game_engine.add_object('dungeon', Dungeon( self.game_engine.get_object('profile').dungeon_id))
def __init__(self, game_menu, x, y, type=NORMAL_MENU): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.menu = Menu(game_menu, type, self.game_engine.get_scene(), x, y ) self.add_to_engine()
def __init__(self, callback): GameEngineElement.__init__(self, has_draw=False, has_event=False) self.menu = None self.callback = callback self.font = pygame.font.SysFont("cmr10", 26, False, False) self.add_to_engine()
def __init__(self, callback): GameEngineElement.__init__(self, has_draw=False, has_event=False) self.menu = None self.callback = callback self.font = pygame.font.SysFont("cmr10",26,False,False) self.add_to_engine()
def __init__(self, game_menu, x, y, type=NORMAL_MENU): GameEngineElement.__init__(self, has_draw=True, has_event=True) self.menu = Menu(game_menu, type, self.game_engine.get_scene(), x, y) self.add_to_engine()