def __init__(self): self.GAME = 'BEGIN GAME' self.GAME_CAPTION = 'XF game' # load game's resources self.FONTS = load_all_fonts(os.path.join('resources', 'fonts')) self.MUSIC = load_all_music(os.path.join('resources', 'music')) self.GFX = load_all_gfx(os.path.join('resources', 'graphics')) self.SFX = load_all_sfx(os.path.join('resources', 'sound')) self.TMX = load_all_tmx(os.path.join('resources', 'tmx')) self.FONT = pg.font.Font(self.FONTS['Fixedsys500c'], 20) self.screen = pg.display.get_surface() self.events = None self.viewport = None self.level_surface = None self.level_rect = None # box self.bground = self.GFX['box'] self.bgroundrect = self.bground.get_rect(centerx=400) # load map resource self.tmx_map = self.TMX['background2'] self.renderer = tilerender.Renderer(self.tmx_map) self.map_image = self.renderer.make_map() self.map_rect = self.map_image.get_rect() self.viewport = SCREEN.get_rect(bottom=self.map_rect.bottom) self.level_surface = pg.Surface(self.map_rect.size) self.level_rect = self.level_surface.get_rect() # set blocks self.blockers = [] for object in self.renderer.tmx_data.getObjects(): if object.name == 'BLOCK': left = object.x - 64 top = object.y blocker = pg.Rect(left, top, 32, 32) self.blockers.append(blocker) # load players self.player = None for object in self.renderer.tmx_data.getObjects(): properties = object.__dict__ if object.name == 'spoint': posx = object.x + 32 posy = object.y self.player = Player.Player('player1', 'down', posx, posy) self.player.rect.x = posx self.player.rect.y = posy else: self.player = Player.Player('player1', 'down') self.player.rect.x = 0 self.player.rect.y = 0
def make_player(self): for object in self.renderer.tmx_data.getObjects(): properties = object.__dict__ if properties['name'] == 'start point': posx = properties['x'] * 2 posy = (properties['y'] * 2) - 32 player = Player(properties['direction']) player.rect.x = posx player.rect.y = posy return player
def __init__(self): pg.init() self.GAME = 'BEGIN GAME' self.GAME_CAPTION = 'XF game' self.FONTS = load_all_fonts(os.path.join('resources', 'fonts')) self.MUSIC = load_all_music(os.path.join('resources', 'music')) self.GFX = load_all_gfx(os.path.join('resources', 'graphics')) self.SFX = load_all_sfx(os.path.join('resources', 'sound')) self.TMX = load_all_tmx(os.path.join('resources', 'tmx')) self.FONT = pg.font.Font(self.FONTS['Fixedsys500c'], 14) self.events = None self.viewport = None self.level_surface = None self.level_rect = None self.screen = pg.display.get_surface() # initialization dialog box self.bground = self.GFX['box'] self.bgroundrect = self.bground.get_rect(centerx=400) self.bgroundimage = pg.Surface(self.bgroundrect.size) self.bgroundimage.set_colorkey((0, 0, 0)) self.bgroundimage.blit(self.bground, (0, 0)) # scripts self.scripts_list = pg.sprite.Group() self.script1 = Scripts('script1', 235, 32 * 9.5, 'xsdhlfvhsu,hdjvghdfjkg,hzjsdkfghjxfkg,hfdj,gvhxkjvhsu,hdjvghdfjkg,hzjsdkfghjxfkg,hfdj,gvhxkj') self.script2 = Scripts('script2', 32 * 7, 32 * 15.6, 'y37467ery etwrutuewtr012345 6789abc123456 ' '7890okl1234567890 54849vhsu,hdjvghdfjkg,hzjsdkfghjxfkg,hfdj,gvhxkj') self.scripts_list.add(self.script1) self.scripts_list.add(self.script2) # for i in range(2): # script = Scripts("script%s"%(i+1), 64*i+635, 32*9.5+32*5*i) # self.scripts_list.add(script) self.collide_scripts = False # scripts collide # map self.tmx_map = self.TMX['background2'] self.renderer = Renderer(self.tmx_map) self.map_image = self.renderer.make_map() self.map_rect = self.map_image.get_rect() self.viewport = SCREEN.get_rect(bottom=self.map_rect.bottom) self.level_surface = pg.Surface(self.map_rect.size) self.level_rect = self.level_surface.get_rect() # box self.box = self.GFX["box"] self.boxpos = self.box.get_rect() print(self.viewport.x, self.viewport.y) self.messagebox = MessageBox() #blocks self.blockers = [] for object in self.renderer.tmx_data.getObjects(): if object.name == 'BLOCK': left = object.x - 64 top = object.y blocker = pg.Rect(left, top, 32, 32) self.blockers.append(blocker) #player self.player = None for object in self.renderer.tmx_data.getObjects(): properties = object.__dict__ if object.name == 'spoint': posx = object.x + 32 posy = object.y # toodo change girl or boys self.player = Player.Player('girl32', 'down', posx, posy) self.player.rect.x = posx self.player.rect.y = posy else: self.player = Player.Player('girl32', 'down') self.player.rect.x = 320 self.player.rect.y = 320 self.processbar = ProcessBar(30, 40, 1000, 20) #texts on the first page self.atexts = AnimateText2([ {"text": "Hey dude, I need your help. Really, you need to listen to me.", "x": 32 * 1, "y": 32 * 2, "type": "text"}, {"text": "I\'ve called the police but they didn\'t believe me.", "x": 32 * 1, "y": 32 * 3, "type": "text"}, {"text": "What happened?", "x": 32 * 8, "y": 32 * 4, "type": "text"}, {"text": "Okay ... I fainted,this is the last thing I\'ve remember.", "x": 32 * 1, "y": 32 * 5, "type": "text"}, {"text": "But now,I\'m in a... I think this is an auditorium. And I\'m wearing a strange orange suit.", "x": 32 * 1, "y": 32 * 6, "type": "text"}, {"text": "I was playing my phone somewhere I think and then...I just arrived here! Sounds crazy right?", "x": 32 * 1, "y": 32 * 7, "type": "text"}, {"text": "It is indeed quite crazy OR I believe you, dude.", "x": 32 * 8, "y": 32 * 8, "type": "button", "offset": 3}, {"text": "Fine,anyway. I\'m trying to figure out how to get out of this place.Any suggestion?", "x": 32 * 0, "y": 32 * 9, "type": "text"}, {"text": "Try the door! OR What\'s your staus?", "x": 32 * 8, "y": 32 * 10, "type": "button", "offset": 2}, {"text": "Let me try...hmm...it\'s locked.", "x": 32 * 0, "y": 32 * 11, "type": "text"}, {"text": "I\'m fine! Luckily not being harmed. At least I have my kidney preserved.", "x": 32 * 0, "y": 32 * 12, "type": "text"}, {"text": "My phone got...24% of the battery and that's the only thing that links us now.", "x": 32 * 0, "y": 32 * 13, "type": "text"}, {"text": 'Hang on! There\'s a camera!I know you could hack into it,right?', "x": 32 * 0, "y": 32 * 14, "type": "text"}, {"text": "I need the something to tell me where you are so I could get the IP address.", "x": 32 * 8, "y": 32 * 15, # "jump": 2, "type": "text"}, {"text": "No,I'll just call the police to let them pick you up.", "x": 32 * 8, "y": 32 * 16, "type": "text"}, {"text": "No,no,no don't! I...no need for the cops,alright?", "x": 32 * 0, "y": 32 * 17, "type": "text"}, {"text": "Are you messing with the drugs again?", "x": 32 * 8, "y": 32 * 18, "type": "text"}, {"text": "No,I mean, a little, alright?", "x": 32 * 0, "y": 32 * 19, "type": "text"}, {"text": "Seriously? Again? I mean, how long have you been out, 4 days ? ", "x": 32 * 0, "y": 32 * 20, "type": "text"}, {"text": "Never again, okay? Go and find any address that could let me find where you are.", "x": 32 * 0, "y": 32 * 21, "type": "text"}, {"text": "Okay then, there\'s definitely something with a name tag here.", "x": 32 * 0, "y": 32 * 22, "type": "text"}, {"text": "Wait...", "x": 32 * 0, "y": 32 * 23, "type": "text"}, # 此处有假进度条 {"text": "Okay...Here are some more.", "x": 32 * 0, "y": 32 * 24, "type": "text"}, ])
renderer = tilerender.Renderer(tmx_map) map_image = renderer.make_map() map_rect = map_image.get_rect() viewport = SCREEN.get_rect(bottom=map_rect.bottom) level_surface = pg.Surface(map_rect.size) level_rect = level_surface.get_rect() # title_box = GFX['title_box'] # title_rect = title_box.get_rect() # title_rect.midbottom = viewport.midbottom # title_rect.y -= 30 alpha = 255 # player posx = 0 posy = 0 player = Player.Player('down') player.rect.x = posx player.rect.y = posy # blocks blockers = [] for object in renderer.tmx_data.getObjects(): # properties = object.__dict__ # if properties['name'] == 'BLock': # left = properties['x'] * 2 # top = (properties['y'] * 2) - 32; # blocker = pg.Rect(left, top, 32, 32) # blockers.append(blocker) if object.name == 'BLOCK': left = object.x - 64 top = object.y blocker = pg.Rect(left, top, 32, 32)
tmx_map = TMX['title'] renderer = tilerender.Renderer(tmx_map) map_image = renderer.make_2x_map() map_rect = map_image.get_rect() viewport = SCREEN.get_rect(bottomright=map_rect.bottomright) level_surface = pg.Surface(map_rect.size) title_box = GFX['title_box'] title_rect = title_box.get_rect() title_rect.midbottom = viewport.midbottom title_rect.y -= 30 alpha = 255 posx = 0 posy = 0 player = Player.Player('down') player.rect.x = posx player.rect.y = posy for object in renderer.tmx_data.getObjects(): properties = object.__dict__ if properties['name'] == 'start point': posx = properties['x'] * 2 posy = (properties['y'] * 2) - 32 player = Player.Player('down') player.rect.x = posx player.rect.y = posy else: posx = 0 posy = 0