Ejemplo n.º 1
0
        def start_game(self):
            try:

                if self.reRun:
                    if self.death_text != None:
                        self.Scen.removeItem(self.death_text)
                        self.death_text = None
                    if self.win_text != None:
                        self.Scen.removeItem(self.win_text)
                        self.win_text = None
                    self.test_player.setY(-60)
                    self.test_player = Player(self.player_specs)
                    self.backGround = Background(-1, -1, self.window_width + 1,
                                                 self.window_height + 1)
                    self.skyObject = self.backGround.skyObj
                    self.bottom_lava = Lava(-1, self.window_height - 50,
                                            self.window_width + 1, 51)
                    self.test_platform = Platform(0, 300,
                                                  self.window_width - 100, 40)
                    self.test_platform_2 = Platform(self.window_width - 50,
                                                    320, 100, 35)
                    self.init_game_screen()
                    self.completion = 0
                    self.goal_added = False

                self.view.setScene(self.scene)

                self.game_timer.start(10)
            except Exception as r:
                print('JJJJJJJJ')
Ejemplo n.º 2
0
    def create_platforms(self):
        platform_x = random.randint(SC.platform_range[0], SC.platform_range[1])

        platform_position1 = (platform_x, SC.platform_start_y)
        platform_position2 = (platform_x + SC.platform_width +
                              SC.platform_gap_size, SC.platform_start_y)

        hammer_x = random.randint(SC.platform_range[0], SC.platform_range[1])
        hammer_position1 = (platform_x + .9 * SC.platform_width -
                            Hammer.default_width,
                            SC.platform_start_y + SC.platform_height)

        hammer_position2 = (platform_x + SC.platform_width +
                            SC.platform_gap_size + .1 * SC.platform_width,
                            SC.platform_start_y + SC.platform_height)

        first_platform = Platform(platform_position1, SC.platform_velocity)
        self.platforms.append(first_platform)
        second_platform = Platform(platform_position2, SC.platform_velocity)
        self.platforms.append(second_platform)

        first_hammer = Hammer(hammer_position1, SC.platform_velocity)
        self.hammers.append(first_hammer)
        second_hammer = Hammer(hammer_position2, SC.platform_velocity)
        self.hammers.append(second_hammer)
Ejemplo n.º 3
0
    def __init__(self, parent):
        Location.__init__(self, parent, menu_background)
        
        pygame.mixer.music.load(music)
        pygame.mixer.music.play(-1)
        
        pygame.mouse.set_visible(1)
        pygame.key.set_repeat(0)


        self.start_button = PlayButton(240, 300)

        self.surfaces = []
        self.controls = pygame.sprite.Group()
        self.controls.add(self.start_button)
        
        self.platform1 = Platform(120, 600)
        self.platform2 = Platform(240, 490)
        self.platform3 = Platform(360, 550)
        self.doodle = Doodle()

        self.animation = pygame.sprite.Group()
        self.animation.add(self.platform1)
        self.animation.add(self.platform2)
        self.animation.add(self.platform3)
        self.animation.add(self.doodle)

        self.window.blit(self.background, (0, 0))
Ejemplo n.º 4
0
 def load_platforms(self):
     platforms = set()
     if self.stageName == 'first':
         left = Platform(470, 490, 246, 10, platforms, 0)  #530
         right = Platform(1196, 490, 246, 10, platforms, 0)
         top = Platform(833, 330, 246, 10, platforms, 0)  # 408
         floor = Platform(290, 710, 1360, 18, platforms, 1)
         return platforms
Ejemplo n.º 5
0
 def __init__(self):
     setWindowPositionCentered(self.width, self.height)
     self.window = pygame.display.set_mode((self.width, self.height))
     pygame.display.set_caption("Ping Pong!")
     pygame.font.init()
     
     # Instantiates components
     self.ball = Ball(self.window)
     platformsX = (350 - 60) // 2
     self.topPlatform = Platform(self.window, platformsX, 0)
     self.bottomPlatform = Platform(self.window, platformsX, 480)
     self.score = Score(self.window)
