Exemple #1
0
        reset_arrow()
        dragon.X -= 10

    if pygame.sprite.collide_rect(player, dragon):
        game_over = True

    if dragon.X < -10:
        you_win = True
        game_over = True

    if player_jumping:
        player.Y += jump_vel
        jump_vel += 0.5
        if player.Y > player_start_y:
            player_jumping = False
            player.Y = player_start_y
            jump_vel = 0.0

    screen.blit(bg, (0, 0))
    if not game_over:
        group.update(ticks, 50)
    group.draw(screen)
    print_text(screen, font, 350, 560, "Press SPACE to jump!")

    if game_over:
        print_text(screen, font, 360, 100, "GAME OVER")
        if you_win:
            print_text(screen, font, 330, 130, "YOU BEAT THE DRAGON!")
        else:
            print_text(screen, font, 330, 130, "THE DRAGON GOT YOU!")
Exemple #2
0
        if player.frame < player.first_frame:
            player.frame = player.first_frame
        if not player_moving:
            player.frame = player.first_frame = player.last_frame
        else:
            player.velocity = calc_velocity(player.direction, 1.5)
            player.velocity.x *= 1.5
            player.velocity.y *= 1.5

        player_group.update(ticks, 50)

        if player_moving:
            player.X += player.velocity.x
            player.Y += player.velocity.y
            if player.X < 0: player.X = 0
            if player.Y < 0: player.Y = 0
            if player.X > 700: player.X = 700
            if player.Y > 500: player.Y = 500

        zombie_group.update(ticks, 50)

        for z in zombie_group:
            z.first_frame = z.direction * z.columns
            z.last_frame = z.first_frame + z.columns - 1
            if z.frame < z.first_frame:
                z.frame = z.first_frame
            z.velocity = calc_velocity(z.direction)

            z.X += z.velocity.x
            z.Y += z.velocity.y
            if z.X < 0 or z.X > 700 or z.Y < 0 or z.Y > 500: