Ejemplo n.º 1
0
 def _generate_platforms(self, game):
     ground1 = Ground(game)
     ground1.set_size_and_position(3 * 240, 3 * 16, 0, 3 * (226 - 16))
     self.platforms.add(ground1)
     ground2 = Ground(game)
     ground2.set_size_and_position(3* 40, 3 * 16, 0, 3 * (226 - 64))
     self.platforms.add(ground2)
     
Ejemplo n.º 2
0
    def __init__(self, parent=None, FRA=None):
        super().__init__(parent)

        self.isCorrect = None  #사용자가 주어진 단어 입력 성공을 확인하는 변수이다
        self.noTyping = None  #사용자가 주어진 단어 입력 성공을 확인하는 변수이다
        self.isClear = None  #게임 종료 후 버튼이 눌렸는지 확인하기 위한 변수이다

        self.timer = QBasicTimer()  # QBasicTimer()=>timer events을 제공한다
        self.timer.start(
            FRAME_PER_MS,
            self)  # .start(int msec)=>주어진 msec주기로 타이머를 시작하거나 재시작한다

        self.back1 = Ground()  #배경 이미지를 가진 Ground객체를 생성한다
        self.back1.setPos(0, GROUND_HEIGHT)  # .setPos(x, y)=>위치를 지정한다
        self.addItem(self.back1)  # .addItem('')=>QGrahphicsScene에 항목을 추가한다

        self.back2 = Ground()  #배경 이미지를 가진 Ground객체를 생성한다
        self.back2.x = 1000  #생성한 객체의 x좌표를 지정한다
        self.back1.setPos(0, GROUND_HEIGHT)  # .setPos(x, y)=>위치를 지정한다
        self.addItem(self.back2)  # .addItem('')=>QGrahphicsScene에 항목을 추가한다

        self.user = User()  #게임 진행 중인 사용자 이미지를 가진 User객체를 생성한다
        self.user.setPos(180, 320)  # .setPos(x, y)=>위치를 지정한다
        self.addItem(self.user)  # .addItem('')=>QGrahphicsScene에 항목을 추가한다

        self.croco = Croco()  #악어 이미지를 가진 Croco객체를 생성한다
        self.croco.setPos(-130, 350)  # .setPos(x, y)=>위치를 지정한다
        self.addItem(self.croco)  # .addItem('')=>QGrahphicsScene에 항목을 추가한다

        self.house = House()  #게임 성공의 목적지인 집의 이미지를 가진 House객체를 생성한다
        self.house.setPos(700, 250)  # .setPos(x, y)=>위치를 지정한다
        self.addItem(self.house)  # .addItem('')=>QGrahphicsScene에 항목을 추가한다

        self.win = Win()  #게임 성공했을 때의 사용자 이미지를 가진 Win객체를 생성한다
        self.win.setPos(800, 390)  # .setPos(x, y)=>위치를 지정한다
        self.addItem(self.win)  # .addItem('')=>QGrahphicsScene에 항목을 추가한다
        self.win.setVisible(False)  #self.win으로 생성한 객체를 보이지 않도록 지정한다

        self.view = QGraphicsView(
            self)  #QGrahicsView()=>구상한 QGraphicsScene을 시각화한다
        self.view.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)  #가로 방향 스크롤을 off로 설정한다
        self.view.setVerticalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)  #세로 방향 스크롤을  off로 설정한다
        self.view.setFixedSize(
            SCREEN_WIDTH, SCREEN_HEIGHT)  # .setFixedSize()=>self.view의 크기 고정한다
        self.setSceneRect(
            0, 100, SCREEN_WIDTH,
            SCREEN_HEIGHT)  # .setFixedSize()=>self.view의 시작 위치와 크기 고정한다
    def reset(self, lives: int, settings: dict, score: int):
        self._settings = settings
        self._arena = Arena((ARENA_W, ARENA_H))
        self._arena.add_to_score(score)
        Mountain(self._arena, (MOUNTAIN_X, MOUNTAIN_Y))
        Hill(self._arena, (HILL_X, HILL_Y), self._settings['level'])
        self._ground = Ground(self._arena, (GROUND_X, GROUND_Y), self._settings['difficulty'])
        self._start_time = time()
        self.bg_list = [Mountain, Hill, Ground]
        self._time_to_generate_alien = time()
        self._hero = []
        self._hero.append(Rover(self._arena, (ROVER_X, ROVER_Y), 1))
        if self._settings['mode'] == 'co-op':
            self._hero.append(Rover(self._arena, (ROVER_2_X, ROVER_2_Y), 2))

        self._start = time()
        self._playtime = 80
        self.hero_lives = lives
        self._aliens = []
        self._obstacles = []
        self._type_obstacles = [Rock, Hole]
        self._rand_x_bomb = 0
        self._time_to_generate_bomber = time()
        self._bomb_ready = False
        self._second = time()

        if self._settings['difficulty'] == 'Easy':
            self.OBS_RANGE = 400
        elif self._settings['difficulty'] == 'Normal':
            self.OBS_RANGE = 300
        else:
            self.OBS_RANGE = 200
