def _create_sprites(self): images = [ common.load_image('presents/frame_1.png'), common.load_image('presents/frame_2.png'), ] actions = FadeIn(.5) + Delay(2) + FadeOut(1) animation = pyglet.image.Animation.from_image_sequence(images, 0.10) self.logo = ActionSprite(animation) self.logo.do(actions) self.logo.x = 0 self.logo.y = 0 images = [ common.load_image('presents/pyweek_1.png'), common.load_image('presents/pyweek_2.png'), ] animation = pyglet.image.Animation.from_image_sequence(images, 0.10) self.pyweek = ActionSprite(animation) self.pyweek.opacity = 0 self.pyweek.do(Delay(2.5) + actions) self.pyweek.x = 0 self.pyweek.y = 0
def __init__(self): super(RestartMenu, self).__init__() items = [ (ImageMenuItem(common.load_image("button_restart.png"), self.begin_game)), (ImageMenuItem(common.load_image("button_score.png"), self.showscore)) ] menu = Menu() menu.menu_valign = BOTTOM menu.menu_halign = LEFT positions = [(common.visibleSize["width"] / 6, common.visibleSize["height"] / 3), (common.visibleSize["width"] * 3 / 5, common.visibleSize["height"] / 3)] menu.create_menu(items, selected_effect=shake(), unselected_effect=shake_back()) setMenuItemPos(menu, positions) self.add(menu, z=52) alivetime = int(endtime - starttime) #保存分数 import pipe now_score = pipe.g_score alivetime = endtime - starttime level = pipe.g_level score_list = [] time_list = [] try: if pattern != 0: level = 'reverse' data = open(level + '_score.txt', 'r') for i in data.read().splitlines(): score_list.append(i.split('@')[0]) time_list.append(i.split('@')[1]) data.close() except Exception, e: score_list = [] time_list = []
def __init__(self, bounds): super().__init__(rect=pg.Rect(0, 0, 220, 220)) self.image = pg.Surface(self.rect.size, pg.SRCALPHA, 32) self.bounds = bounds self.atlas = load_image('zanemotes.png', alpha=True) self.mask = load_image('zaneboxmask.png') self.set_emote('IDLE')
def __init__(self): super(RestartMenu, self).__init__() items = [(ImageMenuItem(common.load_image("button_restart.png"), self.begin_game)), (ImageMenuItem(common.load_image("button_score.png"), self.showscore))] menu = Menu() menu.menu_valign = BOTTOM menu.menu_halign = LEFT positions = [(common.visibleSize["width"] / 6, common.visibleSize["height"] / 3), (common.visibleSize["width"] * 3 / 5, common.visibleSize["height"] / 3)] menu.create_menu(items, selected_effect=shake(), unselected_effect=shake_back()) setMenuItemPos(menu, positions) self.add(menu, z=52) #保存分数 import pipe now_score = pipe.g_score level = pipe.g_level try: if pattern == 0: data = open(level + '_score.txt', 'r') else: data = open('reverse.txt', 'r') f = data.read().splitlines() data.close() except Exception, e: data = None f = []
def __init__(self): Sprite.__init__(self) path = os.path.join(constants.data_folder, "cursors", "hand") self.open, self.rect = common.load_image(path + "-open.png") self.close, self.rect = common.load_image(path + "-close.png") self.image = self.open return
def _create_sprites(self): SPEED = 0.4 logo_image = common.load_image('scene/intro/ceferino.png') logo = Sprite(logo_image) logo.scale = 4 logo.rotation = 180 logo.opacity = 0 logo.do(Place((100, 230))) logo.do(Delay(SPEED / 2) + (FadeIn(SPEED * 2) | RotateBy(180, SPEED) | ScaleTo(1, SPEED))) losers_image = common.load_image('scene/intro/losers.png') losers = Sprite(losers_image) losers.position = 300, 500 losers.rotation = 180 losers.opacity = 0 losers.do(Delay(SPEED) + (MoveTo((300, 250), SPEED) | FadeIn(SPEED) | RotateBy(180, SPEED))) juegos_image = common.load_image('scene/intro/juegos.png') juegos = Sprite(juegos_image) juegos.position = 500, 0 juegos.rotation = -180 juegos.opacity = 0 juegos.do(Delay(SPEED/2 * 3) + (MoveTo((520, 250), SPEED) | FadeIn(SPEED) | RotateBy(180, SPEED)) + Delay(2) + CallFunc(self.skip_scene)) self.add(logo) self.add(losers) self.add(juegos) self.juegos = juegos
def __init__(self, pre_menu, isRegister=False): super(InputLoginName, self).__init__(0, 0, 0, 0) self.isRegister = isRegister self.name = "login_menu" self.pre_menu = pre_menu self.keys_pressed = "" self.char_limit = 10 self.set_player_name = "" # label = cocos.text.Label('Pick a name:', # font_name='Courier', # font_size=24, # anchor_x='center', anchor_y='center') # label.position = common.visibleSize["width"]/2, common.visibleSize["height"]* 3/4 label = createLabel("Input username:\n(10 char at most)", common.visibleSize["width"] / 2, common.visibleSize["height"] * 3 / 4) self.add(label) self.text = createLabel("", common.visibleSize["width"] / 2 + 20, common.visibleSize["height"] * 5 / 7 - 50) self.add(self.text) self.menu = Menu() self.menu.menu_valign = BOTTOM items = [ (ImageMenuItem(common.load_image("button_next.png"), self.next_func)), (ImageMenuItem(common.load_image("button_cancel.png"), self.cancel)), ] self.menu.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out()) self.add(self.menu)
def __init__(self): super(EventLayer, self).__init__() self.dragon = Dragon() for index, part in enumerate(self.dragon.body[::-1]): self.add(part, z=index / 10.0) self.add(self.dragon, z=1) image = common.load_image('dragon/body.png') sprite = cocos.sprite.Sprite(image) sprite.position = 500, 200 self.add(sprite) image = common.load_image('shaolin/test.png') sprite = cocos.sprite.Sprite(image) sprite.position = 200, 150 self.add(sprite) image = common.load_image('shaolin/test_2.png') sprite = cocos.sprite.Sprite(image) sprite.position = 50, 150 self.add(sprite) image = common.load_image('enemies/hannia/stand.png') sprite = cocos.sprite.Sprite(image) sprite.position = 300, 150 self.add(sprite)
def __init__(self): super(RestartMenu, self).__init__() self.font_item = { 'font_name': 'Arial', 'font_size': 40, 'bold': False, 'italic': False, 'anchor_y': 'center', 'anchor_x': 'center', 'color': (192, 192, 192, 255), 'dpi': 96, } self.font_item_selected = { 'font_name': 'Arial', 'font_size': 40, 'bold': False, 'italic': False, 'anchor_y': 'center', 'anchor_x': 'center', 'color': (255, 255, 255, 255), 'dpi': 96, } self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("button_restart.png"), self.initMainMenu)), (ImageMenuItem(common.load_image("button_score.png"), showScore)) ] self.create_menu(items, layout_strategy = fixedPositionMenuLayout([(74,200),(154,200)]))
def __init__(self, world, last, new): self.world = world self.last = last self.new = new self.delay = 0 self.speed = 0.0 self.draw = self.draw_opening # nueva escena self.new_screenshot = world.screen.convert() new.draw(self.new_screenshot) # anterior en dos partes self.last_1 = world.screen.convert() self.last_2 = world.screen.convert() last.draw(self.last_1) last.draw(self.last_2) # corte 1 split_1 = common.load_image("split_1.png", "scenes") self.last_1.blit(split_1, (0, 0)) self.last_1.set_colorkey((255, 0, 255)) # corte 2 split_2 = common.load_image("split_2.png", "scenes") self.last_2.blit(split_2, (0, 0)) self.last_2.set_colorkey((255, 0, 255)) # marca de corte self.split = common.load_image("split_3.png", "scenes")
def _create_sprites(self): ima_background = common.load_image('intro/sky3.png') layer = common.load_image('layer.png') sky = ActionSprite(ima_background) sky.y = 118 sky.x = 100 sky.do(Move((0, -5), 6)) image = common.load_image('intro/castle.png') image.anchor_x = image.width / 2 castle = ActionSprite(image) castle.x = 320 castle.y = 100 castle.do(Move((0, -10), 4) | Scale(0.97, 4)) ima = common.load_image('intro/tree.png') ima.anchor_x = image.width / 2 intro_1 = ActionSprite(ima) intro_1.x = 95 + image.width / 2 intro_1.y = 80 player = ActionSprite(common.load_image('intro/player.png')) player.x = 400 player.y = 90 player.do(Jump(5, 40, 5, 4)) self.sprites = [sky, castle, intro_1, player] self.layer = layer
class Castle(pb.Copyable, pb.RemoteCopy): # instances = [] castle_pic = common.load_image("castle.png", alpha=True) bigcastle_pic = common.load_image("bigcastle.png", alpha=True) def __init__(self, pos, player, map): self.pos = tuple(pos) self.player = player self.big = False self.selected = False # For select phase only # Castle.instances.append(self) for x in (0, 1): for y in (0, 1): map.array[pos[0] + x][pos[1] + y] = Field.CASTLE def backbuffer_blit(self): if self.big == False: pic = Castle.castle_pic else: pic = Castle.bigcastle_pic common.backbuffer_blit(pic, multiply(self.pos, common.block_size)) # game.field.surface.blit(pic, screen_pos) def getStateToCopy(self): state = self.__dict__.copy() return state def setCopyableState(self, state): self.__dict__ = state
def __init__(self): super(loginMenu, self).__init__() position = [ common.visibleSize["width"] / 2 + 5, common.visibleSize["height"] * 3 / 5 ] self.uname_input = InputBox("username", position) position = [ common.visibleSize["width"] / 2 + 5, common.visibleSize["height"] * 31 / 60 ] self.pwd_input = InputBox("password", position, type="*") menu = Menu() items = [(ImageMenuItem(common.load_image("Login.png"), self.login)), (ImageMenuItem(common.load_image("register.png"), self.register))] menu.create_menu(items, selected_effect=shake(), unselected_effect=shake_back()) positions = [(common.visibleSize["width"] / 3, common.visibleSize["height"] * 2 / 5), (common.visibleSize["width"] * 3 / 5, common.visibleSize["height"] * 2 / 5)] setMenuItemPos(menu, positions) self.add(self.uname_input) self.add(self.pwd_input) self.add(menu)
def __init__(self): pygame.sprite.Sprite.__init__(self) if random.randint(0, 1): self.image = common.load_image('arbol.png', True) else: self.image = common.load_image('flor.png', True) self.rect = self.image.get_rect() self.rect.center = self.posicionPlanta()
def __init__(self): super(SingleMenu, self).__init__() items = [(ImageMenuItem(common.load_image("button_logout.png"), self.logOut)), (ImageMenuItem(common.load_image("button_notice.png"), self.logOut))] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out())
def __init__(self, name, energy, on_change_callback): self.name = name self.energy = energy self.on_change_callback = on_change_callback try: self.image = common.load_image("preview.png", name) except: self.image = common.load_image("preview.png", "enemies/" + name)
def __init__(self): super(SingleGameSignMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("button_SignUp.png"), self.signUp)), (ImageMenuItem(common.load_image("button_SignIn.png"), self.signIn)) ] self.create_menu(items,selected_effect=zoom_in(),unselected_effect=zoom_out())
def __init__(self): super(SingleGameStartMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("button_start.png"), self.gameStart)), (ImageMenuItem(common.load_image("button_notice.png"), showNotice)) ] self.create_menu(items,selected_effect=zoom_in(),unselected_effect=zoom_out())
def __init__(self): super(StartMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("button_start.png"), self.begin_game)), (ImageMenuItem(common.load_image("Login.png"), self.login_menu)) ] self.create_menu(items,selected_effect=zoom_in(),unselected_effect=zoom_out())
def _load_background(self): images = [ common.load_image('about/1.png'), common.load_image('about/2.png'), ] animation = pyglet.image.Animation.from_image_sequence(images, 0.10) self.animation = ActionSprite(animation) self.animation.x = 0 self.animation.y = 0
def __init__(self): super(DiffDegreeMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("easy.png"), self.easy_degree)), (ImageMenuItem(common.load_image("mid.png"), self.mid_degree)), (ImageMenuItem(common.load_image("hard.png"), self.hard_degree)) ] self.create_menu(items,selected_effect=zoom_in(),unselected_effect=zoom_out())
def __init__(self): Sprite.__init__(self) self.image_normal = os.path.join(constants.data_folder, 'cursors', "hand-open.png") self.image_close = os.path.join(constants.data_folder, 'cursors', "hand-close.png") self.normal, self.rect = common.load_image(self.image_normal) self.close, self.rect = common.load_image(self.image_close) self.image = self.normal self.color = 0
def __init__(self, name, position): sprite.Sprite.__init__(self) self.name = name self.image_name = os.path.join(constants.data_folder, "links", name) self.normal, self.rect = common.load_image(self.image_name + ".png") self.over = common.load_image(self.image_name + "_hover.png")[0] self.image = self.normal self.rect.move_ip(position) self.active = False
def _create_surfaces(self): icon = common.load_image("%s.png" %(self.name), "buttons") pos = icon.get_rect() pos.center = (20, 20) self.normal = common.load_image("button_normal.png", "buttons") self.normal.blit(icon, pos) self.hover = common.load_image("button_hover.png", "buttons") self.hover.blit(icon, pos)
def __init__(self): super(SingleRegisterMenu, self).__init__() #初始化账号信息为空 initializeRegisterInformation() userlabel = MenuItem('Username:'******'', True, self.gameUsername, "", 12) passlabel = MenuItem('Password:'******'', False, self.gamePassword, "", 12) passagainlabel = MenuItem('Password Again:', None) passagaintext = MyOwnEntryItem('', False, self.gamePasswordAgain, "", 12) registerbutton = ImageMenuItem( common.load_image("button_register.png"), self.gameRegister) gobackbutton = ImageMenuItem(common.load_image("button_goback.png"), self.gameGoback) self.font_item['font_size'] = 15 self.font_item_selected['font_size'] = 17 items = [ userlabel, usertext, passlabel, passtext, passagainlabel, passagaintext, registerbutton, gobackbutton ] self.create_menu(items) width, height = director.get_window_size() pos_x = width // 2 pos_y = height // 2 self.font_item['font_size'] = 38 self.font_item_selected['font_size'] = 39 registerbutton.generateWidgets(pos_x - 40, pos_y - 20, self.font_item, self.font_item_selected) gobackbutton.generateWidgets(pos_x + 40, pos_y - 20, self.font_item, self.font_item_selected) self.font_item['font_size'] = 15 self.font_item_selected['font_size'] = 17 self.font_item_selected['color'] = (0, 0, 0, 255) self.font_item['color'] = (0, 0, 0, 255) usertext.OwnGenerateWidgets( pos_x, pos_y + (self.font_item['font_size'] + 8) * 4 + 25, self.font_item, self.font_item_selected) passtext.OwnGenerateWidgets( pos_x, pos_y + (self.font_item['font_size'] + 8) * 2 + 25, self.font_item, self.font_item_selected) passagaintext.OwnGenerateWidgets(pos_x, pos_y + 25, self.font_item, self.font_item_selected) self.font_item_selected['font_size'] = 15 userlabel.generateWidgets( pos_x, pos_y + (self.font_item['font_size'] + 8) * 5 + 25, self.font_item, self.font_item_selected) passlabel.generateWidgets( pos_x, pos_y + (self.font_item['font_size'] + 8) * 3 + 25, self.font_item, self.font_item_selected) passagainlabel.generateWidgets( pos_x, pos_y + self.font_item['font_size'] + 8 + 25, self.font_item, self.font_item_selected)
def __init__(self): super(SingleDifficultyChooseMenu, self).__init__() items = [(ImageMenuItem(common.load_image("button_easy.png"), self.setEasy)), (ImageMenuItem(common.load_image("button_middle.png"), self.setMiddle)), (ImageMenuItem(common.load_image("button_hard.png"), self.setHard))] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out())
def __init__(self, x=100, y=400): Object.__init__(self) self.normal = common.load_image("cursor.png") self.invisible = common.load_image("invisible.png") self.set_visible(False) self.x, self.y = x, y self.rect = self.normal.get_rect() self.rect.centerx = x self.rect.bottom = y self.dy = 0 self.z = -y
def __init__(self): super(LogOrSignMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("button_login.png"), log_in)), (ImageMenuItem(common.load_image("button_signup.png"), sign_up)), ] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out())
def __init__(self, pos, letter, id): Sprite.__init__(self) image_name = os.path.join(constants.data_folder, "soups", \ letter + "_normal.png") self.image_normal, self.rect = common.load_image(image_name) image_name = os.path.join(constants.data_folder, "soups", \ letter + "_color.png") self.image_color, self.rect = common.load_image(image_name) self.rect.move_ip(pos) self.color = 0 #0 normal 1 coloreada 2 terminada self.id = id
def __init__(self): image = common.load_image('dragon/head.png') self.normal = image self.touch = common.load_image('dragon/head_touch.png') Sprite.__init__(self, image) self.anchor_x, self.anchor_y = 200, 200 self.position = 300, 300 self.schedule_interval(self.update, 1/60.0) self._create_body() rotate = Accelerate(RotateBy(20, 1), 2)
def __init__(self): super(GameUserMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [(ImageMenuItem(common.load_image("button_user1.png"), self.signIn)), (ImageMenuItem(common.load_image("button_user2.png"), self.register))] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out())
def __init__(self): super(SingleGameStartMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [#添加按钮,与点击按钮触发的对象 (ImageMenuItem(common.load_image("button_start.png"), self.gameStart)), (ImageMenuItem(common.load_image("button_notice.png"), showNotice)), (ImageMenuItem(common.load_image("button_record.png"), showRecord)), (ImageMenuItem(common.load_image("button_rank.png"), requestRank)), (ImageMenuItem(common.load_image("button_logout.png"), logOut)) ] self.create_menu(items,selected_effect=zoom_in(),unselected_effect=zoom_out())
def __init__(self, screen, background, capture, ref_img, transform_mat): State.__init__(self, screen, background, capture, ref_img, transform_mat) self.one = FloatingWord(common.load_image("1.png", alpha=True)[0], sfx="one.wav") self.two = FloatingWord(common.load_image("2.png", alpha=True)[0], sfx="two.wav") self.three = FloatingWord(common.load_image("3.png", alpha=True)[0], sfx="three.wav") self.fight = FloatingWord(common.load_image("fight.png", alpha=True)[0], sfx="fight.wav") self.fight.end_size = (200, 200) self.fight.anim_time = 1000 self.fight.wait_time = 100 self.sprites.add(self.three) print "CountdownState: Initialized"
def __init__(self): super(SingleGameStartMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER # 舍弃原有的start按钮,直接从选择难度进入游戏 modified by Joe at 2017.12.11 items = [ (ImageMenuItem(common.load_image("button_easy.png"), self.gameStartEasy)), (ImageMenuItem(common.load_image("button_medium.png"), self.gameStartMedium)), (ImageMenuItem(common.load_image("button_hard.png"), self.gameStartHard)), # (MultipleMenuItem('difficulty',on_diff_choose(),diffBuf,0)) ] self.create_menu(items,selected_effect=zoom_in(),unselected_effect=zoom_out())
def _load_images(self): self.img = [ common.load_image('tv/0.png'), common.load_image('tv/1.png'), common.load_image('tv/2.png'), common.load_image('tv/3.png'), common.load_image('tv/4.png'), ] for image in self.img: image.anchor_x = 164 image.anchor_y = 184
def __init__(self): super(RestartMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [(ImageMenuItem(common.load_image("button_restart.png"), self.initMainMenu)), (ImageMenuItem(common.load_image("button_difficulty.png"), self.initDifficultyMenu)), (ImageMenuItem(common.load_image("button_notice.png"), showNotice))] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out())
def __init__(self): super(DifficultyMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [ # 添加按钮,与点击按钮触发的对象 (ImageMenuItem(common.load_image("button_easy.png"), self.setGameEasy)), (ImageMenuItem(common.load_image("button_normal.png"), self.setGameNormal)), (ImageMenuItem(common.load_image("button_hard.png"), self.setGameHard)), (ImageMenuItem(common.load_image("button_Ai.png"), self.setGamAi)), ] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out()) global aiControl aiControl= False
def __init__(self): super(DifficultyMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("button_easy.png"), self.back0)), (ImageMenuItem(common.load_image("button_normal.png"), self.back1)), (ImageMenuItem(common.load_image("button_hard.png"), self.back2)), ] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out())
def __init__(self): super(RestartMenu, self).__init__() #self.menu_valign = CENTER #self.menu_halign = CENTER removeSpriteScores() gameOver_Item = ImageMenuItem(common.load_image("text_game_over.png"), None) gamePanel_Item = ImageMenuItem(common.load_image("score_panel.png"), None) restart_button = ImageMenuItem(common.load_image("button_restart.png"), self.initMainMenu) difficulty_button = ImageMenuItem( common.load_image("button_difficulty.png"), self.initDifficultyMenu) items = [ gameOver_Item, gamePanel_Item, restart_button, difficulty_button ] self.create_menu(items) width, height = director.get_window_size() pos_x = width // 2 pos_y = height // 2 self.font_item['font_size'] = 42 self.font_item_selected['font_size'] = 45 restart_button.generateWidgets(pos_x - 48, pos_y - 50, self.font_item, self.font_item_selected) difficulty_button.generateWidgets(pos_x + 48, pos_y - 50, self.font_item, self.font_item_selected) self.font_item['font_size'] = 50 self.font_item['color'] = (255, 255, 255, 255) self.font_item_selected['font_size'] = 50 self.font_item_selected['color'] = (255, 255, 255, 255) gameOver_Item.generateWidgets(pos_x, pos_y + 135, self.font_item, self.font_item_selected) #设置游戏结果的panel global panel_pos_x, panel_pos_y, panel_size panel_size = 100 panel_pos_x = pos_x panel_pos_y = pos_y + 40 self.font_item['font_size'] = panel_size self.font_item['color'] = (255, 255, 255, 255) self.font_item_selected['font_size'] = panel_size self.font_item_selected['color'] = (255, 255, 255, 255) gamePanel_Item.generateWidgets(panel_pos_x, panel_pos_y, self.font_item, self.font_item_selected) #showRank(str(14), str(42)) showResult(str(score), str(bestScore), str(myRank), str(totalDefeat))
def __init__(self): super(DifficultyMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("button_simple.png"), self.selectSimple)), (ImageMenuItem(common.load_image("button_middle.png"), self.selectMiddle)), (ImageMenuItem(common.load_image("button_hard.png"), self.selectHard)), ] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out())
def __init__(self): super(LogInMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER items = [(ImageMenuItem(common.load_image("button_register.png"), self.register)), (ImageMenuItem(common.load_image("button_logIn.png"), self.logIn)), (ImageMenuItem(common.load_image("button_guest.png"), self.guest)), (ImageMenuItem(common.load_image("button_exit.png"), self.exit))] self.create_menu(items, selected_effect=zoom_in(), unselected_effect=zoom_out())
def __init__(self): pygame.sprite.Sprite.__init__(self) self.path_next = os.path.join(constants.icons_folder, 'gartoon', "next.png") self.path_prev = os.path.join(constants.icons_folder, 'gartoon', "prev.png") self.next, self.next_rect = common.load_image(self.path_next) self.prev, self.prev_rect = common.load_image(self.path_prev) self.next_rect.move_ip(constants.screen_mode[0] - \ self.next_rect[2] - 5, constants.screen_mode[1] - \ self.next_rect[3] - 5) self.prev_rect.move_ip(5, constants.screen_mode[1] - \ self.prev_rect[3] - 5) self.image = self.next self.rect = self.next_rect
def __init__(self): super(NoticeInputMenu2, self).__init__() self.menu_valign = CENTER self.menu_halign = LEFT self.font_item['font_size'] = 20 self.font_item_selected['font_size'] = 20 items = [(EntryMenuItem('send:', getNotice, '', 20)), (ImageMenuItem(common.load_image("button_ok.png"), self.sendNotice2)), (ImageMenuItem(common.load_image("button_back.png"), self.back2))] self.create_menu(items, selected_effect=zoom_out(), unselected_effect=zoom_out(), layout_strategy=myVerticalMenuLayout)
def _create_sprites(self): sky = ActionSprite(common.load_image('intro/sky2.png')) sky.y = 118 sky.do(Move((-200, 0), 6)) walk = ActionSprite(common.load_image('intro/walk.png')) walk.y = 130 walk.x = 120 #TODO: reducir el tamaño de esta imágen, es grande al pedo. ima_background = common.load_image('intro/back_subscene_3.png') background = ActionSprite(ima_background) background.x = 0 background.y = 0 self.sprites = [sky, background, walk]
def __init__(self, screen, background, capture, ref_img, transform_mat): State.__init__(self, screen, background, capture, ref_img, transform_mat) self.ready = False self.should_draw_bounding_box = True self.player1_rect = pygame.rect.Rect((10, 100, 300, common.RESOLUTION[1] - 100)) self.player2_rect = pygame.rect.Rect((common.RESOLUTION[0] - 310, 100, 390, common.RESOLUTION[1] - 100)) self.special_detection_rects += (self.player1_rect, self.player2_rect) self.mask = StageMask(self.player1_rect, self.player2_rect) self.title = common.FloatingWord(common.load_image('geekfighter.png', alpha = True)[0], center = (common.RESOLUTION[0] / 2, 154), sfx = 'opening.wav') self.title.start_size = (19, 10) self.title.end_size = (600, 308) self.title.anim_time = 2000 self.title.wait_forever = True self.sprites.add(self.title) self.explanations1 = common.HelpText((common.RESOLUTION[0] / 2, 330), 'Stand facing each other', self.font, (210, 0, 0), pos_is_center = True) self.explanations2 = common.HelpText((common.RESOLUTION[0] / 2, 370), 'in your FIGHTING STANCE', self.font, (210, 0, 0), pos_is_center = True) self.explanations3 = common.HelpText((common.RESOLUTION[0] / 2, 410), 'and HOLD STILL for 5 seconds', self.font, (210, 0, 0), pos_is_center = True) self.player1_counter = 0 self.player1_heights = [] self.player2_counter = 0 self.player2_heights = [] self.readybar1 = ReadyBar((10, 89), self.INIT_TIME) self.readybar2 = ReadyBar((common.RESOLUTION[0] - 310, 89), self.INIT_TIME) self.last_time = pygame.time.get_ticks() ## self.text = self.font.render("Players, stand facing each other with your arms at your sides", 1, (10, 10, 10)) ## self.pos = (self.screen.get_width() / 2 - self.text.get_width() / 2, self.screen.get_height() / 10) ## self.text2 = self.font.render("Press the SPACEBAR when ready...", 1, (10, 10, 10)) ## self.pos2 = (self.screen.get_width() / 2 - self.text2.get_width() / 2, self.screen.get_height() / 10 + self.text.get_height() + 5) print "TutorialState: Initialized"
def __init__(self, pos, letter, color): Sprite.__init__(self) image_name = os.path.join(constants.data_folder, "crazyletter", "container_" + color + ".png") self.image, self.rect = common.load_image(image_name) self.rect.move_ip(pos) self.letter = letter
def __init__(self): super(rankOkMenu, self).__init__() self.font_item = { 'font_name': 'Arial', 'font_size': 18, 'bold': False, 'italic': False, 'anchor_y': 'center', 'anchor_x': 'center', 'color': (255, 255, 255, 255), 'dpi': 96, } self.font_item_selected = { 'font_name': 'Arial', 'font_size': 22, 'bold': False, 'italic': False, 'anchor_y': 'center', 'anchor_x': 'center', 'color': (255, 255, 255, 255), 'dpi': 96, } self.menu_valign = CENTER self.menu_halign = CENTER items = [ (ImageMenuItem(common.load_image("button_ok.png"), self.goRestart)) ] self.create_menu(items,layout_strategy = fixedPositionMenuLayout([(114,140)]))
def __init__(self, initial_pos, direction): pygame.sprite.Sprite.__init__(self) self.direction = direction self.image, self.rect = common.load_image('skull.png', -1) self.rect.topleft = initial_pos if self.direction == common.DIRECTION_LEFT: self.rect.topright = self.rect.topleft
def __init__(self): global isOnline super(SingleGameStartMenu, self).__init__() self.menu_valign = CENTER self.menu_halign = CENTER menu = Menu() items = [ (ImageMenuItem(common.load_image("seeme.png"), self.select_diff)), (ImageMenuItem(common.load_image("reverse.png"),self.enter)), (ImageMenuItem(common.load_image("exit.png"), self.exit)), (ImageMenuItem(common.load_image("back.png"), self.back)), ] if isOnline == 1: print("111") menu.create_menu(items,selected_effect=zoom_in(),unselected_effect=zoom_out()) self.add(menu)
def __init__(self, name, position=[ common.visibleSize["width"] / 2 + 5, common.visibleSize["height"] * 9 / 10 ], type=""): super(InputBox, self).__init__() self.pos_x = position[0] self.pos_y = position[1] self.menu_valign = CENTER self.menu_halign = CENTER items = [(ImageMenuItem(common.load_image("inputbox.png"), None))] self.create_menu(items) width, height = director.get_window_size() for idx, i in enumerate(self.children): item = i[1] item.transform_anchor = (self.pos_x - 8, self.pos_y - 3) item.generateWidgets(self.pos_x - 8, self.pos_y - 3, self.font_item, self.font_item_selected) self.str = "" self.name = name self.is_selected = 0 self.type = type
def setup(self): self.background = common.load_image(constants.illustration_002)[0] #position of the red container self.informative_text() position_red = [(20,560), (70,560), (120,560), \ (170,560), (220,560), (270,560), \ (320, 560)] #position of the green container position_green = [ (500,560), (550,560), (600,560), \ (650,560), (700,560)] self.hand = Hand() self.icons = pygame.sprite.Group() self.icons.add([Icons('stop')]) self.letters = self.groupLetters() container_red = self.groupContainer(position_red, 'higiene', 'red') container_green = self.groupContainer(position_green, 'salud', 'green') self.containers = pygame.sprite.Group() self.containers.add([container_red, container_green]) self.sprites = pygame.sprite.OrderedUpdates() self.sprites.add([self.icons, self.containers, self.letters, \ self.hand]) pygame.mouse.set_visible( False ) #oculntar el puntero del mouse self.button_down = 0 pos = pygame.mouse.get_pos() self.hand.update(pos) self.screen.blit(self.background, (0,0)) self.sprites.draw(self.screen) pygame.display.update() pygame.event.clear()
def __init__(self, image, center_x, center_y, half_width, half_height): super(CollidableRectSprite, self).__init__(common.load_image(image + ".png")) self.position = (center_x, center_y) self.cshape = AARectShape(Vector2(center_x, center_y), half_width, half_height) self.name = image
def show_losersjuegos_logo(self, dt): images = [ common.load_image('presents/frame_1.png'), common.load_image('presents/frame_2.png'), ] animation = pyglet.image.Animation.from_image_sequence(images, 0.10) self.logo = ActionSprite(animation) self.logo.opacity = 0 self.logo.x = 0 self.logo.y = 0 self.logo.do(FadeIn(2)) self.sprites.insert(0, self.logo) self.name.set_text('Thanks !', 'http://www.losersjuegos.com.ar') self.name.set_position(180, 400)
def _load(self, index): if self.pos in [7, 9]: path = 'back_robot' else: path = 'robot' return common.load_image('%s/%d.png' %(path, index))
def __init__(self): super(leftArrowMenu, self).__init__() self.font_item = { 'font_name': 'Arial', 'font_size': 32, 'bold': False, 'italic': False, 'anchor_y': 'center', 'anchor_x': 'right', 'color': (255, 255, 255, 255), 'dpi': 96, } self.font_item_selected = { 'font_name': 'Arial', 'font_size': 32, 'bold': False, 'italic': False, 'anchor_y': 'center', 'anchor_x': 'right', 'color': (255, 255, 255, 255), 'dpi': 96, } self.menu_valign = CENTER self.menu_halign = LEFT items = [ (ImageMenuItem(common.load_image("button_left.png"), self.goLeft)), ] self.create_menu(items)
def _load_images(self): circle = common.load_image('mouse/circle.png') circle.anchor_x = circle.width / 2 circle.anchor_y = circle.height / 2 background = common.load_image('mouse/background.png') background.anchor_x = background.width / 2 background.anchor_y = background.height / 2 cursor = common.load_image('mouse/cursor.png') cursor.anchor_x = cursor.width / 2 cursor.anchor_y = cursor.height / 2 self.circle = circle self.cursor = cursor self.background = background
def __init__(self): sprite.Sprite.__init__(self) self.image, self.rect = common.load_image(constants.cursor_filename) pos = constants.screen_mode[0] / 2.0, constants.screen_mode[1] / 2.0 self.rect.width = 1 self.rect.height = 1 mouse.set_pos(pos)
def __init__(self, textline, pos=(0,0)): Sprite.__init__(self) image_name = os.path.join(constants.data_folder, "healthy", textline + ".png") self.image, self.rect = common.load_image(image_name) self.rect.center = pos self.orig = pos self.name = textline
def __init__(self, screen, pos): Sprite.__init__(self) path = os.path.join(constants.images_labyrinth, "ball.png") self.image, self.rect = common.load_image(path) self.rect.move_ip(pos) self.pos = (0,0) self.move_ball = 5 self.screen = screen
def _create_sprites(self): sky = ActionSprite(common.load_image('intro/sky2.png')) sky.y = 118 sky.do(Move((-100, 0), 6)) intro_1 = ActionSprite(common.load_image('intro/intro_1.png')) intro_1.x = 95 intro_1.y = 118 intro_1.scale = 1.2 intro_1.do(Scale(1.1, 6)) run = ActionSprite(common.load_image('intro/run.png')) run.x = 400 run.y = 80 run.do(Scale(1.1, 6)) self.sprites = [sky, intro_1, run]