예제 #1
0
파일: main.py 프로젝트: ThomasJagielski/mp4
def add_ground():
    """
    Add the ground image
    """
    for i in range(1, length, 30):
        model.items.append(Brick(x=i, y=540))
        model.items.append(Brick(x=i, y=570))
예제 #2
0
    def setup_bricks4():
        for row in range(0):
            for column in range(0):
                brick = Brick(
                    gs, gs.colors[row],
                    column * (gs.brick_width + gs.marginx) + 50 +
                    gs.brick_width, gs.brick_length * 3 + gs.marginy)
                bricks.add(brick)
            gs.marginy += gs.brick_length + 5
        gs.marginy = gs.marginy_holder

        for row in range(0):
            for column in range(0):
                brick = Brick(gs, gs.colors[row], (screen_rect.centerx),
                              gs.brick_length + gs.marginy)
                bricks.add(brick)
            gs.marginy += gs.brick_length + 5
        gs.marginy = gs.marginy_holder

        for row in range(0):
            for column in range(0):
                brick = Brick(
                    gs, gs.colors[row], gs.screen_width - column *
                    (gs.brick_width - gs.marginx) - 50 - gs.brick_width,
                    gs.brick_length * 3 + gs.marginy)
                bricks.add(brick)
            gs.marginy += gs.brick_length + 5
        gs.marginy = gs.marginy_holder
예제 #3
0
 def brickMaker():
     global level
     i = 1
     while i != 15 * level + 30:
         brck = Brick()
         x = brck.makeBrick(arr, perm)
         if x == 1:
             i += 1
예제 #4
0
 def setup_bricks2():
     for row in range(8):
         for column in range(4):
             brick = Brick(gs, gs.colors[row],
                           column * (gs.brick_width + gs.marginx2) + 40,
                           gs.marginy)
             bricks.add(brick)
         gs.marginy += gs.brick_length + 5
예제 #5
0
    def setup_bricks3():
        for row in range(6):
            for column in range(5):
                brick = Brick(gs, gs.colors[row],
                              column * (gs.brick_width * 2) + 40, gs.marginy2)
                bricks.add(brick)
            gs.marginy2 += gs.brick_length * 2
        gs.marginy2 = gs.marginy_holder

        for row in range(5):
            for column in range(4):
                brick = Brick(
                    gs, gs.colors[row],
                    column * (gs.brick_width * 2) + 40 + gs.brick_width,
                    gs.marginy2 + gs.brick_length)
                bricks.add(brick)
            gs.marginy2 += gs.brick_length * 2
        gs.marginy2 = gs.marginy_holder
예제 #6
0
파일: scene.py 프로젝트: Anchit1999/Mario
    def brick_coin(cls):
        '''make brick, coin'''
        flag = 0
        for k in BRICK_LIST:
            POLY.print_poly(k, k.xps, k.yps)
            if PERSON.xpos == 18 and PERSON.ypos >= 345 and PERSON.ypos <= 347 and flag == 0:
                PERSON.sym = 'M'
                try:
                    sound = open('smb_powerup.wav', 'r')
                    os.system('aplay -q ./smb_powerup.wav&')
                except:
                    pass
                BRICK_LIST.append(Brick(14, 345, '*', 3))
                flag = 1

            # print(PERSON.xpos,PERSON.ypos,k.xps,k.yps)
            if PERSON.xpos == k.xps + 4 and PERSON.ypos >= k.yps and PERSON.ypos <= k.yps + 2:
                if k.coin != '*' and k.coin != 0:
                    k.coin -= 1
                    try:
                        sound = open('smb_coin.wav', 'r')
                        os.system('aplay -q ./smb_coin.wav&')
                    except:
                        pass
                    Manage.coinscollect()
                    Manage.changescore('coin')
                else:
                    try:
                        sound = open('smb_bump.wav', 'r')
                        os.system('aplay -q ./smb_bump.wav&')
                    except:
                        pass
            if k.coin == 0:
                BRICK_LIST.remove(k)
                try:
                    sound = open('smb_breakblock.wav', 'r')
                    os.system('aplay -q ./smb_breakblock.wav&')
                except:
                    pass
                Manage.changescore('brick')

        for k in COIN_LIST:
            # k.print_coin(k.x,k.y)
            POLY.print_poly(k, k.xps, k.yps)
            if PERSON.xpos == k.xps and PERSON.ypos == k.yps:
                try:
                    sound = open('smb_coin.wav', 'r')
                    os.system('aplay -q ./smb_coin.wav&')
                except:
                    pass
                Manage.coinscollect()
                COIN_LIST.remove(k)
                Manage.changescore('coin')
예제 #7
0
    def setup_bricks():
        # each row will have 9 bricks
        for row in range(4):
            for column in range(0, 9):
                # create new brick
                brick = Brick(gs, gs.colors[row],
                              column * (gs.brick_width + gs.marginx) + 12,
                              gs.marginy)
                bricks.add(brick)

            # update y marin as next row will be placed down
            gs.marginy += gs.brick_length + 5