Ejemplo n.º 4
0
 def __init__(self):
     pygame.init()
     self.camera = Vector2(400, 0)
     self.ground = Ground()
     self.clock = pygame.time.Clock()
     self.screen = pygame.display.set_mode((screenWidth, screenHeight))
     self.player = Player()
Ejemplo n.º 5
0
    def __init__(self):
        """Initialize the game, and create game resources."""
        pygame.init()

        self.settings = Settings()
        self.stats = GameStats(self)
        self.screen = pygame.display.set_mode(
            (self.settings.screen_width, self.settings.screen_height))

        # Fullscreen mode
        #self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
        #self.settings.screen_width = self.screen.get_rect().width
        #self.settings.screen_height = self.screen.get_rect().height

        self.block = Block(self)
        self.bowser = Bowser(self)
        self.ground = Ground(self)
        self.axe = Axe(self)
        self.fireballs = pygame.sprite.Group()
        self.iceballs = pygame.sprite.Group()

        self.gravity = self.settings.gravity
        self.groundY = 0

        # Make the Play button.
        self.play_button = Button(self, "Play")
Ejemplo n.º 6
0
    def __init__(self, width, height, title):
        # Window initializing code
        self.win_size = width, height
        self.win = pygame.display.set_mode((width, height))
        pygame.display.set_caption(title)

        self.running = True
        self.background = (0, 0, 0)

        # Pymunk initializing code
        pymunk.pygame_util.positive_y_is_up = False
        self.space = pymunk.Space()
        self.space.gravity = 0, 700

        # Create game objects
        self.ground = Ground(self.win_size[0], 150, self.win_size)
        self.player1 = Tank("red")
        self.player2 = Tank("blue")
        self.bullets = []

        # Setup code
        self.current_player = self.player1
        self.other_player = self.player2
        self.moves_left = 100
        self.shoot_wait = 380
        self.shooting = False

        self.player1.body._set_position((100, 250))
        self.player2.body._set_position((width-136, 250))

        # Add game objects to space
        self.ground.add_to_space(self.space)
        self.player1.add_to_space(self.space)
        self.player2.add_to_space(self.space)
Ejemplo n.º 7
0
    def add_comp(self, comp, x, y):
        """ Adds a component to the sprite group of a given type and position"""
        xpos, ypos = self.grid_snap(x, y)
        new_component = None
        if comp == 'r':
            value = input('Please enter a resistor value (-1 to cancel): ')
            value = int(value)
            if not value == -1:
                new_component = Resistor(value, xpos, ypos)
            else:
                print('canceling')

        elif comp == 'v':
            value = 5
            new_component = Voltage(value, xpos, ypos)
            self.vcc = new_component
        elif comp == 'g':
            value = 0
            new_component = Ground(xpos, ypos)
        else:
            print('Not an existing component')  #just for debugging

        if not new_component is None:
            self.components.add(new_component)
            self.graph.update({(xpos, ypos):
                               (comp, value)})  #component info for analysis
            self.connections[new_component] = list()
            print(self.graph)
