예제 #1
1
def new():
    global arr, e1, e2, e3, e4, bm, f1, f2, brick
    #create walls
    w = Walls()
    arr = w.structure()
    #flags use for bomb
    f1 = False
    f2 = False
    #random number of bricks
    num = random.randint(15, 25)
    for i in range(0, num):
        brick = Bricks(arr)
        arr = brick.place_brick()
    #four enemies
    e1 = Enemy(arr)
    e2 = Enemy(arr)
    e3 = Enemy(arr)
    e4 = Enemy(arr)
    #create bomberman instance
    bm = Bomberman(arr)
    arr = bm.place(arr, 4, 2)
    #create board instance
    b = Board(arr, lives, score)
    b.print_board()
예제 #2
0
 def __init__(self, rows, columns, brickslimit):
     self.rows = rows
     self.columns = columns
     self._brickslimit = brickslimit
     Walls.__init__(self, 2, 4)
     Bricks.__init__(self, 2, 4)
     self.enemies = []
예제 #3
0
 def __init__(self, rows, columns, brickslimit, length, width):
     self.rows = rows
     self.columns = columns
     # Bricks limit indicates max amount of bricks placed in the board
     self._brickslimit = brickslimit
     Walls.__init__(self, length, width)
     Bricks.__init__(self, length, width)
     self.enemies = []
예제 #4
0
 def setUp(self):
     self.pbricks = Bricks()
     for c in [
         Settings,
         StaticManager,
         testcss,
         testjs,
         externaljs,
         externalcss
     ]:
         self.pbricks.add(c)
예제 #5
0
 def __init__(self, vari):
     self.vari = vari
     self.c1 = Bricks(42, 84, 50)
     self.Board = self.c1.board_after_bricks()
     self.cnt = self.c1.return_count()
     self.enemy_array = self.c1.enemy_array()
     self.enemy_array1 = self.c1.enemy_array1()
     self.x_v = 2
     self.y_v = 4
     self.x_b = 2
     self.y_b = 4
     #self.game_over=0
     self.score = 0
     self.score1 = 0
     self.l11 = self.cnt
예제 #6
0
def start_game():
    global tk
    tk = Tk()
    tk.title("Bounce !!")
    tk.resizable(0, 0)
    tk.wm_attributes("-topmost", 1)
    canvas = Canvas(tk,
                    width=500,
                    height=500,
                    bg="Black",
                    highlightthickness=0)
    canvas.pack()
    tk.update()

    paddle = Paddle(canvas, "Blue")
    bricks = Bricks(canvas, "Green")
    ball = Ball(canvas, paddle, bricks, "red")
    while True:
        if ball.hit_bottom == False and len(bricks.recs) > 0:
            ball.draw()
            paddle.draw()
        elif len(bricks.recs) == 0:
            flag = 1
            break
        elif ball.hit_bottom:
            flag = 2
            break
        tk.update_idletasks()
        tk.update()
        time.sleep(0.05)

    return flag
예제 #7
0
 def setUp(self):
     bricks = Bricks()
     self.settings = bricks.add(MockSettings)
     bricks.add(StaticManager)
     self.testscss = bricks.add(testscss)
     bricks.add(testlib)
     self.bricks = bricks
예제 #8
0
class TestSqliteComponent(unittest.TestCase):
    def setUp(self):
        self.bricks = Bricks()
        self.bricks.add(Settings)
        self.pool = self.bricks.add(SqliteThreadPool)
        self.db = self.bricks.add(DatabaseComponent)

    def test_trivial(self):
        with self.db.cursor as cursor:
            pass
        self.assertEqual(len(self.pool.connections), 1)

    def testExec(self):
        with self.db.cursor as cursor:
            cursor.execute("SELECT 1, 'two';")
            result = cursor.fetchone()
        self.assertEqual(result, (1, 'two'))
        self.assertEqual(len(self.pool.connections), 1)

    def testPool(self):
        import threading
        lock = threading.Lock()
        connections = set()
        threads = set()
        lock.acquire()
        def target():
            c = self.pool.getconn()
            connections.add(c)
            lock.acquire()
            self.pool.putconn(c)
            lock.release()
        for i in range(3):
            t = threading.Thread(target=target)
            t.start()
            threads.add(t)
        lock.release()
        for thread in threads:
            thread.join()
        self.assertEqual(len(connections), 3)
        self.assertEqual(len(self.pool.connections), 3)
