示例#1
0
def generate_images(xsize, ysize):
    unit = 5.0
    height = 10.0
    center = (unit * xsize / 2, unit * ysize / 2, height / 2)
    projections = {'top': (center, (0.0, 0.0, 1.0), (0.0, 1.0, 0.0)),
                   'side': (center, (1.0, 0.0, 0.0), (0.0, 0.0, 1.0)),
                   'iso': (center,
                           (math.sqrt(0.4), -math.sqrt(0.4), math.sqrt(0.2)),
                           (-math.sqrt(0.5), math.sqrt(0.5), 0.0)),
                   'bottom': (center,
                              (math.sqrt(0.4),
                               -math.sqrt(0.4),
                               -math.sqrt(0.2)),
                              (-math.sqrt(0.5), math.sqrt(0.5), 0.0))}

    b1 = brick.brick(xsize, ysize, fillet=False)
    v1 = cd.view()

    v1.set_background((1.0, 1.0, 1.0))
    v1.set_scale(24.0)
    v1.set_size((600, 400))

    for projection in projections:
        vcenter, vout, vup = projections[projection]
        v1.clear()
        v1.set_projection(vcenter, vout, vup)
        v1.display(b1, color=(0.0, 0.0, 0.0), line_width=2.0)
        v1.mode_drawing()
        v1.save(name='brick_' + projection + '.png')
示例#2
0
def generate_images(xsize, ysize):
    unit = 5.0
    height = 10.0
    center = (unit * xsize / 2, unit * ysize / 2, height / 2)
    projections = {'top': (center, (0.0, 0.0, 1.0), (0.0, 1.0, 0.0)),
                   'side': (center, (1.0, 0.0, 0.0), (0.0, 0.0, 1.0)),
                   'iso': (center,
                           (math.sqrt(0.4), -math.sqrt(0.4), math.sqrt(0.2)),
                           (-math.sqrt(0.5), math.sqrt(0.5), 0.0)),
                   'bottom': (center,
                              (math.sqrt(0.4),
                               -math.sqrt(0.4),
                               -math.sqrt(0.2)),
                              (-math.sqrt(0.5), math.sqrt(0.5), 0.0))}

    b1 = brick.brick(xsize, ysize, fillet=False)
    v1 = cd.view()

    v1.set_background((1.0, 1.0, 1.0))
    v1.set_scale(24.0)
    v1.set_size((600, 400))

    for projection in projections:
        vcenter, vout, vup = projections[projection]
        v1.clear()
        v1.set_projection(vcenter, vout, vup)
        v1.display(b1, color=(0.0, 0.0, 0.0), line_width=2.0)
        v1.mode_drawing()
        v1.save(name='brick_' + projection + '.png')
