Esempio n. 1
0
 def put_message(self):
     message = "Balls : %d" % (self.n)
     text = self.Font.render(message, True, (0, 0, 255))
     screen.blit(text, (100, int(.9 * screen.get_height())))
     display.update(
         [[0, int(screen.get_height() * .9)],
          [int(screen.get_width() / 2),
           int(screen.get_height() * .1)]])
Esempio n. 2
0
 def draw(self):
     screen.fill(color_black)
     draw.rect(screen, color_white, [[0,0],[int(screen.get_width()),int(screen.get_height()*.9)]])
     self.target.draw()
     self.player.draw()
     for ball in self.balls:
         ball.draw()
     display.update([[0,0],[int(screen.get_width()),int(screen.get_height()*.9)]])
Esempio n. 3
0
 def put_message(self):
     message = "Balls : %2d    Score : %3d    High : %3d" % (
         self.n, self.score, self.high)
     text = self.Font.render(message, True, (0, 0, 255))
     screen.blit(text, (screen.get_width() / 2 - text.get_width() / 2,
                        int(.9 * screen.get_height())))
     display.update(
         [[0, int(screen.get_height() * .9)],
          [int(screen.get_width()),
           int(screen.get_height() * .1)]])
Esempio n. 4
0
 def draw(self):
     screen.fill(color_black)
     draw.rect(
         screen, color_white,
         [[0, 0], [int(screen.get_width()),
                   int(screen.get_height() * .9)]])
     self.target.draw()
     self.player.draw()
     for ball in self.balls:
         ball.draw()
     display.update(
         [[0, 0], [int(screen.get_width()),
                   int(screen.get_height() * .9)]])
Esempio n. 5
0
 def bounce(self):
     if self.width / 2 > self.x:
         self.x = self.width / 2
         self.dx = -self.dx
     if screen.get_width() - self.width / 2 < self.x:
         self.x = screen.get_width() - self.width / 2
         self.dx = -self.dx
     if self.height / 2 > self.y:
         self.y = self.height / 2
         self.dy = -self.dy
     if screen.get_height() * .9 - self.height / 2 < self.y:
         self.y = screen.get_height() * .9 - self.height / 2
         self.dy = -self.dy
Esempio n. 6
0
 def bounce(self):
     if self.width/2 > self.x:
         self.x = self.width/2
         self.dx = -self.dx
     if screen.get_width()-self.width/2 < self.x:
         self.x = screen.get_width()-self.width/2
         self.dx = -self.dx
     if self.height/2 > self.y:
         self.y = self.height/2
         self.dy = -self.dy
     if screen.get_height()*.9-self.height/2 < self.y:
         self.y = screen.get_height()*.9-self.height/2
         self.dy = -self.dy
Esempio n. 7
0
 def __init__(self,position=Vector2(0,0),velocity=Vector2(0,0)):
     self.pic = image.load('images/planet.png')
     self.size  = Vector2(self.pic.get_width(),self.pic.get_height())
     x = ( screen.get_width()*.3 + random()*screen.get_width()*.4 )
     y = ( screen.get_height()*.4 + random()*screen.get_height()*.2 )
     dx = (randrange(-100,100)*0.01)
     dy = (randrange(-100,100)*0.01)
     self.position = position if position else Vector2(float(x),float(y))
     self.position_int = Vector2(0,0)
     self.velocity = velocity if  velocity else Vector2(dx,dy)
     if randint(0,1):
         self.mass = randint(1,10)
     else:
         self.mass = randint(20,30)
         self.velocity/=1.0