예제 #9
0
class TestStaticBuilder(unittest.TestCase):
    def setUp(self):
        self.pbricks = Bricks()
        for c in [
            Settings,
            StaticManager,
            testcss,
            testjs,
            externaljs,
            externalcss
        ]:
            self.pbricks.add(c)

    def tearDown(self):
        self.pbricks.components['json_settings'].cleanup()

    def testSimpleStaticCopy(self):
        establish_static_assets(self.pbricks)
        out_dir = self.pbricks.components['json_settings']['served_static_dir']
        ftests = [
            ('css/style.css', 'body{background-color: teal;}\n'),
            ('js/what.js', 'function(){};\n')
        ]
        for fname, contents in ftests:
            match = file_contents_match(join(out_dir, fname), contents)
            self.assertTrue(match)

    def testAssetUrls(self):
        js = self.pbricks.components[testjs]
        css = self.pbricks.components[testcss]
        ext_css = self.pbricks.components[externalcss]
        asseturls = [
            (js, 'http://localhost:8888/js/what.js'),
            (css, 'http://localhost:8888/css/style.css'),
            (ext_css, 'http://www.somecdn.com/style.css'),
        ]
        for asset, url in asseturls:
            self.assertEqual(asset.get_url(), url)
예제 #10
0
 def populate_board_with_bricks(self, grid):
     '''
         Populates the board with bricks at random positions using random number
     '''
     count = 0
     for i in range(2, self.rows - 2):
         if i % 2 == 0:
             for j in range(4, self.columns - 4):
                 if j % 4 == 0 and grid[i][j] != 'X':
                     if self.brick_nested_condition(i, j, count):
                         brick = Bricks(4, 2)
                         temp = brick.brick
                         grid = self.populate_board_with_element(
                             i, j, grid, temp)
                         count = count + 1
     return grid
예제 #11
0
 def PopulateBoardWithBricks(self, Grid):
     count = 0
     for i in range(2, self.rows - 2):
         if i % 2 == 0:
             for j in range(4, self.columns - 4):
                 if j % 4 == 0 and Grid[i][j] != 'X':
                     # bricks are populated based on a random number
                     if (random() > 0.7 and count < self.GetBrickslimit()
                             and (i != 2 or j != 4) and (i != 2 or j != 8)
                             and (i != 4 or j != 4)):
                         brick = Bricks(4, 2)
                         temp = brick.Brick
                         Grid = self.PopulateBoardWithElement(
                             i, j, Grid, temp)
                         count = count + 1
     return Grid
예제 #12
0
        signal.alarm(0)
        return text
    except AlarmException:
        os.system('clear')
        b.output(disp)
        print("Your Score is %d" % score)
    signal.signal(signal.SIGALRM, signal.SIG_IGN)
    return ''


player = Bomberman()  # different objects being created
b = Board()
b.display(disp)
e = Enemy()
u = Bomb()
s = Bricks()
e.generate_enemies(disp, 10)  # enemies being generated
for i in range(
        10
):  # if you want more enemies just change the number 10 in this and above line
    e.change(i, disp)
s.generate_bricks(disp)  # brikcs being generated
player.start(disp)
b.output(disp)
planted = 0  # different variables for various purposes
count = 0
flag = 0
die = 0
won = 1
score = 0
enemieskilled = 0
예제 #13
0
import time
from turtle import Turtle, Screen
from paddle import Paddle
from bricks import Bricks
from ball import Ball
from scoreboard import Scoreboard

screen = Screen()
screen.title("Ping Pong")
screen.bgcolor("black")
screen.setup(width=800, height=800)
screen.listen()
screen.tracer(0)

paddle = Paddle()
brick = Bricks()
brick.put_bricks()
ball = Ball()
scoreboard = Scoreboard()

screen.onkey(paddle.go_right, "Right")
screen.onkey(paddle.go_left, "Left")

game_is_on = True
while game_is_on:
    screen.update()
    time.sleep(0.1)
    ball.move()

    if ball.ycor() >= 380:
        ball.bounce_from_ceiling()
예제 #14
0
os.system('aplay song.wav &')
B = Board()
M = Mario()
M.generate_mario()
M.generate_boss(25, 420, B.left(), B.right())

