Ejemplo n.º 1
0
 def __init__(self):
     self.guess = 2
     self.end = False
     self.time = 0
     player = (0, 11 * 50, 36)
     base = (10 * 50, 14 * 50)
     self.levels = [Screen(self, screen, (),
                           (365, 459, 330, 111, (255, 255, 255), 'Начать игру'),
                           (724, 459, 330, 111, (255, 255, 255), 'Выход')),
                    Level(self, screen, wallist, brwalls, snowlist, snowmanlist, player, base),
                    Screen(self, screen, (("Первый уровень пройден", 400, 300, (250, 250, 0)),),
                           (365, 459, 330, 111, (255, 255, 255), 'Продолжить'),
                           (724, 459, 330, 111, (255, 255, 255), 'Выход')),
                    Level(self, screen, wallist2, brwalls2, snowlist2, snowmanlist2, player, base),
                    Screen(self, screen, (("Второй уровень пройден", 400, 300, (250, 250, 0)),),
                           (365, 459, 330, 111, (255, 255, 255), 'Продолжить'),
                           (724, 459, 330, 111, (255, 255, 255), 'Выход')),
                    Level(self, screen, wallist3, brwalls3, snowlist3, snowmanlist3, player, base),
                    Screen(self, screen, (("Третий уровень пройден", 400, 300, (250, 250, 0)),),
                           (365, 459, 330, 111, (255, 255, 255), 'Продолжить'),
                           (724, 459, 330, 111, (255, 255, 255), 'Выход')),
                    Level(self, screen, wallist4, brwalls4, snowlist4, snowmanlist4, player, base),
                    Screen(self, screen, (("Четвёртый уровень пройден", 400, 300, (250, 250, 0)),),
                           (365, 459, 330, 111, (255, 255, 255), 'Продолжить'),
                           (724, 459, 330, 111, (255, 255, 255), 'Выход')),
                    Level(self, screen, [], [], snowlist5, [], player, (1000, 1000)),
                    Screen(self, screen, (("Игра окончена! Вы победили", 400, 300, (250, 250, 0)),),
                           (365, 459, 330, 111, (255, 255, 255), 'В главное меню'),
                           (724, 459, 330, 111, (255, 255, 255), 'Выход')),
                    Screen(self, screen, (("Вы проиграли. Удачи в следующий раз", 400, 300, (250, 250, 0)),),
                           (365, 459, 330, 111, (255, 255, 255), 'В главное меню'),
                           (724, 459, 330, 111, (255, 255, 255), 'Выход'))]
Ejemplo n.º 2
0
def create_levels(player_sprite):
    level_list = []

    level = Level()
    level.grid = get_level_1_array()
    level_list.append(level)
    level.background_color = arcade.color.BISTRE

    level = Level()
    level.grid = get_level_2_array()
    level_list.append(level)
    level.background_color = arcade.color.BLACK_OLIVE

    level = Level()
    level.grid = get_level_3_array()
    level_list.append(level)
    level.background_color = arcade.color.EERIE_BLACK

    create_walls(level_list)

    add_level_1_creatures(level_list[0])
    add_level_2_creatures(level_list[1])
    add_level_3_creatures(level_list[2], player_sprite)

    create_stairs(level_list)

    return level_list
Ejemplo n.º 3
0
 def generate_next_level(self):
     if self.current_level < (self.config['game']['levels'] - 1):
         return Level(self.config['level']).generate().with_stairs_up(
             self.hero).with_stairs_down()
     else:
         return Level(self.config['level']).generate().with_stairs_up(
             self.hero)
Ejemplo n.º 4
0
    def __init__(self, director, background=(0, 0, 0)):
        super().__init__(director)

        self.background = background

        self.level1 = Level('assets/levels/level1.json', director.screen)
        self.level1_sub_level = Level('assets/levels/level1_sub_level.json',
                                      director.screen)

        self.level = self.level1