Ejemplo n.º 6
0
    def new(self):
        self.all_sprites = pg.sprite.Group()
        self.platforms = pg.sprite.Group()
        self.saws = pg.sprite.Group()

        plts_conf, plr_conf, saw_conf, fl_saw_conf, prtl_conf = self.create_level(
            levels.level1)

        self.player = Player(*plr_conf, self)
        self.all_sprites.add(self.player)

        for plt in plts_conf:
            p = Platform(*plt)
            self.all_sprites.add(p)
            self.platforms.add(p)

        for saw in saw_conf:
            s = Saw(*saw)
            self.all_sprites.add(s)
            self.saws.add(s)

        for fl_saw in fl_saw_conf:
            s = FlyingSaw(*fl_saw, self.platforms)
            self.all_sprites.add(s)
            self.saws.add(s)

        self.portal = Portal(*prtl_conf)
        self.all_sprites.add(self.portal)

        self.run()
Ejemplo n.º 7
0
 def get_sprites(self):
     platforms_group = pygame.sprite.Group()
     for x in range(len(self.level_array)):
         for y in range(len(self.level_array[0])):
             if self.level_array[x, y] == 1:
                 platforms_group.add(Platform(y * 20, x * 20, 20, 20, self))
     return platforms_group
Ejemplo n.º 8
0
    def load_map(self, folder, name):
        #This should be read from layout.txt
        self.spawn_x = 50
        self.spawn_y = 50

        #opens an .oel file and create map from it
        tree = ET.parse(os.path.join('data', 'maps', folder, name))
        root = tree.getroot()
        self.camera.map_w = int(root.attrib['width'])
        self.camera.map_h = int(root.attrib['height'])
        for r in root:

            for o in r:
                if o.tag == 'tile':
                    size = 25
                    target = Platform(
                        int(o.attrib['x']) * size,
                        int(o.attrib['y']) * size, int(o.attrib['tx']),
                        int(o.attrib['ty']), size)
                    self.platforms.append(target)

                else:

                    target = Object(int(o.attrib['x']),
                                    int(o.attrib['y']),
                                    o.tag + '.png',
                                    colorkey=None,
                                    folder='maps')
                    target.set_message('This is a ' + o.tag)
                    self.objects.append(target)

                self.entity.append(target)

        return self
Ejemplo n.º 9
0
    def randomPlatform(self, top=True):
        x = random.randint(0, screen_width - platform_width)
        bad_y = []

        for spr in self.allsprites:
            bad_y.append((spr.y - platform_y_padding, spr.y + platform_y_padding + spr.rect.height))
    
        good = 0
        while not good:
            if top:
                y = random.randint(-100, 100)
            else:
                y = random.randint(0, screen_height)

            good = 1
            for bad_y_item in bad_y:
                if bad_y_item[0] <= y <= bad_y_item[1]:
                    good = 0
                    break

        dig = random.randint(0, 100)
        if dig < 35:
            return MovingPlatform(x, y)
        elif 35 <= dig < 50:
            return CrashingPlatform(x, y) 
        else:
            return Platform(x, y)
Ejemplo n.º 10
0
def create_object(ch, x, y):
    if ch in ['1', '2', '3', '4', '5']:
        obj = Jelly(ord(ch) - ord('1'), x, y)
        gfw.world.add(gfw.layer.item, obj)
        #print('creating Jelly', x, y)
    elif ch in ['O', 'P']:
        dy = 1 if ch == 'Q' else 3
        y -= dy * BLOCK_SIZE // 2
        x -= BLOCK_SIZE // 2
        obj = Platform(ord(ch) - ord('O'), x, y)
        gfw.world.add(gfw.layer.platform, obj)
        #print('creating Platform', x, y)
    elif ch in ['B']:
        pass
    else:
        ao = factory.create(ch, x, y)
        if ao is None:
            global ignore_char_map
            if ch not in ignore_char_map:
                print("Error? I don't know about: '%s'" % ch)
                ignore_char_map |= {ch}
            return
        l, b, r, t = ao.get_bb()
        ao.pass_wh(r - l, t - b)
        gfw.world.add(gfw.layer.enemy, ao)
Ejemplo n.º 11
0
    def __init__(self, player):
        teleporter = Teleporter()
        # Call the parent constructor
        Level.__init__(self, player)

        self.level_limit = 1500

        # Array with type of platform, and x, y location of the platform.
        level = [
            [210, 70, 450, 770],
            [210, 70, 850, 520],
            [210, 70, 1000, 420],
            [210, 70, 1120, 580],
        ]

        # Go through the array above and add platforms
        for platform in level:
            block = Platform(platform[0], platform[1])
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            self.platform_list.add(block)
        teleporter.rect.x = self.level_limit
        teleporter.rect.y = 50
        self.teleporter_list.add(teleporter)