for i in range(20, 400, 100):
    B.cloud_make(10, i)
    B.cloud_make(10, i + 50)
    B.mountain_make(16, i + 30)
    B.pit_make(i)
    B.pillar_make(i + 60)
    for j in range(0, 10):
        if j % 2:
            B.coin_make(25, i + j + 40)
    Bricks.make_brick(18, i + 20, B.left(), B.right())
    en_arr = [25, i + 10, B.left(), B.right()]
    M.generate_enemy(en_arr)
FT = time.time()
C = 0
BFT = time.time()
B.powerup(25, 40)
while True:
    os.system("tput reset")
    M.print_scolife()
    B.print_board()
    if time.time() > FT + 1 and time.time() - FT < 2 and M.stat():
        C += 1
        if C % 13 <= 6:
            M.move_enemy(25, B.left(), B.right(), '+')
        else:
예제 #15
0
from input import Get, input_to
from clouds import *
from flag import *
from mario import *

brd = Board(19,600)
Walls.placeWalls(brd)
l = brd.length
Brick_coordinates = [[12,28,1],[12,40,1],[12,56,1],[12,48,1],[12,52,2],[12,44,1],[6,48,1],[12,264,1],[12,268,1],[12,272,2],[6,276,1],[6,280,1],[6,284,1],[6,288,1],[6,292,1],[6,304,1],[6,308,1],[6,312,1],[6,316,1],[12,316,1],[12,324,1],[12,328,1],[12,338,1],[12,348,1],[12,358,1],[6,348,1],[12,370,1],[6,374,1],[6,378,1],[6,381,1],[6,393,1],[6,397,1],[6,401,1],[6,405,1],[12,397,1],[12,401,1],[12,522,1],[12,526,1],[12,530,1],[12,534,1]]
Pipe_coordinates = [[brd.length-8,68],[brd.length-8,110],[brd.length-8,152],[brd.length-8,200],[l-8,510],[l-8,550]]
Holes_coordinates = [[brd.length-2,248],[brd.length-2,290],[l-2,486],[l-2,488]]
Stair_coordinates = [[brd.length-4,418],[brd.length-4,422],[brd.length-4,426],[brd.length-4,430],[brd.length-6,422],[l-6,426],[l-6,430],[l-8,426],[l-8,430],[l-10,430],[brd.length-4,454],[brd.length-4,450],[brd.length-4,446],[brd.length-4,442],[brd.length-6,450],[l-6,446],[l-6,442],[l-8,446],[l-8,442],[l-10,442],[l-4,466],[l-4,470],[l-4,474],[l-4,478],[l-4,482],[l-6,470],[l-6,474],[l-6,478],[l-6,482],[l-8,474],[l-8,478],[l-8,482],[l-10,478],[l-10,482],[l-4,492],[l-4,496],[l-4,500],[l-4,504],[l-6,492],[l-6,496],[l-6,500],[l-8,492],[l-8,496],[l-10,492],[l-4,554],[l-4,558],[l-4,562],[l-4,566],[l-4,570],[l-4,574],[l-6,558],[l-6,562],[l-6,566],[l-6,570],[l-6,574],[l-8,562],[l-8,566],[l-8,570],[l-8,574],[l-10,566],[l-10,570],[l-10,574],[l-12,570],[l-12,574],[l-14,574]]
Enem_coordinates = [[l-4,120],[l-4,208],[l-4,124,-1],[l-4,240],[l-4,255,-1],[l-4,270,1],[l-4,305],[l-4,310],[l-4,370,-1],[l-4,520]]
Cloud_coordinates = [[0,10],[0,75],[0,100],[0,150],[0,230],[0,350],[0,400],[0,450],[0,500],[0,550]]
for cord in Brick_coordinates:
	bricks = Bricks(2,4,cord[2])
	bricks.setPosition(cord[0],cord[1])
	bricks.placebrick(brd)
	Rem.lis.append(bricks)

for cord in Pipe_coordinates:
	bricks = Pipes(6,4)
	bricks.setPosition(cord[0],cord[1])
	bricks.placebrick(brd)

for cord in Holes_coordinates:
	bricks = Holes(2,4)
	bricks.setPosition(cord[0],cord[1])
	bricks.placebrick(brd)

for cord in Stair_coordinates:
예제 #16
0
    'Score: ' + str(score) + "       " + "Lives " + str(lives), True,
    (255, 255, 255), (0, 0, 0))