Ejemplo n.º 8
0
 def test_connect_database(self):
     g = Ground()
     self.assertTrue(g != None)
     s = Spider()
     self.assertTrue(s != None)
     h = Horace()
     self.assertTrue(h != None)
Ejemplo n.º 9
0
 def __init__(self, mw, ball):
     #self.mw = mw
     self.ground = Ground()
     self.points = [0 for _ in range(9)]
     self.records = []
     self.sumrecords = []
     self.games = 0
     self.top_players = [Player(True, i, mw) for i in range(9)]
     self.bottom_players = []
     for i in range(9):
         if i == 0:
             p = Pitcher(False, i, mw)
         elif i == 1:
             p = Catcher(False, i, mw)
         elif i == 2:
             p = First(False, i, mw)
         elif i == 3:
             p = Second(False, i, mw)
         elif i == 4:
             p = Third(False, i, mw)
         elif i == 5:
             p = Short(False, i, mw)
         else:
             p = Player(False, i, mw)
         self.bottom_players.append(p)
     self.ball = ball
Ejemplo n.º 10
0
def run_game():
    pygame.init()
    settings = Settings()
    clock = pygame.time.Clock()
    #tela
    screen = pygame.display.set_mode(settings.SCREEN_DIMENSION)
    pygame.display.set_caption('Flappy Bird - Python')
    surface = pygame.image.load('images/bluebird-midflap.png')
    pygame.display.set_icon(surface)
    #objetos
    bird = Bird(settings, screen)
    ground = Ground(screen, settings)
    button = Button(screen, settings)
    game_over = GameOverButton(screen, settings)
    score = Scoreboard(screen)
    #grupos
    ground_group = Group()
    pipe_up_group = Group()
    pipe_down_group = Group()
    #adições
    ground_group.add(ground)

    #-------------------------------------------------------------------------------------------------------------------
    while True:
        clock.tick(30)
        function.check_events(bird, screen, settings, pipe_up_group,
                              pipe_down_group, score)
        function.update_screen(screen, bird, settings, ground_group, button,
                               game_over, pipe_up_group, pipe_down_group,
                               score)
Ejemplo n.º 11
0
def enter():
    gfw.world.init([
        'bg', 'ground', 'enemy_melee', 'enemy_range', 'enemy_charge', 'bullet',
        'player'
    ])
    obj_gen.init()

    global stage_sel
    stage_sel = stage()

    global player
    player = Player()
    gfw.world.add(gfw.layer.player, player)

    global bg
    bg = Bg()
    bg.image = gfw.image.load(stage_sel.bg_selector())
    gfw.world.add(gfw.layer.bg, bg)

    global ground
    ground = Ground()
    gfw.world.add(gfw.layer.ground, ground)

    global game_state
    game_state = STATE_IN_GAME

    global music_bg
    music_bg = load_wav('res/Bg_music.wav')
    music_bg.repeat_play()
Ejemplo n.º 12
0
def enter():
    global boy
    boy = Boy()
    game_world.add_object(boy, 1)

    ground = Ground()
    game_world.add_object(ground, 0)
Ejemplo n.º 13
0
def enter():
    global ground, character, stage, hp
    global scoreLabel, Label
    global jelly_sound, collide_sound, item_eat

    character = Cookie()
    stage = Stage()
    ground = Ground()
    hp = HP()

    game_world.add_object(character, 1)
    game_world.add_object(stage, 0)
    game_world.add_object(ground, 0)
    game_world.add_object(hp, 0)

    label = score.Label("Score: ", 50, get_canvas_height() - 50, 45, 0)
    label.color = (255, 255, 255)
    score.labels.append(label)
    scoreLabel = label

    jelly_sound = load_wav('jelly.wav')
    jelly_sound.set_volume(32)
    item_eat = load_wav('item.wav')
    item_eat.set_volume(32)
    collide_sound = load_wav('collide.wav')
    collide_sound.set_volume(50)
