예제 #1
0
    def init_sprites(self, role_name, sources):
        role_images = sources['player'][role_name]
        role_pos = [cfg.SCREEN_WIDTH * 0.15, cfg.INIT_HEIGHT / 2]
        role = character.player(role_images, role_pos)

        floor_first_pos = [0, cfg.INIT_HEIGHT]
        # floor image is a single block use relative variable in configuration file draw different combination of floor
        floor_imgae = sources['map']['floor']
        imgae_width = floor_imgae.get_width()
        floor_sprites = pygame.sprite.Group()
        x = 0
        y = cfg.INIT_HEIGHT
        for width_level, height_level, gap_level in cfg.FLOOR_LIST:
            y = cfg.INIT_HEIGHT + height_level * cfg.FLOOR_GAP_HEIGHT
            # instantiate a floor
            floor = map.Floor(floor_imgae, (x, y), width_level)
            # calculate the gap between two blocks
            x += imgae_width * width_level + gap_level * cfg.FLOOR_GAP_WIDTH
            floor_sprites.add(floor)
        BG = sources['background']['running_background']
        mountains = []
        fogs = []
        mountains += [sources['background']['mountain1']]
        mountains += [sources['background']['mountain2']]
        mountains += [sources['background']['mountain3']]
        mountains += [sources['background']['mountain4']]
        fogs += [sources['background']['fog1']]
        fogs += [sources['background']['fog2']]
        fogs += [sources['background']['fog3']]
        return role, floor_sprites, BG, mountains, fogs
예제 #2
0
    def new_game(self):
        self.hero = character.player(HERO_NAME)
        # New game_scene with default settings
        new_game = game_scene.game_scene(self.scene_manager, self, DEFAULT_MAP,
                                         MAP_ENTRANCE)

        # Fade transition
        fade = fade_transition.fade_transition(self.scene_manager, FADE_TIME,
                                               FADE_COLOUR)

        self.scene_manager.change(new_game, fade)
예제 #3
0
    def __init__(self):
        super(GameScene, self).__init__()
        self.score = 0
        self.grid = scene.grid(50, 50, 32, 32, 8)
        self.velita = character.player(self.grid)  # Jugador Principal
        self.ghosts = []
        for x in range(5):
            self.ghosts.append(character.Enemy(self.grid))
        self.players = self.ghosts[:]
        self.players.append(self.velita)
        # self.cartica = cards.deck(21)
        self.font = pygame.font.Font(None, 20)
        self.GUI = GUI.pantalla(self.velita, screen, self.grid)
        random.shuffle(self.players)
        self.turns = Manage.TurnManager(self.players, self.grid)

        self.alpha = 0
예제 #4
0
    def set_y_limit(self, y1, y2):
        self.y_limit[0] = y1
        self.y_limit[1] = y2


cam = camera()

#-- GENERATE PLAYER ------------------------------------------------------------------------------#
import character as ch
player_bstat = ch.basic_stat(acc=3,
                             jump_power=10,
                             max_speed=10,
                             max_hp=100,
                             max_mp=100)
player_phstat = ch.physics_stat(width=20, height=20, air_drag=0.2)
player = ch.player("1P", (500, 400), player_bstat, player_phstat)

#-- GENERATE MAPS ------------------------------------------------------------------------------#
import map
maps = {}

# MAP: TEST MAP
maps['test_map'] = map.map(player, (40, 24))
map_now.map_setting(map_temp, {'start': (50, 300)})
test_map.background_setting(pygame.image.load("img/background.png"))
test_map.start(player, test_map.spawn_list['start'])
test_map.add_block(
    entity.eventblock(
        test_map, (5, 5), entity.PLAYER_COLLIDE,
        lambda: test_map.player.harms.append(attack.damage(5, False))))
test_map.add_block(
예제 #5
0
#Window Size
(winX, winY) = (1200, 800)

#Create the window with aboce specs
screen = pygame.display.set_mode((winX, winY))
#clock used for fps
clock = pygame.time.Clock()

#initialzing the Objects
scoreB = ScoreBoard(20, 20, 40)
score = 0
scoreB.setScore(score)

bg = SpaceBackground(screen, 1, 0)

p1 = player(300, 410, 64, 64)

running = True
runGame = False


def beginGame():
    global runGame
    runGame = True


def quitGame():
    global running
    running = False