Hi, I am trying to make a brick breaker game, but I am stuck. i need help moving the panel, and getting the ball to bounce off of bricks upon collision and erase the bricks.
Also I wanted to create two lists, one that contains coordinates, the second would be an empty list, which would read the coordinates, and then create a brick, then add it to that empty list, I am just unsure on how to do this.
here is my outline code
from visual import*
scene.title = 'brick'
scene.range=10
brick1=box(pos=(-5,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick2=box(pos=(-4,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick3=box(pos=(-3,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick4=box(pos=(-2,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick5=box(pos=(-1,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick6=box(pos=(0,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick7=box(pos=(1,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick8=box(pos=(2,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick9=box(pos=(3,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick10=box(pos=(4,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick11=box(pos=(5,9,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick12=box(pos=(-4,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick13=box(pos=(-3,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick14=box(pos=(-2,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick15=box(pos=(-1,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick16=box(pos=(0,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick17=box(pos=(1,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick18=box(pos=(2,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick19=box(pos=(3,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
brick20=box(pos=(4,8,0), length=1, height=1, width=1, color=color.white, material=materials.marble)
ball=sphere(color=color.cyan, pos=vector(0,0,0), radius=0.2)
ball.velocity = vector(0,-1,0)
delta_t= 0.01
panel=box(pos=(0,-9,0), length=2, height=0.5, width=0, color=color.white)
panel.velocity = vector(1,0,0)
while True:
rate(300)
ball.pos= ball.pos + ball.velocity*delta_t
if ball.y<10:
ball.velocity.y=-ball.velocity.y
if ball.y >= panel.y +.5 and ball.x<= panel.x+1 and ball.x >= panel.x-1 :
ball.velocity.y= -ball.velocity.y
if scene.kb.keys:
s=scene.kb.getkey()
if s == 'right':
panel.pos.x = panel.pos.x + 0.2
if s == 'left':
panel.pos.x = panel.pos.x - 0.2
if ball.y >= 7 and ball.x >.5 and ball.x <.5:
ball.velocity.y=-ball.velocity.y
if ball.y <= -10:
break
print "Game Over"