Ejemplo n.º 14
0
 def update(self):
     for col in self._map:
         for panel in col:
             if panel.is_road() and panel.update() == 1:
                 ground = Ground(panel.point.x, panel.point.y)
                 self.replace_panel(ground)
     self.i_manager.update()
Ejemplo n.º 15
0
def enter():

    global stage, ground, hp, cookie, jelly, potion, jtrap, djtrap, strap
    global scoreLabel, Label
    global jelly_sound, item_sound, collide_sound

    stage = Stage()  # 스테이지
    ground = Ground()  # 바닥
    hp = HP()  # 체력
    cookie = Cookie()  # 캐릭터

    game_world.add_object(stage, game_world.layer_bg)
    game_world.add_object(ground, game_world.layer_bg)
    game_world.add_object(hp, game_world.layer_bg)
    game_world.add_object(cookie, game_world.layer_player)

    # 점수
    label = score.Label("Score: ", 50, get_canvas_height() - 50, 45, 0)
    label.color = (255, 255, 255)
    score.labels.append(label)
    scoreLabel = label

    # 사운드
    jelly_sound = load_wav('jelly.wav')
    jelly_sound.set_volume(32)
    item_sound = load_wav('item.wav')
    item_sound.set_volume(32)
    collide_sound = load_wav('collide.wav')
    collide_sound.set_volume(50)
Ejemplo n.º 16
0
def enter():
    gfw.world.init([
        'bg', 'ground', 'spine', 'jelly', 'h_item', 's_item', 'missile',
        'skill_w', 'skill_f', 'skill_g', 'player'
    ])
    global score
    score = 0

    for n, speed in [(1, 10), (2, 100)]:
        bg = Background('cookie_run_bg_%d.png' % n)
        bg.speed = speed
        gfw.world.add(gfw.layer.bg, bg)

    global ground
    for l, sp in [(0, n_speed), (500, n_speed), (1000, n_speed),
                  (1500, n_speed)]:
        ground = Ground(l, sp)
        gfw.world.add(gfw.layer.ground, ground)

    global font
    font = gfw.font.load('res/CookieRun.ttf', 30)

    global Select
    Select = cookie_state.Select
    global player
    player = Player(Select)
    gfw.world.add(gfw.layer.player, player)
Ejemplo n.º 17
0
 def __init__(self, bg):
     self.bg = bg
     #self.x, self.y = 64 * 6, 64 * 2 + 32  # 32 = 플레이어 높이 // 2
     self.x = 64 * 6  # 전체 백그라운드 중에서 드로우 좌표
     self.y = 360 + 64 * 3 + 32  # 전체 백그라운드 중에서 드로우 좌표
     self.canvas_width = get_canvas_width()
     self.canvas_height = get_canvas_height()
     self.image = load_image('image\Player\Idle.png')
     self.runImage = load_image('image\Player\Run.png')
     self.jumpImage = load_image('image\Player\Jump.png')
     self.attackImage = load_image('image\Player\Attack.png')
     self.image_dash = load_image('image\dash_effect.png')
     self.hurtImage = load_image('image\Player\Hurt.png')
     self.dir = 1
     self.jump_timer = 0.1
     self.jumped = False
     self.workingJump = True
     self.stop_jump_while_dash = 0
     self.dash_timer = 0
     self.velocity = 0
     self.velocityOnY = 0
     self.fall_speed = 400
     self.jumping = False
     self.frame = 0
     self.attackFrame = 0
     self.hurtFrame = 0
     self.hurting = False
     self.invincibilityTime = 10
     self.HP = 100
     self.STR = 30
     self.INT = 50
     self.attack_count = 0
     self.coinCount = 0
     self.groundList = Ground.groundList
     self.groundYList = Ground.groundYList
     self.ax = 0
     self.bx = 0
     self.ay = 0
     self.by = 0
     self.ground0 = Ground(0, self.bg)
     self.ground1 = Ground(1, self.bg)
     self.ground2 = Ground(2, self.bg)
     self.ground3 = Ground(3, self.bg)
     self.ground4 = Ground(4, self.bg)
     self.ground5 = Ground(5, self.bg)
     self.ground6 = Ground(6, self.bg)
     self.chicken = None
     self.inCure = False
     self.onFire = False
     self.onFlatform = False
     self.potionHealthy = 40
     self.itemList = [[], [], []]  # Item
     self.magicList = [[], [], []]  # Magic
     self.fireSpellCount = 0
     self.light = None
     self.fire = None
     self.font = load_font('ConsolaMalgun.ttf')
     self.event_que = []
     self.cur_state = IdleState
     self.cur_state.enter(self, None)