Ejemplo n.º 5
0
    def __init__(self):
        pygame.init()
        pygame.mixer.init()
        pygame.joystick.init()

        self.screen = pygame.display.set_mode(
            (800, 600),
            pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE)
        SCREEN_SIZE = self.screen.get_size()
        pygame.display.set_caption("KISI: The Game")

        self.gamepads = []
        self.yygamepad()

        self.LowQuality = True

        self.clock = pygame.time.Clock()

        self.yymenu = YYMenu()
        dataloader.yyload(self)

        self.hiscores = hiscores.HiScores()
        self.hiscores.load("hiscores.txt")

        self.pressedButtons = {
            pygame.K_UP: False,
            pygame.K_DOWN: False,
            pygame.K_LEFT: False,
            pygame.K_RIGHT: False,
            pygame.K_ESCAPE: False
        }
        self.konorPress = False

        self.DaciuTexty = []
        self.ComboText = None
        self.bonusy = []

        self.levels = [
            Level('data/lev10.txt'),
            Level('data/lev3.txt'),
            Level('data/lev2.txt'),
            Level('data/lev4.txt'),
            Level('data/lev5.txt'),
            Level('data/lev6.txt'),
            Level('data/lev7.txt'),
            Level('data/lev8.txt'),
            Level('data/lev9.txt')
        ]
        self.level = 0

        self.yydaciurs()

        self.rungame = True

        if pygame.font:
            self.font = pygame.font.Font(None, 30)
        else:
            self.font = None

        self.state = STATE_MENU
Ejemplo n.º 6
0
    def simpleswap(self, yamldata):
        x = self.r.randint(1, 99)
        y = self.r.randint(1, 99)
        print(x)
        print(y)
        levelx = Level()
        levely = Level()

        for i, j in yamldata.items():
            foundx = False
            foundy = False
            for k, l in j.items():
                if x == l['Level']:
                    print('found x')
                    foundx = True
                    self.storelevelvalue(l, levelx)
                    t1 = l
                    print(t1)
                if y == l['Level']:
                    print('found Y')
                    foundy = True
                    self.storelevelvalue(l, levely)
                    t2 = l
                    print(t2)
                ##t1 is the level found with X and t2 is level found with Y and just swapping them
                if foundx == True and foundy == True:
                    if not self.skipAp:
                        t1['Ap'] = levely.ap
                        t2['Ap'] = levelx.ap
                    if not self.skipDef:
                        t1['Defense'] = levely.defence
                        t2['Defense'] = levelx.defence
                    if not self.skipExp:
                        t1['Exp'] = levely.exp
                        t2['Exp'] = levelx.exp
                    if not self.skipMag:
                        t1['Magic'] = levely.magic
                        t2['Magic'] = levelx.magic
                    if not self.skipLvl:
                        t1['Level'] = y
                        t2['Level'] = x
                    if not self.skipSh:
                        t1['ShieldAbility'] = levely.shield
                        t2['ShieldAbility'] = levelx.shield
                    if not self.skipSt:
                        t1['StaffAbility'] = levely.staff
                        t2['StaffAbility'] = levelx.staff
                    if not self.skipStr:
                        t1['Strength'] = levely.strength
                        t2['Strength'] = levelx.strength
                    if not self.skipsw:
                        t1['SwordAbility'] = levely.sword
                        t2['SwordAbility'] = levelx.sword
                    break
def run_game():
    # Initialize pygame, settings, and screen object.
    pygame.init()
    settings = Settings()
    clock = pygame.time.Clock()
    clock.tick(60)

    screen = pygame.display.set_mode(
        (settings.screen_width, settings.screen_height))

    pygame.display.set_caption("Oh My Blocks")

    # Make the Play button.
    play_button = Button(settings, screen, "Play")

    # Make a ship, a group of bullets and blocks.
    ship = Ship(settings, screen)
    bullets = Group()
    blocks = Group()

    level = Level(settings, screen, blocks)
    level.getLevel()

    while True:

        game.check_events(settings, screen, ship, bullets)
        game.update_bullets(settings, screen, ship, blocks, bullets)
        game.update_screen(settings, screen, play_button, blocks, ship,
                           bullets)