示例#3
0
    def __init__(self, config):
        """
        Initializations for the startup of the current wordclock plugin
        """
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.pretty_name = "Tetris"
        self.description = "For the players."

        self.bg_color = wcc.BLACK

        self.bricks = [
            brick([[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
                  wcc.Color(255, 0, 0)),
            brick([[1, 0, 0], [1, 1, 1], [0, 0, 0]], wcc.Color(255, 255, 0)),
            brick([[0, 0, 1], [1, 1, 1], [0, 0, 0]], wcc.Color(0, 0, 255)),
            brick([[1, 1], [1, 1]], wcc.Color(255, 0, 255)),
            brick([[0, 1, 1], [
                1,
                1,
                0,
            ], [0, 0, 0]], wcc.Color(0, 255, 255)),
            brick([[0, 1, 0], [1, 1, 1], [0, 0, 0]], wcc.Color(0, 255, 0)),
            brick([[1, 1, 0], [0, 1, 1], [0, 0, 0]], wcc.Color(255, 255, 255))
        ]
示例#4
0
def generate_map(level, brick_width, brick_height):
    map = get_map(level)

    for i in range(len(map[0])):
        for j in range(len(map)):
            if map[j][i] == 1:
                brick_object = brick.brick()
                brick_object._init_(i * brick_width, j * brick_height,
                                    brick_img)
                bricks_list.append(brick_object)
                print("Object added at", i, j)
示例#5
0
def enter():
    global boy
    boy = Boy()
    game_world.add_object(boy, 1)

    global grass
    grass = Grass()
    game_world.add_object(grass, 0)

    global balls
    balls = [Ball() for i in range(10)] + [BigBall() for i in range(10)]
    game_world.add_objects(balls, 1)

    global Brick
    Brick = brick()
    game_world.add_object(Brick, 1)
示例#6
0
def init_levels(level):
    global x_position, brick_list, y_position
    
    for x in open(os.path.join("Levels", "Level"+str(level))):
        brick_cursor = None
        for y in x:
            if y == '1':
                brick_cursor = brick(pygame, game_constants.brick_image)
                
                brick_cursor.rect.x = x_position
    
                brick_cursor.rect.y = y_position
            
                brick_list.add(brick_cursor)
                
            
            x_position += game_constants.brick_size.width + 2
            if x_position + game_constants.brick_size.width >= game_constants.game_size.width:
                    x_position= 0
                    y_position += game_constants.brick_size.height + 2                    
示例#7
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]

        self.bg_color = wcc.BLACK

        self.bricks = [
            brick([[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
                  wcc.Color(255, 0, 0)),
            brick([[1, 0, 0], [1, 1, 1], [0, 0, 0]], wcc.Color(255, 255, 0)),
            brick([[0, 0, 1], [1, 1, 1], [0, 0, 0]], wcc.Color(0, 0, 255)),
            brick([[1, 1], [1, 1]], wcc.Color(255, 0, 255)),
            brick([[0, 1, 1], [
                1,
                1,
                0,
            ], [0, 0, 0]], wcc.Color(0, 255, 255)),
            brick([[0, 1, 0], [1, 1, 1], [0, 0, 0]], wcc.Color(0, 255, 0)),
            brick([[1, 1, 0], [0, 1, 1], [0, 0, 0]], wcc.Color(255, 255, 255))
        ]
示例#8
0
class Board:
    '''board class'''
    bricks = []
    bricks2 = []
    level1 = []
    enemies = []
    bullets = []
    ebul = []

    coins = []

    flyer = Flyer(355, 35, 1, 0)

    player = Mario(620, 28, 5, 0, 0, 1)
    for j in range(40):
        row = []
        for k in range(1000):
            row.append(" ")
        level1.append(row)

    enemy = Enemy(140, 20, 1, 0)
    enemies.append(enemy)

    enemy = Enemy(170, 32, 1, 0)
    enemies.append(enemy)

    enemy = Enemy(150, 32, -1, 0)
    enemies.append(enemy)

    enemy = Enemy(215, 20, 1, 0)
    enemies.append(enemy)

    enemy = Enemy(265, 32, 1, 0)
    enemies.append(enemy)

    enemy = Enemy(580, 32, 1, 0)
    enemies.append(enemy)

    enemy = Enemy(590, 32, 1, 0)
    enemies.append(enemy)

    vil = Villain(730, 22, 0, 10)

    brick(bricks)
    for i in range(70, 130, 5):
        brick = MakeBrick(i, 30, -2)
        bricks2.append(brick)
        coin = Coin(i + 1, 28)
        coins.append(coin)

    for i in range(50, 80, 5):
        brick = MakeBrick(i, 20, -2)
        bricks2.append(brick)
        coin = Coin(i + 1, 18)
        coins.append(coin)
    for i in range(10, 60, 5):
        brick = MakeBrick(i, 30, -2)
        bricks2.append(brick)
        coin = Coin(i + 1, 28)
        coins.append(coin)
    for i in range(100, 140, 5):
        brick = MakeBrick(i, 20, -2)
        bricks2.append(brick)
        coin = Coin(i + 1, 18)
        coins.append(coin)
    time = 0
    alivev = 1

    # print_background(level1)
    # draw_brick(level1,bricks)

    def print_board(self, k):
        '''print board function'''
        if self.player.level == 1:
            print_background(self)
            print_player(self)
            draw_brick(self, self.bricks)
            print_enemy(self)
            print_bullet(self, self.bullets)
            print_bullet(self, self.ebul)

            if self.alivev == 1:
                print_villain(self, self.vil.posx, self.vil.posy)

            if self.alivev == 0:
                win(self)
                # time.sleep(3)

            temp = ""

            string = '\033[93m' + "Life=" + str(
                self.player.life) + " Score=" + str(
                    self.player.score) + " Coins=" + str(
                        self.player.coins) + "\n" + '\033[0m'
            if k >= 550 and self.alivev == 1:
                string += '\033[93m' + "Boss Life=" + \
                    str(self.vil.life) + "\n" + '\033[0m'

            temp += string

            for i in range(40):

                for j in range(k, k + 150, 1):
                    temp += self.level1[i][j]

            print(temp)
        else:
            print_background(self)
            print_player(self)
            draw_brick(self, self.bricks2)
            draw_coin(self, self.coins)

            if time.time() - self.time >= 0.3:
                write(self)
                self.time = time.time()

            temp = ""

            string = '\033[93m' + "Life=" + str(
                self.player.life) + " Score=" + str(
                    self.player.score) + " Coins=" + str(
                        self.player.coins) + "\n" + '\033[0m'

            temp += string

            for i in range(40):

                for j in range(k, k + 150, 1):
                    temp += self.level1[i][j]

            print(temp)

    def dum(self):
        '''dummy method'''
        return self
示例#9
0
def display_brick(view, size):
    view.clear()
    view.display(brick.brick(size[0], size[1]))
示例#10
0
def display_brick(view, size):
    view.clear()
    view.display(brick.brick(size[0], size[1]))
示例#11
0
    while user[1] != 0 and user[3] == 0:
        enemy_count = 0
        got_inside_block = False
        a = board(38, 76)
        a_a = a.make_board()    # This will have dictionary
        x = unoccupied()
        un = x._un
        oc = x._oc
        ene = []
        fast_ene = []
        bricks = []
        time_count = 0.0
        for i in range(1, 6):
            ene.append(enemy(un, oc, a_a, user))
        for i in range(1, 20):
            bricks.append(brick(un, oc, a_a))
        b = bomberman(3, 5, a_a, user, ene, 'normal')
        b._wallpass = False
        immortal = False
        # This problem in implementation, pass bomberman in bomb to avoid it
        user[4] = b
        new_speed = 'normal'
        bomb_effect = 'normal'
        power_up_timer = 0
        time_counter = 120
###############################################################################
        while user[2] == 1 and user[3] == 0 and time_counter > 0:
            time_count = speed(time_count, new_speed)
    # GIVING POWERUP #############
            if b._super_power == "S":
                new_speed = 'twice'