Ejemplo n.º 18
0
 def __init__(self):
     self.running = False
     self.window = pygame.display.set_mode(
         (self.WIN_WIDTH, self.WIN_HEIGHT))
     self.clock = pygame.time.Clock()
     self.score = 0
     self.bird = Bird(230, 350)
     self.ground = Ground(730)
     self.pipes = [Pipe(600)]
Ejemplo n.º 19
0
def enter():
    server.boy = Boy()
    game_world.add_object(server.boy, 1)

    server.zombie = Zombie()
    game_world.add_object(server.zombie, 1)

    server.ground = Ground()
    game_world.add_object(server.ground, 0)
Ejemplo n.º 20
0
def returnMap(posx, posy, mappos, direction, length, height):
    grnd = Ground(length, height)
    grnd.renderGround(mappos)
    mrio = Mario(posx, posy)

    if mappos >= 2:
        mapMatrix = renderBlocks(grnd.length - (mappos - 2), 7, grnd)
        grnd.updateMap(mapMatrix)
    mapMatrix = mrio.renderMario(grnd, direction)
    return mapMatrix
Ejemplo n.º 21
0
def enter():
    global boy
    boy = Boy()
    game_world.add_object(boy, 1)

    global zombie
    zombie = Zombie()
    game_world.add_object(zombie, 1)

    ground = Ground()
    game_world.add_object(ground, 0)
Ejemplo n.º 22
0
 def __init__(self, player):
     self.platform_list = pygame.sprite.Group()
     self.enemy_list = pygame.sprite.Group()
     self.chest_list = pygame.sprite.Group()
     self.teleporter_list = pygame.sprite.Group()
     self.player = player
     self.world_shift = 0
     ground = Ground()
     wall = Wall()
     self.platform_list.add(ground)
     self.platform_list.add(wall)
Ejemplo n.º 23
0
def initEnemies():
    x = 0
    while (x < cfg.numPipes):
        pipeSet = PipeSet(x, enemy_list)
        pipeSets.append(pipeSet)
        x += 1
    x = 0
    while (x < cfg.numGround):
        ground = Ground(x)
        enemy_list.add(ground)
        x += 1
Ejemplo n.º 24
0
    def __init__(self):

        self.display = (1000, 800)  # window'un boyutlari
        self.mouseX = 0  # mouse hareketinin x koordinati
        self.mouseY = 0  # mouse hareketinin y koordinati
        self.flag = False
        self.flag2 = False
        self.currentValue = 0
        self.antenna = Antenna()
        self.plane = Plane()
        self.ground = Ground(100, 100)  # ground'un boyutlari
        self.sidebar = SideBar()
Ejemplo n.º 25
0
 def __init__(self, images, gravity=1):
     super(World, self).__init__()
     self.background = images['sky']
     self.image = self.background.copy()
     self.scroll = cycle(range(self.background.get_width()))
     self.rect = self.image.get_rect()
     self.ground = Ground(images['ground'], self.rect.midleft)
     self.background.fill((33, 22, 7), self.ground.rect)
     self.gravity = gravity
     self.start_locs = [
         tuple(map(add, (0, self.ground.rect.height), loc))
         for loc in self.ground.start_locs
     ]