Ejemplo n.º 8
0
def main():
    app = QApplication(sys.argv)
    frog = Frog(Point(200, 400))
    level = Level(1, Point(0, 0), Point(700, 700))
    game = Game(frog, level)
    g = Graphics(game, Point(900, 900))
    sys.exit(app.exec_())
Ejemplo n.º 9
0
def main():
    app = QApplication(sys.argv)
    frog = Frog(Point(900, 300))
    level = Level(5, Point(100, 100), Point(700, 700))
    game = Game(frog, level)
    a = MainGame(1700, 1000, game)
    sys.exit(app.exec_())
Ejemplo n.º 10
0
    def __init__(self, server_port, full_screen=False):
        pygame.init()
        infoObject = pygame.display.Info()
        pygame.display.set_caption("Tank War")
        pygame.key.set_repeat(10)

        self.level = Level()
        self.mode = 'Single Player'
        self.players = []
        self.available_servers = []
        self.timer = pygame.time.Clock()
        self.font = pygame.font.Font('freesansbold.ttf', 36)
        self.small_font = pygame.font.Font('freesansbold.ttf', 24)
        self.tiny_font = pygame.font.Font('freesansbold.ttf', 18)
        self.active_menu = 'Main menu'

        self.network = Network(server_port, self)
        self.start_game = False

        self.enemies = pygame.sprite.Group()
        self.no_enemies = 2

        if full_screen == True:
            self.screen = pygame.display.set_mode(
                (infoObject.current_w, infoObject.current_h))
        else:
            self.screen = pygame.display.set_mode((WIDTH, HEIGHT))
Ejemplo n.º 11
0
    def __init__(self, levels, template='default.txt'):
        self._parked = {}
        self._levels = []

        for i in xrange(levels):
            new_level = Level(template=template)
            self._levels.append(new_level)
Ejemplo n.º 12
0
    def setup(self):
        scr_size = self.app.screen.get_size()

        self.level = Level(scr_size)
        self.level.restart()

        self.cheat_idx = 0

        self.background = TiledImage(load_image("grass"))

        # makes things look a bit nicer for some reason
        w = self.background.rect.width
        self.background.rect.move_ip(-w / 2, -w / 2)

        self.l_shadow = ShadowLayer(scr_size)
        self.l_sprite = Layer(scr_size)

        self.sprites = Group()

        self.app.scores.reset()

        self.font = pygame.font.Font(None, 60)

        self.cheating = False

        play_song("maintheme", volume=0.7)
Ejemplo n.º 13
0
    def __init__(self, parent=None):
        super(Demo, self).__init__(parent)
        #   Setup scene
        self.m_scene = QGraphicsScene()
        self.setScene(self.m_scene)
        self.setup_scene()
        self.setFixedSize(WINDOW_WIDTH, WINDOW_HEIGHT)

        #   Set up entities (not attached to this term, but basically things like light sources, level, npcs)
        self.m_lightSource = None
        self.level = Level(self, fp='assets/level_test.txt')
        self.player = Player(self, MAP_WIDTH/2, MAP_HEIGHT/2, Link(parent=self))

        #   Setup animation timer
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.animate)
        self.timer.setInterval(30)
        self.timer.start()

        #   Render settings
        self.setRenderHint(QPainter.Antialiasing)
        self.setFrameStyle(QFrame.NoFrame)

        #   Input management
        self.mouse_down = False
        self.setMouseTracking(True)
        self.key_pressed = False
Ejemplo n.º 14
0
    def __init__(self):
        # Model
        self.__FPS = FPS
        self.__caption = TITULO
        self.__sprites = pg.sprite.Group()
        self.__jogador = Jogador()
        self.__level = Level(world)

        self.__background = pg.image.load("data/teste.png")
        self.__bg_x = 0

        # VIEW
        # inicializa a janela do pygame
        pg.init()
        # inicializa o audio
        pg.mixer.init()
        # define o titulo
        pg.display.set_caption(self.__caption)

        # Model
        self.__clock = pg.time.Clock()

        # VIEW
        self.__sprites.add(self.__jogador, self.__level.platforms,
                           self.__level.items, self.__level.exit)
        self.__screen = pg.display.set_mode((WIDTH, HEIGHT))
        self.__running = True