Ejemplo n.º 12
0
 def __init__(self, player):
     teleporter = Teleporter()
     # Call the parent constructor
     Level.__init__(self, player)
     self.level_limit = 2000
     # Array with width, height, x, and y of platform
     level = [[210, 40, 500, 650], [210, 40, 900, 600],
              [210, 40, 1200, 550], [210, 40, 1400, 450],
              [1000, 40, 2010, 795], [1000, 40, 2010, 795]]
     # Go through the array above and add platforms
     for platform in level:
         block = Platform(platform[0], platform[1])
         block.rect.x = platform[2]
         block.rect.y = platform[3]
         block.player = self.player
         self.platform_list.add(block)
         teleporter.rect.x = 1000
         teleporter.rect.y = 620
         self.teleporter_list.add(teleporter)
     # X and Y coordinates for generating enemies
     enemy_list = []
     enemy_level = [[230, 420], [500, 420], [800, 300]]
     for n in enemy_level:
         enemy = Enemy()
         enemy.rect.x = n[0]
         enemy.rect.y = n[1]
         self.enemy_list.add(enemy)
     #X and Y for the score chests
     chest_list = []
     chest_level = [[300, 100], [550, 300]]
     for n in chest_level:
         chest = Chest()
         chest.rect.x = n[0]
         chest.rect.y = n[1]
         self.chest_list.add(chest)
Ejemplo n.º 13
0
def setPlatform(x,y,size, image):
    for i in range(size):
        platforms.append( Platform())
        platforms[len(platforms)-1].set_dimensions(50, 50) 
        platforms[len(platforms)-1].x_pos = x+i*50
        platforms[len(platforms)-1].y_pos = y
        platformImages.append(image)
Ejemplo n.º 14
0
def platsassemble(levelnow, levelindex):
    for p in range(len(levelnow)):
        platform = Platform(levelnow[p])
        platform.harvesthour(mapsizes[levelindex][0], mapsizes[levelindex][1])
        wall_list.add(platform)
        sprite_list.add(platform)
        print(str(levelnow[p]))
Ejemplo n.º 15
0
def generating_platforms(group, going):
    """Генерация платформ"""
    y = 5
    while y < HEIGHT:
        generate_platform(group, y)
        y += going
    Platform(group, 200, 600)
    def __init__(self, world):
        self.__world = world
        self.__platforms = pg.sprite.Group()
        self.__items = pg.sprite.Group()
        self.__exit = pg.sprite.Group()
        self.__bg = (BLUE)

        row_count = 0
        for row in self.__world:
            col_count = 0
            for tile in row:
                if tile == 1:
                    wall = Platform(col_count * TILE_SIZE_W,
                                    row_count * TILE_SIZE_H, TILE_SIZE_W,
                                    TILE_SIZE_H, BLUE)
                    self.__platforms.add(wall)
                    #tile = (wall.image, wall.rect)
                elif tile == 2:
                    grogu = Key(col_count * TILE_SIZE_W,
                                row_count * TILE_SIZE_H, 20, 20, GREEN)
                    self.__items.add(grogu)
                elif tile == 3:
                    ship = Extraction_point(col_count * TILE_SIZE_W,
                                            row_count * TILE_SIZE_H,
                                            TILE_SIZE_W, TILE_SIZE_H, PURPLE)
                    self.__exit.add(ship)
                col_count += 1
            row_count += 1

        self.__spawn_point = ((WIDTH, HEIGHT))