Ejemplo n.º 26
0
def create_ground_slice(filename):
    with open(filename) as f:
        lines = f.readlines()

    clay_coords = set()

    for line in lines:
        raw_coords = line.strip().split(', ')
        intermediate_coords = parse_coordinates(raw_coords,
                                                reverse=line[0] == 'y')
        clay_coords = clay_coords.union(set(intermediate_coords))

    return Ground(clay_coords)
Ejemplo n.º 27
0
def initEnemies(pipeDistance, pipeGap):
    x = 0
    while (x < display_width + 678):
        ground = Ground(x, display_width)
        enemy_list.add(ground)
        x += 336
    x = 0
    y = -160
    while (x < display_width):
        upperPipe = UpperPipe(x, y)
        enemy_list.add(ground)
        lowerPipe = LowerPipe(x, y + pipeGap)
        enemy_list.add(ground)
        x += pipeDistance
Ejemplo n.º 28
0
    def __init__(self):
        """ Constructor """
        pygame.init()
        pygame.mixer.init()

        # Load game icon
        self.game_icon = pygame.image.load('images/game/icon.png')
        pygame.display.set_icon(self.game_icon)

        self.settings = Settings()

        # Set screen dimensions.
        self.SCREEN_HEIGHT, self.SCREEN_WIDTH = self.settings.screen_height, self.settings.screen_width
        pygame.display.set_caption("Flappy Unicorn")
        self.screen = pygame.display.set_mode(
            (self.SCREEN_WIDTH, self.SCREEN_HEIGHT))
        self.screen_rect = self.screen.get_rect()

        self.game_active = False
        self.game_over = False

        self.pillar_time_elapsed = 0
        self.cloud_time_elapsed = 0
        self.clock_tick = 0

        # Audio instance.
        self.audio = Audio()

        # Create start and game over screens.
        self.start_screen = StartScreen(self)
        self.game_over_screen = GameOver(self)

        # Create an animated flying unicorn
        self.unicorn = Unicorn(self)
        self.unicorn_sprite = pygame.sprite.Group(self.unicorn)

        # Create the background
        self.background = Background(self)

        # Create ground.
        self.ground = Ground(self)

        # Create cloud.
        self.clouds = pygame.sprite.Group()

        # Create pillar sprite group.
        self.pillars = pygame.sprite.Group()

        # Create the scoreboard.
        self.scoreboard = Scoreboard(self)
Ejemplo n.º 29
0
 def __init__(self):
     #generer joueur
     self.player = Player(self)
     self.all_players = pygame.sprite.Group
     self.all_players.add(self.player)
     self.ground = Ground(self)
     self.background = pygame.image.load("assets/background.png")
     self.background_x = 0
     self.pressed = {}
     self.game_clock = pygame.time.Clock()
     self.fps = 30
     self.rect = pygame.Rect(0, 0, 720, 480)
     self.nb_obstacles = 0
     self.liste_obstacles = pygame.sprite.Group()
Ejemplo n.º 30
0
 def _generate_territory(self, x, y):
     u"""
         x, yの位置に設置されるTerritoryを返す
         プレイヤー人数によって配置が異なるのでその処理をココで行う
     """
     if self.player_count == 1:
         if 6 <= x <= 9:
             return Territory(x, y, self.players[0])
         else:
             return Ground(x, y)
     elif self.player_count == 2:
         u"""
             2-5 Player 1
             10-13 Player 2
         """
         if 2 <= x <= 5:
             return Territory(x, y, self.players[0])
         elif 10 <= x <= 13:
             return Territory(x, y, self.players[1])
         else:
             return Ground(x, y)
     elif self.player_count == 3:
         u"""
             1~4 Player 1
             6-9 Player 2
             11-14 Player 3
         """
         if 1 <= x <= 4:
             return Territory(x, y, self.players[0])
         elif 6 <= x <= 9:
             return Territory(x, y, self.players[1])
         elif 11 <= x <= 14:
             return Territory(x, y, self.players[2])
         else:
             return Ground(x, y)
     elif self.player_count == 4:
         return Territory(x, y, self.players[int(x / 4)])