Ejemplo n.º 15
0
    def __init__(self):
        # init mixer first to prevent audio delay
        pygame.mixer.pre_init(44100, -16, 2, 2048)
        pygame.mixer.init()

        pygame.init()
        pygame.display.set_caption('NEXTGAME')

        self.option_handler = optionhandler.OptionHandler()

        mode = 0
        if self.option_handler.fullscreen:
            mode = pygame.FULLSCREEN

        self.screen = pygame.display.set_mode(self.option_handler.resolution,
                                              mode)

        self.image_handler = imagehandler.ImageHandler()
        self.input_handler = inputhandler.InputHandler()

        self.clock = pygame.time.Clock()
        self.time_step = 15.0 / self.option_handler.fps
        self.font = pygame.font.Font(None, 30)

        self.level = Level()

        self.grid_color = [150, 150, 150]

        self.wall_start = None
        self.grabbed_object = None
        self.grab_offset = np.zeros(2)
        self.object_types = ['wall', 'platform']
        self.type_index = 0

        self.camera = Camera([0, 0], self.option_handler.resolution)
Ejemplo n.º 16
0
 def setup(self):
     # Create vertically scrolling background image
     self.background_list.append(
         PropSprite(asset="./assets/backgrounds/space_background.png",
                    scaling=SCALING,
                    x=WINDOW_WIDTH // 2,
                    y=BACKGROUND_HEIGHT // 2,
                    change_y=-BACKGROUND_SCROLL_SPEED))
     self.background_list.append(
         PropSprite(asset="./assets/backgrounds/space_background.png",
                    scaling=SCALING,
                    x=WINDOW_WIDTH // 2,
                    y=BACKGROUND_HEIGHT + WINDOW_LENGTH // 2,
                    change_y=-BACKGROUND_SCROLL_SPEED))
     # Currently 3 explosion types available
     for i in range(0, 3):
         asset = "./assets/explosions/explosion_" + str(i) + ".png"
         self.explosion_texture_list.append(
             self.create_texture_list(asset=asset,
                                      sprite_width=100,
                                      sprite_height=100,
                                      columns=10,
                                      count=70))
     # Texture list for boss
     self.enemy_boss_character_texture_list = self.create_texture_list(
         asset="./assets/enemies/big_boss.png",
         sprite_width=512,
         sprite_height=512,
         columns=2,
         count=2)
     # Setup levels
     self.curr_level = Level(number=1, num_max_enemies=2, num_max_bosses=1)
     self.levels.append(self.curr_level)
Ejemplo n.º 17
0
def run_main():
    level = Level((1, 1), 2)
    with ToyGame2DSimulator(level) as simulator:
        simulator.make_move('right')
        simulator.make_move('down')
        simulator.sample().show()
        print simulator.sample().state.feature_vector()
Ejemplo n.º 18
0
def read_levels(infile):
    '''
    Packages the contents of the input file (infile, str) into instances of
    Level.
    Takes an input filename (str).
    Returns a list of Level instances.
    '''
    level_contents = read_level_contents(infile)

    levels = []
    sublevels = []
    for row in level_contents:
        if row != '':
            row = row.split()
            spin = float(row[J_INDEX])
            parity = int(row[PI_INDEX])
            energy = float(row[ENERGY_INDEX])
            energy_fixed = int(row[ENERGY_FIXED_INDEX])
            width = float(row[WIDTH_INDEX])
            width_fixed = int(int(row[WIDTH_FIXED_INDEX]) or width == 0)
            radius = float(row[CHANNEL_RADIUS_INDEX])
            channel = int(row[CHANNEL_INDEX])
            separation_energy = float(row[SEPARATION_ENERGY_INDEX])
            sublevels.append(
                Level(spin, parity, energy, energy_fixed, width, width_fixed,
                      radius, channel, separation_energy))
        else:
            levels.append(sublevels)
            sublevels = []

    return levels