예제 #8
0
def init_game():
    for y, row in enumerate(settings.field):
        for x, column in enumerate(row):
            if column == 1:
                settings.grass.append(
                    Grass(settings.main_surf, settings.field_size,
                          settings.cells_size, (x, y)))
            elif column == 2:
                settings.armor.append(
                    Armor(settings.main_surf, settings.field_size,
                          settings.cells_size, (x, y)))
            elif type(column) is list:

                for add_nums in column:
                    if add_nums[0] == 0:
                        if add_nums[1] % 2 == 0:
                            ind = 0
                        else:
                            ind = 3
                    else:
                        if add_nums[1] % 2 == 0:
                            ind = 2
                        else:
                            ind = 1

                    settings.bricks.append(
                        Brick(settings.main_surf, settings.field_size,
                              settings.cells_size,
                              (50 + settings.cells_size * x +
                               add_nums[0] * settings.cells_size // 2,
                               50 + settings.cells_size * y +
                               add_nums[1] * settings.cells_size // 4), ind))
            elif column == 4:
                settings.fin.append(
                    Fin(settings.main_surf, settings.field_size,
                        settings.cells_size, (x, y)))
                settings.fin_pos.append([x, y])

            elif column == 5:
                settings.spawns.append([x, y])
            elif column == 6:
                settings.bots_spawn.append([x, y])
            elif column == 7:
                settings.water.append(
                    Water(settings.main_surf, settings.field_size,
                          settings.cells_size, (x, y)))
예제 #9
0
        termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
        fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
    return c
qflag = 0
level = 1
while level <= 3:
    t = Terminal()
    bx = 0
    by = 0
    planted = False
    SCORE = 0
    flag = 0
    arr = [[' ' for i in range(76)] for y in range(38)]
    wall1 = Wall()
    arr = wall1.buildwall(arr)     # populate the array with the wall.
    bricks = Brick(t.cyan('/'))
    arr = bricks.place(arr)       # populate the array with the bricks.
    bomber = Bomberman(t.green('B'))
    num = randint(3*level, 4*level)
    enarr = []
    var = False
    for i in range(num):
        enarr.append(Enemy(t.red('E')))         # enarr is populated with all the enemies.
    arr = bomber.spawn(arr)             # bomberman is spawned.
    for i in range(0, num):
        arr = enarr[i].randspawn(arr)           # all the enemies are randomly spawned.
    if level == 1:
        lives = 3
    print t.blue('SCORE :- '), SCORE, t.blue('LIVES :- '), lives, t.blue('LEVEL :- '), level, t.yellow('\t\tBOMBERMAN\n')
    for i in range(38):
        print ''.join(arr[i])
예제 #10
0
def main():
	b = Wall(38,76)
	b.set_wall()
	array = b.getboard()
	man = BomberMan(array)
	enemy = Enemy()
	enemy.setposition(array,b)
	bricks = Brick(2,4)
	bricks.set_bricks(array)
	bomb = Bomb(2,4,0,False,False)
	flag = 0
	count = 0
	while True:
		cprint("Score is "+ str(bomb.get_score()), 'red', attrs=['bold'])
		cprint("Number of lives: " + str(man.getlives()),'green',attrs=['bold'])
		if flag == 4 :
			bomb.blast(array)
			if bomb.getdestroy() == True:
				cprint("YOU HAVE WON :D", 'yellow')
				cprint("Your final score is " + str(bomb.get_score()), 'green', attrs = ['bold'])
				sys.exit()
			if bomb.getdead() == True:
				man.decrementlives()
				if(man.getlives() != 0):
					man.clear_bomberman(array)
					man.afterdeath()
					man.initialise_bomberman(array)
					bomb.setdead(False)
				else:
					cprint("GAME OVER! :'(",'red', attrs = ['bold'])
					sys.exit()

			flag = 0
		elif flag != 0:
			flag = flag + 1
		else:
			pass
		b.print_board()
		b.clearblast()
		b.set_wall()
		if count == 1:
			count = 0
		enemyx = enemy.getx()
		enemyy = enemy.gety()
		manx = man.getx()
		many = man.gety()
		if manx == enemyx and (many == enemyy + 4 or many == enemyy - 4 or many == enemyy):
			man.decrementlives()
			if (man.getlives() != 0):
				man.clear_bomberman(array)
				man.afterdeath()
				man.initialise_bomberman(array)
			else:
				print("GAME OVER! :'(")
				sys.exit()
				
		elif many == enemyy and (manx == enemyx + 2 or manx == enemyx - 2 or manx == enemyx):		#to check whether the enemy is killing the bomberman or not :P
			man.decrementlives()
			if (man.getlives() != 0):
				man.clear_bomberman(array)
				man.afterdeath()
				man.initialise_bomberman(array)
			else:
				print("GAME OVER! :'(")
				sys.exit()
		else:
			pass
		enemy.enemy_motion(array)			#bomb doing shit :/
		inp = click.getchar()
		if inp == 'b' and flag == 0:
			flag = flag + 1
			bomb.get_bomb_coordinates(array,man)	
		elif inp == 'q':
			cprint("You have quit!",'red',attrs=['bold'])
			sys.exit()
		else:
			val = man.movement(array,inp)
			if flag != 0 and val == 1:
				bomb.set_bomb(array,3-flag)