textrect = text.get_rect()
textrect.x = 0
textrect.y = 1

all_sprites_list = pygame.sprite.Group()
paddle = Paddle(GREEN, 40, 10, 300, 470)
all_sprites_list.add(paddle)

brick_list = []
for i in range(4):
    y = i * 10 + 22
    for i in range(16):
        x = i * 40
        brick = Bricks(RED, 39, 9, x, y)
        brick_list.append(brick)
        all_sprites_list.add(brick)

while 1:
    all_sprites_list.update()
    for event in pygame.event.get():
        if event.type == pygame.QUIT: sys.exit()

    ballrect = ballrect.move(speed)
    if ballrect.left < 0 or ballrect.right > width:
        speed[0] = -speed[0]
    if ballrect.top < 0:
        speed[1] = -speed[1]
    elif ballrect.top > height:
        lives = lives - 1
예제 #17
0
from turtle import Screen
from paddle import Paddle
from scoreboard import Scoreboard
from ball import Ball
from bricks import Bricks

screen = Screen()
screen.bgcolor("black")
screen.title("Breakout Baby")
screen.setup(width=600, height=800)
screen.tracer(0)

paddle = Paddle()
bricks = Bricks()
scoreboard = Scoreboard()
bricks.make_bricks()
ball = Ball()


def brick_collision():
    for brick in bricks.brick_list:
        if ball.distance(brick) < 30:
            bricks.brick_list.remove(brick)
            brick.hideturtle()
            ball.bounce_y()
            scoreboard.point(brick)


def bounce():
    if paddle.distance(ball) < 50 and ball.ycor() < -270:
        ball.bounce_y()
예제 #18
0
파일: application.py 프로젝트: Zer0-/listrr
    DatabaseComponent
)

def make_length_verifier():
    from listrr.listid import gen_list_uuid
    correct_length = len(gen_list_uuid(settings['list_uuid_size']))
    def lenverify(s):
        return len(s) == correct_length
    return lenverify

uuid_length = make_length_verifier()

api_route = Route('api', handler=Api)
routemap = Route('home', handler=Homepage) + {
    uuid_length: Route('list', handler=ListView),
    'api': api_route + {
        uuid_length: api_route
    }
}

class Main(BaseMC):
    depends_on = [routemap]

bricks = Bricks()

for c in components:
    bricks.add(c)

main = bricks.add(Main)
application = wsgi(main)
예제 #19
0
screen.bgcolor('black')
screen.setup(width=800, height=600)
screen.title('Breakout')
screen.tracer(0)

paddle = Paddle(0)
ball = Ball()
bricks = []
score_keeper = Scorekeeper()
life_keeper = Lifekeeper()

starting_brick_x_position = -354
starting_brick_y_position = 240
for _ in range(11):
    bricks.append(
        Bricks(starting_brick_x_position, starting_brick_y_position, 1, 3))
    starting_brick_x_position += 70

second_brick_x_position = -375
second_brick_y_position = 210
for _ in range(16):
    bricks.append(
        Bricks(second_brick_x_position, second_brick_y_position, 1, 2))
    second_brick_x_position += 50

third_brick_x_position = -354
third_brick_y_position = 180
for _ in range(11):
    bricks.append(Bricks(third_brick_x_position, third_brick_y_position, 1, 3))
    third_brick_x_position += 70
예제 #20
0
# Create Screen
screen = Screen()
screen.setup(width=650, height=600)
screen.bgcolor("black")
screen.title("Atari BREAKOUT")
screen.tracer(0)

# Create paddle object
paddle = Paddle((0, -200))

# Create ball object
ball = Ball()

# Create bricks
bricks = Bricks()

# Create scoreboard
scoreboard = Scoreboard()

# Move paddle left and right
screen.listen()
screen.onkeypress(paddle.move_right, "Right")
screen.onkeypress(paddle.move_left, "Left")

num_of_hits = 0

game_is_on = True
while game_is_on:
    time.sleep(ball.move_speed)
    screen.update()