Ejemplo n.º 19
0
    def __init__(self):
        super().__init__()

        # initialize various windows used in this scene:
        # gamewin -> main map view
        # hudwin -> left stripe wtih key char information
        # msgwin -> basic messages window
        self.gamewin = win.Window(10, 0, win.screenwidth - 10,
                                  win.screenheight)
        self.hudwin = win.Window(0, 0, 10, win.screenheight)
        self.hudwin.setbg(win.color(50, 50, 50))
        self.msgwin = win.Window(self.hudwin.width, win.screenheight - 10,
                                 win.screenwidth - self.hudwin.width, 10)
        self.msgwin.setalpha(1.0, 0.0)

        # create player and level object
        self.player = gameobject.create('player', 50, 50)
        self.level = Level(self.player, 200, 200, self.gamewin)

        # create initial dungeon and compute the initial player field of view and player position.
        dungeon.createdungeon(self.level, 2)
        self.level.computefov()

        self.id = "Game Scene"

        self.keydict = {
            ',': (self._handlestairs, 'upstair'),
            '.': (self._handlestairs, 'downstair'),
        }
Ejemplo n.º 20
0
    def parse(self, svgFile):
        document = etree.parse(svgFile)

        # there is a main svg node in a svg file
        dom_svg = document.getroot()

        # the main svg node has width and height attributes
        attrs = dom_svg.attrib
        width = UnitsConvertor(attrs['width']).convert('px')
        height = UnitsConvertor(attrs['height']).convert('px')

        levelOptions = dom_svg.xpath('//dc:description', namespaces=NSS)
        if levelOptions is not None and len(levelOptions) > 0:
            description = self.getNodeText(levelOptions[0])
        else:
            description = None

        labelParser = Factory().create('label_parser')
        options = labelParser.parse(description)
        createIfAbsent(options, 'svg')
        options['svg']['width'] = width
        options['svg']['height'] = height

        rootLayer = self.scanLayers(dom_svg, None)

        return Level(options, rootLayer, document)
Ejemplo n.º 21
0
 def enter(self):
     self._g_root = greenlet.getcurrent()
     self._g_loop = greenlet.greenlet(self._loop)
     self.message_log = MessageLog()
     self.level = Level(self, self.DUNGEON_SIZE_X, self.DUNGEON_SIZE_Y)
     self.game.window.push_handlers(self)
     self._g_loop.switch()
Ejemplo n.º 22
0
 def __parse_cmd(self, namespace) -> Level:
     screen = Screen(ScreenNumber(namespace.init_num), namespace.portal)
     # Parse buttons with specialized parser
     buttons = self.button_parser.parse(namespace.buttons)
     goal = ScreenNumber(namespace.goal)
     level = Level(screen, buttons, goal, namespace.max_moves)
     return level
Ejemplo n.º 23
0
 def start(self):
     self.tk.geometry(
         str(self.config['width'] * self.size_x) + 'x' +
         str(self.config['height'] * self.size_y))
     self.level = Level(self)
     self.level.render(1)
     self.tk.mainloop()
Ejemplo n.º 24
0
    def choose_level(self):
        while True:
            self.draw_choose()
            self.clock.tick(self.framerate)
            for event in pygame.event.get():
                if (event.type == pygame.QUIT
                        or (event.type == pygame.KEYDOWN
                            and event.key == pygame.K_ESCAPE)):
                    return True
                if event.type == pygame.MOUSEBUTTONDOWN:
                    mx, my = event.pos
                    if mx > 50 and mx < 750 and my > 220 and my < 565:
                        ix = (mx - 50) // 124
                        iy = (my - 220) // 95
                        if (6 * iy + ix < NB_LVLS and (mx - 50) % 124 < 80
                                and (my - 220) % 95 < 60):
                            lvl = 6 * iy + ix + 1

                            level = Level(self.screen,
                                          "levels/level%d.txt" % lvl)
                            if not level.intro():
                                return False
                            res = 0
                            while res == 0 or res == 2:
                                if res:
                                    level.init_shuttle()
                                    level.fade(0)
                                res = level.start()
                            if res == 1:
                                return False