Esempio n. 8
0
 def __init__(self, position=Vector2(0, 0), velocity=Vector2(0, 0)):
     self.pic = image.load('images/planet.png')
     self.size = Vector2(self.pic.get_width(), self.pic.get_height())
     x = (screen.get_width() * .3 + random() * screen.get_width() * .4)
     y = (screen.get_height() * .4 + random() * screen.get_height() * .2)
     dx = (randrange(-100, 100) * 0.01)
     dy = (randrange(-100, 100) * 0.01)
     self.position = position if position else Vector2(float(x), float(y))
     self.position_int = Vector2(0, 0)
     self.velocity = velocity if velocity else Vector2(dx, dy)
     if randint(0, 1):
         self.mass = randint(1, 10)
     else:
         self.mass = randint(20, 30)
         self.velocity /= 1.0
Esempio n. 9
0
 def __init__(self,x=0,y=0):
     self.pic = image.load('images/ball.png')
     self.width = self.pic.get_width()
     self.height = self.pic.get_height()
     self.x = self.width  + randrange( 0,ceil((screen.get_width()  - x)    - 2*self.width ) )
     self.y = self.height + randrange( 0,ceil((screen.get_height() - y)*.9 - 2*self.height) )
     self.dx = (random()*2)
     self.dy = (random()*2)
Esempio n. 10
0
 def __init__(self):
     self.pic = image.load('images/ball.png')
     self.width = self.pic.get_width()
     self.height = self.pic.get_height()
     self.x = self.width  + floor( random()*(screen.get_width()     - 2*self.width ) )
     self.y = self.height + floor( random()*(screen.get_height()*.9 - 2*self.height) )
     self.dx = (random()*3)
     self.dy = (random()*3)
Esempio n. 11
0
 def __init__(self):
     self.pic = image.load('images/ball.png')
     self.width = self.pic.get_width()
     self.height = self.pic.get_height()
     self.x = self.width + floor(random() *
                                 (screen.get_width() - 2 * self.width))
     self.y = self.height + floor(
         random() * (screen.get_height() * .9 - 2 * self.height))
     self.dx = (random() * 3)
     self.dy = (random() * 3)
Esempio n. 12
0
 def __init__(self, x=0, y=0):
     self.pic = image.load('images/ball.png')
     self.width = self.pic.get_width()
     self.height = self.pic.get_height()
     self.x = self.width + randrange(
         0, ceil((screen.get_width() - x) - 2 * self.width))
     self.y = self.height + randrange(
         0, ceil((screen.get_height() - y) * .9 - 2 * self.height))
     self.dx = (random() * 2)
     self.dy = (random() * 2)
Esempio n. 13
0
 def put_message(self):
     message = "Balls : %2d    Score : %3d    High : %3d"%(self.n,self.score,self.high)
     text = self.Font.render(message, True, (0, 0, 255))    
     screen.blit(text, (screen.get_width()/2 - text.get_width()/2,int(.9*screen.get_height())))
     display.update([[0,int(screen.get_height()*.9)],[int(screen.get_width()),int(screen.get_height()*.1)]])
Esempio n. 14
0
 def draw(self):
     screen.fill((0,0,0))
     for planet in self.planets.values():
         planet.draw()
     display.update([[0,0],[screen.get_width(),screen.get_height()]])
Esempio n. 15
0
 def new(self):
     self.x = self.width + floor(random() *
                                 (screen.get_width() - 2 * self.width))
     self.y = self.height + floor(
         random() * (screen.get_height() * .9 - 2 * self.height))
Esempio n. 16
0
 def draw(self):
     screen.fill((0, 0, 0))
     for planet in self.planets.values():
         planet.draw()
     display.update([[0, 0], [screen.get_width(), screen.get_height()]])
Esempio n. 17
0
 def new(self):
     self.x = self.width  + floor( random()*(screen.get_width()  - 2*self.width ) )
     self.y = self.height + floor( random()*(screen.get_height()*.9 - 2*self.height) )                       
Esempio n. 18
0
 def put_message(self):
     message = "Balls : %d"%(self.n)
     text = self.Font.render(message, True, (0, 0, 255))    
     screen.blit(text, (100,int(.9*screen.get_height())))
     display.update([[0,int(screen.get_height()*.9)],[int(screen.get_width()/2),int(screen.get_height()*.1)]])