예제 #21
0
class Board:
    def __init__(self, vari):
        self.vari = vari
        self.c1 = Bricks(42, 84, 50)
        self.Board = self.c1.board_after_bricks()
        self.cnt = self.c1.return_count()
        self.enemy_array = self.c1.enemy_array()
        self.enemy_array1 = self.c1.enemy_array1()
        self.x_v = 2
        self.y_v = 4
        self.x_b = 2
        self.y_b = 4
        #self.game_over=0
        self.score = 0
        self.score1 = 0
        self.l11 = self.cnt

    def place_man(self):
        b2 = Bomberman(2, 4)
        b2 = b2.create_man(self.Board)
        return b2

    def movement(self, direction, x_cor, y_cor, index, type_c):
        if direction == 'a':
            if self.Board[x_cor][y_cor -
                                 4] == '#' or self.Board[x_cor][y_cor -
                                                                4] == '%':
                return self.Board
            else:
                self.Board[x_cor][y_cor] = ' '
                self.Board[x_cor][y_cor + 1] = ' '
                self.Board[x_cor][y_cor + 2] = ' '
                self.Board[x_cor][y_cor + 3] = ' '
                self.Board[x_cor + 1][y_cor] = ' '
                self.Board[x_cor + 1][y_cor + 1] = ' '
                self.Board[x_cor + 1][y_cor + 2] = ' '
                self.Board[x_cor + 1][y_cor + 3] = ' '
                y_cor = y_cor - 4
                if type_c == 1:
                    b2 = Bomberman(x_cor, y_cor)
                    b21 = b2.create_man(self.Board)
                    self.x_v = x_cor
                    self.y_v = y_cor
                    self.x_b = x_cor
                    self.y_b = y_cor
                    return b21
                elif type_c == 2:
                    b3 = Enemy(x_cor, y_cor)
                    b3 = b3.create_enemy(self.Board)
                    self.enemy_array[index] = x_cor
                    self.enemy_array1[index] = y_cor
                    return b3

        elif direction == 'd':
            if self.Board[x_cor][y_cor +
                                 4] == '#' or self.Board[x_cor][y_cor +
                                                                4] == '%':
                return self.Board
            else:
                self.Board[x_cor][y_cor] = ' '
                self.Board[x_cor][y_cor + 1] = ' '
                self.Board[x_cor][y_cor + 2] = ' '
                self.Board[x_cor][y_cor + 3] = ' '
                self.Board[x_cor + 1][y_cor] = ' '
                self.Board[x_cor + 1][y_cor + 1] = ' '
                self.Board[x_cor + 1][y_cor + 2] = ' '
                self.Board[x_cor + 1][y_cor + 3] = ' '
                y_cor = y_cor + 4
                if type_c == 1:
                    b2 = Bomberman(x_cor, y_cor)
                    b21 = b2.create_man(self.Board)
                    self.x_v = x_cor
                    self.y_v = y_cor
                    self.x_b = x_cor
                    self.y_b = y_cor
                    return b21
                elif type_c == 2:
                    b3 = Enemy(x_cor, y_cor)
                    b3 = b3.create_enemy(self.Board)
                    self.enemy_array[index] = x_cor
                    self.enemy_array1[index] = y_cor
                    return b3

        elif direction == 's':
            if self.Board[x_cor +
                          2][y_cor] == '#' or self.Board[x_cor +
                                                         2][y_cor] == '%':
                return self.Board
            else:
                self.Board[x_cor][y_cor] = ' '
                self.Board[x_cor][y_cor + 1] = ' '
                self.Board[x_cor][y_cor + 2] = ' '
                self.Board[x_cor][y_cor + 3] = ' '
                self.Board[x_cor + 1][y_cor] = ' '
                self.Board[x_cor + 1][y_cor + 1] = ' '
                self.Board[x_cor + 1][y_cor + 2] = ' '
                self.Board[x_cor + 1][y_cor + 3] = ' '
                x_cor = x_cor + 2
                if type_c == 1:
                    b2 = Bomberman(x_cor, y_cor)
                    b21 = b2.create_man(self.Board)
                    self.x_v = x_cor
                    self.y_v = y_cor
                    self.x_b = x_cor
                    self.y_b = y_cor
                    return b21
                elif type_c == 2:
                    b3 = Enemy(x_cor, y_cor)
                    b3 = b3.create_enemy(self.Board)
                    self.enemy_array[index] = x_cor
                    self.enemy_array1[index] = y_cor
                    return b3

        elif direction == 'w':
            if self.Board[x_cor -
                          2][y_cor] == '#' or self.Board[x_cor -
                                                         2][y_cor] == '%':
                return self.Board
            else:
                self.Board[x_cor][y_cor] = ' '
                self.Board[x_cor][y_cor + 1] = ' '
                self.Board[x_cor][y_cor + 2] = ' '
                self.Board[x_cor][y_cor + 3] = ' '
                self.Board[x_cor + 1][y_cor] = ' '
                self.Board[x_cor + 1][y_cor + 1] = ' '
                self.Board[x_cor + 1][y_cor + 2] = ' '
                self.Board[x_cor + 1][y_cor + 3] = ' '
                x_cor = x_cor - 2
                if type_c == 1:
                    b2 = Bomberman(x_cor, y_cor)
                    b21 = b2.create_man(self.Board)
                    #	b2.set_x_cor(x_cor)
                    #	b2.set_y_cor(y_cor)
                    self.x_v = x_cor
                    self.y_v = y_cor
                    self.x_b = x_cor
                    self.y_b = y_cor
                    return b21
                elif type_c == 2:
                    b3 = Enemy(x_cor, y_cor)
                    b3 = b3.create_enemy(self.Board)
                    self.enemy_array1[index] = y_cor
                    self.enemy_array[index] = x_cor
                    return b3

    def ret_x_cor_b(self):
        return self.x_v

    def ret_y_cor_b(self):
        return self.y_v

    def ret_x_cor_e(self):
        return self.enemy_array

    def ret_y_cor_e(self):
        return self.enemy_array1

    def enemy_cnt(self):
        return self.cnt

    def enemy_arr(self):
        return self.enemy_array

    def enemy_arr1(self):
        return self.enemy_array1

    def ret_x_cor_bomb(self):
        return self.x_b

    def ret_y_cor_bomb(self):
        return self.y_b

    def game_score(self):
        return self.score

    def bomb(self, x, y, array):
        array[x][y] = 'B'
        array[x][y + 1] = 'B'
        array[x][y + 2] = 'B'
        array[x][y + 3] = 'B'
        array[x + 1][y] = 'B'
        array[x + 1][y + 1] = 'B'
        array[x + 1][y + 2] = 'B'
        array[x + 1][y + 3] = 'B'
        return array

    def blast(self, x, y, array):
        k = self.cnt
        if array[x][y] == '(':
            for i in range(k):
                if self.enemy_array[i] == x and self.enemy_array1[i] == y:
                    self.enemy_array[i] = -1
                    self.enemy_array1[i] = -1
                    self.score = self.score + 100
                    self.l11 = self.l11 - 1
        array[x][y] = '^'
        array[x][y + 1] = '^'
        array[x][y + 3] = '^'
        array[x][y + 2] = '^'
        array[x + 1][y] = '^'
        array[x + 1][y + 1] = '^'
        array[x + 1][y + 3] = '^'
        array[x + 1][y + 2] = '^'

        if array[x][y - 4] != '#':
            if array[x][y - 4] == '(':
                for i in range(k):
                    if self.enemy_array[i] == x and self.enemy_array1[
                            i] == y - 4:
                        self.enemy_array[i] = -1
                        self.enemy_array1[i] = -1
                        self.score = self.score + 100
                        self.l11 = self.l11 - 1

            if array[x][y - 4] == '%':
                self.score = self.score + 20
            array[x][y - 4] = '^'
            array[x][y - 3] = '^'
            array[x][y - 2] = '^'
            array[x][y - 1] = '^'
            array[x + 1][y - 1] = '^'
            array[x + 1][y - 2] = '^'
            array[x + 1][y - 3] = '^'
            array[x + 1][y - 4] = '^'
        if array[x][y + 4] != '#':
            if array[x][y + 4] == '(':
                for i in range(k):
                    if self.enemy_array[i] == x and self.enemy_array1[
                            i] == y + 4:
                        self.enemy_array[i] = -1
                        self.enemy_array1[i] = -1
                        self.score = self.score + 100
                        self.l11 = self.l11 - 1
            elif array[x][y + 4] == '%':
                self.score = self.score + 20

            array[x][y + 4] = '^'
            array[x][y + 5] = '^'
            array[x][y + 6] = '^'
            array[x][y + 7] = '^'
            array[x + 1][y + 4] = '^'
            array[x + 1][y + 5] = '^'
            array[x + 1][y + 6] = '^'
            array[x + 1][y + 7] = '^'
        if array[x - 2][y] != '#':
            if array[x - 2][y] == '(':
                for i in range(k):
                    if self.enemy_array[i] == x - 2 and self.enemy_array1[
                            i] == y:
                        self.enemy_array[i] = -1
                        self.enemy_array1[i] = -1
                        self.score = self.score + 100
                        self.l11 = self.l11 - 1
            elif array[x - 2][y] == '%':
                self.score = self.score + 20

            array[x - 2][y] = '^'
            array[x - 2][y + 1] = '^'
            array[x - 2][y + 2] = '^'
            array[x - 2][y + 3] = '^'
            array[x - 1][y] = '^'
            array[x - 1][y + 1] = '^'
            array[x - 1][y + 2] = '^'
            array[x - 1][y + 3] = '^'
        if array[x + 2][y] != '#':
            if array[x + 2][y] == '(':
                for i in range(k):
                    if self.enemy_array[i] == x + 2 and self.enemy_array1[
                            i] == y:
                        self.enemy_array[i] = -1
                        self.enemy_array1[i] = -1
                        self.score = self.score + 100
                        self.l11 = self.l11 - 1
            elif array[x + 2][y] == '%':
                self.score = self.score + 20

            array[x + 2][y] = '^'
            array[x + 2][y + 1] = '^'
            array[x + 2][y + 2] = '^'
            array[x + 2][y + 3] = '^'
            array[x + 3][y] = '^'
            array[x + 3][y + 1] = '^'
            array[x + 3][y + 2] = '^'
            array[x + 3][y + 3] = '^'
        return array

    def after_blast(self, x, y, array):
        array[x][y] = ' '
        array[x][y + 1] = ' '
        array[x][y + 3] = ' '
        array[x][y + 2] = ' '
        array[x + 1][y] = ' '
        array[x + 1][y + 1] = ' '
        array[x + 1][y + 3] = ' '
        array[x + 1][y + 2] = ' '

        if array[x][y - 4] == '^':
            array[x][y - 4] = ' '
            array[x][y - 3] = ' '
            array[x][y - 2] = ' '
            array[x][y - 1] = ' '
            array[x + 1][y - 1] = ' '
            array[x + 1][y - 2] = ' '
            array[x + 1][y - 3] = ' '
            array[x + 1][y - 4] = ' '

        if array[x][y + 4] == '^':
            array[x][y + 4] = ' '
            array[x][y + 5] = ' '
            array[x][y + 6] = ' '
            array[x][y + 7] = ' '
            array[x + 1][y + 4] = ' '
            array[x + 1][y + 5] = ' '
            array[x + 1][y + 6] = ' '
            array[x + 1][y + 7] = ' '
        if array[x - 2][y] == '^':
            array[x - 2][y] = ' '
            array[x - 2][y + 1] = ' '
            array[x - 2][y + 2] = ' '
            array[x - 2][y + 3] = ' '
            array[x - 1][y] = ' '
            array[x - 1][y + 1] = ' '
            array[x - 1][y + 2] = ' '
            array[x - 1][y + 3] = ' '
        if array[x + 2][y] == '^':
            array[x + 2][y] = ' '
            array[x + 2][y + 1] = ' '
            array[x + 2][y + 2] = ' '
            array[x + 2][y + 3] = ' '
            array[x + 3][y] = ' '
            array[x + 3][y + 1] = ' '
            array[x + 3][y + 2] = ' '
            array[x + 3][y + 3] = ' '
        return array

    def game_end(self):
        return self.l11
예제 #22
0
from render import Render
from player import Player
from ball import Ball
from bricks import Bricks
from bar import Bar

Score = 0
Lives = 9
Time = time.time()
Level = 1

while True:
    screen = Render()
    player = Player(screen)
    ball = Ball(screen, player)
    bricks = Bricks(screen)
    bar = Bar(screen)

    bar.score = Score
    bar.lives = Lives
    bar.level = Level
    bar.start_time = Time

    while True:
        # Restart
        if player.movement(input_to(), screen):
            Score = 0
            Time = time.time()
            Lives = 10
            break
        # Endgame
예제 #23
0
 def setUp(self):
     self.bricks = Bricks()
     self.bricks.add(Settings)
     self.pool = self.bricks.add(SqliteThreadPool)
     self.db = self.bricks.add(DatabaseComponent)