Ejemplo n.º 25
0
def test_draw_level():
    # make a dummy level
    from level import Level
    tiles = [
        "########", "########", "##    ##", "##@.$ ##", "##   *##", "########",
        "########", "########"
    ]
    tiles = list(map(lambda r: list(r), tiles))
    level = Level(tiles, [(3, 3), (4, 5)], (3, 2), [(3, 4), (4, 5)])

    # load sprites and canvas with pygame
    pg.init()
    BASE_RES = (512, 600)  # rectangular to test uncolored area
    pview.set_mode(BASE_RES)

    # sheet and expected order of images, flattened
    filename = '../assets/sokobalt_tilesheet_8px.png'
    sprites = load_spritesheet(filename, SPR_ORDER, 8)

    done = False
    while not done:
        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
            if event.type == pg.KEYDOWN and event.key == pg.K_ESCAPE:
                done = True
            if event.type == pg.KEYDOWN and event.key == pg.K_F11:
                pview.toggle_fullscreen()
        # draw every loop, kinda wasteful
        draw_level(level, pview.screen, sprites)
        pg.display.flip()

    # tear down
    pg.quit()
Ejemplo n.º 26
0
def main():
    print()  # Newline after the pygame hello message

    # Parse arguments to get the path to a level file
    if len(argv) < 2:
        print("Missing argument: Path to a labyrinth file")
        exit(1)
    levelFile = argv[1]

    # Create level object from level file
    try:
        level = Level(levelFile)
    except Exception as e:
        print("Error while reading the level file: %s" % (e))
        exit(1)

    # Create game
    game = Game(level,
                windowSize=SIZE,
                totalRays=RAYS,
                fovDegrees=FOV,
                targetFps=FPS)

    # Run game
    game.run()
Ejemplo n.º 27
0
 def draw(self):
     level = Level(self.level_width, self.level_height)
     path = self.get_path()
     for point in path:
         level.set(point, CellType.START)
     level.print()
     return
Ejemplo n.º 28
0
def main():
    """ Main Program """
    # Initialising Pygame library
    pygame.init()
    pygame.mixer.init()
    screen = pygame.display.set_mode([700, 700])

    # Taking player name as input
    pName = getPlayerName(screen)
    if not pName: return

    # Reading high scores from file
    hScore = []
    with open("./data/file.txt", "r") as f:
        for line in f:
            line = line.strip()
            hScore.append(line.split())

    # Creating level object and calling it's different levels in loop
    room = Level()
    i = [0]
    while i[0] < len(room.maze):
        if not game(screen, room, room.maze[i[0]], i, pName, hScore): break
        i[0] += 1

    # Before exiting updating high scores back in the file
    with open("./data/file.txt", "w") as f:
        for i in range(len(room.maze)):
            f.write(" ".join(hScore[i]) + "\n")

    pygame.quit()
Ejemplo n.º 29
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.calculateButton.clicked.connect(self.find_paths)
        self.ui.clearButton.clicked.connect(self.ui.tableWidget.clearContents)
        self.ui.addRowButton.clicked.connect(self.add_row)
        self.ui.delRowButton.clicked.connect(self.del_row)
        self.ui.viewResourceButton.clicked.connect(self.start_resource_loading)
        self.actionHelp = QtGui.QAction('Help',
                                        self,
                                        statusTip="Help and Docs",
                                        triggered=self.help)
        self.actionHelp.setObjectName("actionHelp")
        self.ui.menubar.addAction(self.actionHelp)
        self.actionAbout = QtGui.QAction('About',
                                         self,
                                         statusTip="About Maven",
                                         triggered=self.about)
        self.actionAbout.setObjectName("actionAbout")
        self.ui.menubar.addAction(self.actionAbout)

        self.all_activities = None  # created because self.start_resource_levelling can't access all the activities
        self.result = None
        self.success = 'No'
        self.progress = 'Yes'
        self.resource_level = Level()
Ejemplo n.º 30
0
    def next_level(self):
        """Go to intermediate screen then start next level
        """

        next_level = Level(self)
        info_screen = InfoScreen(self, self.score, self.lives, next_level)
        self.change_state(info_screen)