예제 #1
0
def level1(fps,screeninfo,screen):
    run = True
    world = definitions.World(worldMap)
    player = definitions.Player(100, screeninfo.screenHeight - 130)
    sun = pygame.image.load("Preassets/img/sun.png")
    background = pygame.image.load("Preassets/img/sky.png")
    while run:
        clock.tick(fps)
        screen.blit(background,(0,0))
        screen.blit(sun,(100,100))
        world.draw()
        definitions.base_enemyGroup.update()
        definitions.base_enemyGroup.draw(screen)
        player.update(definitions.game_over,world)
        slime_group.draw(screen)
        platform_group.draw(screen)
        lava_group.draw(screen)
        coin_group.draw(screen)
        exit_group.draw(screen)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run=False
        pygame.display.update()
    pygame.quit()
예제 #2
0
score_coin = definitions.Coin(definitions.tile_size // 2,
                              definitions.tile_size // 2)

slime_group = definitions.small_slime_group
platform_group = definitions.platform_group
lava_group = definitions.lava_group
coin_group = definitions.coin_group
exit_group = definitions.exit_group
score_coin = definitions.Coin(tile_size // 2, tile_size // 2)
coin_group.add(score_coin)
water_group = definitions.water_group
world = definitions.World(world_data)  # (runs once outside game loop)
# call player class with starting coordinates
resetpositions = [100, definitions.screen_height - 175]
player = definitions.Player(resetpositions[0], resetpositions[1])

# create buttons
restart_button = definitions.TuTButton(definitions.screen_width // 2 - 50,
                                       definitions.screen_height // 2 + 100,
                                       definitions.tkrestart_img)
start_button = definitions.TuTButton(definitions.screen_width // 2 - 350,
                                     definitions.screen_height // 2,
                                     definitions.tkstart_img)
exit_button = definitions.TuTButton(definitions.screen_width // 2 + 150,
                                    definitions.screen_height // 2,
                                    definitions.tkexitbtn_img)


def run(game_over, world, score, level, world_data, resetpositions):
    # game loop