Ejemplo n.º 17
0
def run_game():
    #Инициализация игры и создание объекта на экране
    #timer = pygame.time.Clock()
    pygame.init()
    ai_setting = Settings()
    screen = pygame.display.set_mode(
        (ai_setting.screen_width, ai_setting.screen_height))
    pygame.display.set_caption("Arcanoid")
    platform = Platform(ai_setting, screen)
    bricks = Group()
    ball = Ball(ai_setting, screen, platform, bricks)

    #блок музыки - начало игры
    music_file = "mus/title.mp3"
    pygame.mixer.music.load(music_file)
    pygame.mixer.music.play()  #Проигрываем5
    #

    # Create the wall of bricks.
    gameF.create_wall(ai_setting, screen, platform, bricks)

    #Запуск основного цикла в игре
    while True:
        #    timer.tick(240)
        if (ai_setting.life == 0):

            break
        gameF.checkEvents(platform)  #Функция реагирования на события
        platform.update()  #Обновление платформы
        ball.update()  #Обновление мяча

        gameF.updateScreen(ai_setting, screen, platform, ball,
                           bricks)  #Функция перерисовки экрана
Ejemplo n.º 18
0
 def __init__(self, player):
     '''call parent constructor'''
     Level.__init__(self, player)
     self.level_limit = -10000
     '''array with with width, height, x, and y of platform'''
     level = [
         [210, 70, 500, 500],
         [210, 70, 800, 400],
         [210, 70, 1120, 280],
         [210, 70, 2000, 300],
         [210, 70, 1800, 500],
         [210, 70, 2900, 400],
     ]
     walls = [[70, 600, 0, 0], [70, 600, 3200, 0]]
     '''go through the array and add platforms'''
     for platform in level:
         block = Platform(platform[0], platform[1])
         block.rect.x = platform[2]
         block.rect.y = platform[3]
         block.player = self.player
         self.platform_list.add(block)
     '''do the same for level walls'''
     for wall in walls:
         block = Wall(wall[0], wall[1])
         block.rect.x = wall[2]
         block.rect.y = wall[3]
         block.player = self.player
         self.walls_list.add(block)
     '''add enemies to level'''
     self.enemy_list.add(Enemy())
     self.enemy_list.add(Enemy())
Ejemplo n.º 19
0
def load_map_level(map_name, x_player, y_player):
    global sprites, platforms, level, hero, camera

    sprites = pygame.sprite.Group()
    platforms = list()
    level = load_level(map_name)
    hero = Player(x_player, y_player)
    sprites.add(hero)
    x = 0
    y = 0
    for row in level:
        for col in row:
            if col == "#":
                pf = Platform(x, y)
                sprites.add(pf)
                platforms.append(pf)
            elif col == '@':
                fin = Final(x, y)
                sprites.add(fin)
                platforms.append(fin)
            x += PLATFORM_WIDTH
        y += PLATFORM_HEIGHT
        x = 0

    total_level_width = len(level[0]) * PLATFORM_WIDTH
    total_level_height = len(level) * PLATFORM_HEIGHT
    camera = Camera(camera_configure, total_level_width, total_level_height)
Ejemplo n.º 20
0
    def __init__(self):
        pygame.init()

        self.screen = Screen()
        self.clock = pygame.time.Clock()
        self.doodler = Doodler(Screen.WIDTH / 2, Screen.HEIGHT / 2)

        self.p1 = Platform(Screen.WIDTH / 2, Screen.HEIGHT / 2 + 130)
Ejemplo n.º 21
0
 def __init__(self):
     self.win = Window((Game.win_width, Game.win_height))
     self.sky = Sky(Game.win_width, Game.win_height)
     self.platform = Platform(Game.win_width, 96, Game.win_height - 96 - 30)
     self.dino = None
     self.enemy_velocity = 250
     self.score = 0
     self.create_handlers()
     self.enemies = []
Ejemplo n.º 22
0
 def __init__(self):
     # initialize pygame and create window
     pygame.init()
     self.screen = pygame.display.set_mode((WIDTH, HEIGHT))
     pygame.display.set_caption("My Game")
     self.clock = pygame.time.Clock()
     self.running = True
     self.spritesheet = Spritesheet(
         os.path.join(img_folder, "p1_spritesheet.png"))
     self.ground = Platform(0, HEIGHT - 40, WIDTH, 40, self)
Ejemplo n.º 23
0
def init(p1_actions):
    platforms.empty()
    global player
    for i in range(height // 100):
        for j in range(width // 420):
            platform = Platform((random.randint(5, (width - 50) // 10) * 10,
                                 120 * j + random.randint(0, 4) * 100), 'images/platform.png', 70, 40)
            platforms.add(platform)
    player = Player((platforms.sprites()[-1].rect.centerx, platforms.sprites()[-1].rect.centery - 300), p1_actions)
    sprites.add(player)
Ejemplo n.º 24
0
    def crete_platforms(self):
        ws_platform_static = [[80, 35, 0, 175], [40, 30, 80, 200],
                              [40, 30, 120, 220], [220, 15, 120, 220],
                              [275, 75, 370, 175], [115, 250, 640, 0],
                              [50, 40, 0, 500], [380, 40, 50, 540],
                              [350, 50, 430, 500], [180, 100, 750, 395],
                              [150, 50, 930, 430], [50, 50, 1080, 395]]

        for ws in ws_platform_static:
            platform_object = Platform(*ws)
            self.set_of_platforms.add(platform_object)
Ejemplo n.º 25
0
def frametest(display):

    # frames = (VolumeAmountFrame, TextFrame, MenuFrame, SourceIconFrame, VUFrame, SpectrumFrame)   # create a list of all screens to test one by one
    scaled_frames = (RecordingScreen)
    # frames = (VU2chFrame, VUV2chFrame, Spectrum2chFrame)
    limits = ((0.3,"white"), (0.6,"grey"), (0.8,"red"))
    events          = Events(( 'Platform', 'CtrlTurn', 'CtrlPress', 'VolKnob', 'Audio', 'RemotePress'))
    p = Platform(events)
    if display=='int':
        d = p.internaldisplay
    else:
        d = p.frontdisplay

    geo   = Geometry(d.boundary)
    geo.scale( (1.0, 1.0) )   # make the  Screen scale width
    # for f in scaled_frames:
    # f = VUV2chFrame
    # # a = f(geo.coords, p, d, 'left', limits )
    # a = f(geo.coords, p, d, 0.3 )

    # f = SpectrumFrame
    # a = f(geo.coords, p, d, 'left', 0.4 )
    # print( "%s initialised: %s" % (type(f).__name__, a) )
    # f = Spectrum2chFrame
    # a = f(geo.coords, p, d, 1.0 )
    # print( "%s initialised: %s" % (type(f).__name__, a) )

    # f = VUMeterAFrame
    # a = f(geo.coords, p, d, 'left', 0.5 )

    # a = testScreen1(p, d)
    # print( "%s initialised: %s" % (type(f).__name__, a) )

    # import math
    # a = MetersAScreen(p, d)
    # d.draw(a)
    # for _ in range(0, 10):
    #     for x in range(0,360,10):
    #
    #         p.vu['left'] = math.pow(math.sin(x),2)
    #         p.vu['right'] = math.pow(math.cos(x),2)
    #         print("x =",x, p.vu)
    #         d.draw(a)
    #         time.sleep(0.1)
    #
    # print( "Drawn: %s" % ( a) )
    # time.sleep(5)

    #
    #
    a = RecordingScreen(p, d)
    print( "RecordingScreen initialised: ", a, p )
    d.draw(a)
    time.sleep(5)
Ejemplo n.º 26
0
def playgame(screen_height, screen_width, running):
    turtle.listen()
    for i in range(number_of_platforms):
        X = random.randint(-screen_width, screen_width)
        Y = random.randint(-screen_height, screen_height)

        new_plat = Platform(X, Y, plat_width, plat_height, plat_dy)
        platforms.append(new_plat)

    turtle.ontimer(move_platforms_down(), 3 * 1000)
    while running:
        # print("HERE")
        move_platforms_down()
        player.falling_down(screen_width, screen_height)
        # player.move()
        for platform in platforms:
            if collide(platform):
                if player.ycor() > platform.ycor():
                    player.dy = platform.dy
                else:
                    running = False

        if player.ycor() < -screen_height:
            running = False

        if screen_width != int(
                turtle.getcanvas().winfo_width() / 2) or screen_height != int(
                    turtle.getcanvas().winfo_height() / 2):
            screen_width = int(turtle.getcanvas().winfo_width() / 2)
            screen_height = int(turtle.getcanvas().winfo_height() / 2)

        if score == 10:
            turtle.Screen().bgpic("clouds(1).gif")
        if score == 20:
            turtle.Screen().bgpic("galaxy.gif")
        if score == 30:
            turtle.reset()
            turtle.ht()
            turtle.pu()
            turtle.write("Congratulations!, you are now a Y1 MEET student",
                         font=("Arial", 10, "normal"),
                         align="center")
            # turtle.write("click the "space" bar to continue!", font=("Arial",100,"normal"), align="center")
            #turtle.listen()
            turtle.onkey(win_game, "space")

            # turtle.clear()
            # turtle.ht()
            # turtle.write("MEET your coordinators", font=("Arial", 100, "normal"), align="center")
            # turtle.write("click the "space" bar to continue!", font=("Arial",100,"normal"), align=(0,-100)
            # turtle.onkey(win_game, "space")

        turtle.update()
Ejemplo n.º 27
0
 def create_ghouls(self):
     ws_platform_static = [[80, 35, 0, 175], [40, 30, 80, 200],
                           [40, 30, 120, 220], [220, 15, 120, 220],
                           [250, 40, 370, 175], [115, 150, 640, 100],
                           [50, 40, 0, 500], [380, 40, 50, 540],
                           [300, 50, 430, 500], [180, 100, 750, 395],
                           [150, 50, 930, 430], [50, 50, 1080, 395]]
     for ws in ws_platform_static:
         platform = Platform(*ws)
         self.set_of_platforms.add(platform)
         ghoul = Ghoul(GHOUL_WALK_R[0], GHOUL_WALK_R, GHOUL_WALK_L,
                       ENEMY_DEATH, platform, 2)
         self.set_of_enemies.add(ghoul)
Ejemplo n.º 28
0
def frametest():
    p = Platform()
    a = testScreen(p, p.frontdisplay)
    # a = VUScreen(p, p.frontdisplay, 0.5)
    l = p.chLogic()
    print( "testScreen initialised: ", a, p )
    print"logic ", l
    for k in l:

        p.activeSource= l[k]
        p.frontdisplay.draw(a.draw)
        time.sleep(3)

    print( "testScreen draw executed")
Ejemplo n.º 29
0
def main():
    parser = argparse.ArgumentParser(
        description=
        "Restore a Linux system to a previous state in terms of applications installed and configuration files.",
        add_help=True)
    main_command = parser.add_mutually_exclusive_group()
    main_command.add_argument(
        "--install",
        nargs="+",
        type=str,
        choices=System.app_classes,
        help="Install a class of apps, and restore their configuration files.")
    main_command.add_argument(
        "--backup",
        nargs="+",
        type=str,
        choices=System.app_classes,
        help="Initiate backup to the frontdown directory.")
    main_command.add_argument(
        "--restore",
        nargs="+",
        type=str,
        choices=System.app_classes,
        help="Initiate a restore from the frontdown directory.")
    args = parser.parse_args()

    app_classes = args.install or args.backup or args.restore

    if not app_classes:
        parser.print_help()
        exit(0)

    if "all" in app_classes:
        app_classes = filter(lambda x: x != "all", System.app_classes)

    app_configs = map(AppConfigParser.parse_class_directory, app_classes)

    if args.install:
        apps_installer = AppsInstaller(Platform().installer)
        map(apps_installer.install_class, app_classes)
        exit(0)

    for config_class in app_configs:
        for configs in config_class:
            for app_config in configs:
                if args.restore:
                    app_config.restore()
                elif args.backup:
                    app_config.backup()
    exit(0)
Ejemplo n.º 30
0
 def __init__(self,window):
     """Constructor"""
     self.window = window
     self.fps = 30
     
     #Initialize player one and player two. 
     self.playerone = Person(0,
                             575-64,
                             Characters.megaman_right.value["hp"],
                             (500-64,575-64),
                             self.window,
                             Characters.megaman_right,
                             Direction.right,
                             6,
                             Controls.WASD,
                             Characters.megaman_right.value["spd"]) 
     self.playertwo = Person(900,
                             575-64,
                             Characters.megaman_left.value["hp"],
                             (500,575-64),
                             self.window,
                             Characters.megaman_left,
                             Direction.left,
                             6,
                             Controls.OKLColon,
                             Characters.megaman_left.value["spd"])
     
     #Initialize platforms.
     self.platforms = [Platform(275,self.window,platform),
                       Platform(425,self.window,platform),
                       Platform(575,self.window,platform)]
 
     #Initialize clock
     self.clock = pygame.time.Clock()
     
     #Initialize menu
     self.menu = Mainmenu(self.window)