Ejemplo n.º 1
0
 def __init__(self, gameDisplay):
     self.gameDisplay = gameDisplay
     self.towers = [
         tower.Tower(gameDisplay, 150, 400, (255, 0, 0)),
         tower.Tower(gameDisplay, 400, 400, (0, 255, 0)),
         tower.Tower(gameDisplay, 650, 400, (0, 0, 255))
     ]
     firstTower = self.towers[0]
     firstTower.addDisc(disc.Disc(150, (125, 125, 125)))
     firstTower.addDisc(disc.Disc(100, (125, 125, 0)))
     firstTower.addDisc(disc.Disc(50, (125, 0, 0)))
Ejemplo n.º 2
0
    def init_matrix(self):
        """
        The Matrix has you
        """

        self.db("Initializing matrix")

        self.frames = [(Image.new("RGB", (self.cols, self.rows), "black"), 0)]

        if self.disc:
            self._disc = disc.Disc(mock=self.mock)
            self.dot_frames = [(self._disc.sample_image(self.frames[0][0]), 0)]
        else:
            if self.mock:
                from mock import RGBMatrix, RGBMatrixOptions
            else:
                from rgbmatrix import RGBMatrix, RGBMatrixOptions

            options = RGBMatrixOptions()
            options.cols = self.cols
            if self.decompose:
                options.rows = int(self.rows / 2)
                options.chain_length = 2
            else:
                options.rows = self.rows
                options.chain_length = 1
            options.parallel = 1
            options.gpio_slowdown = 2
            options.hardware_mapping = (
                "adafruit-hat-pwm"  # If you have an Adafruit HAT: "adafruit-hat" or "adafruit-hat-pwm"
                # https://github.com/hzeller/rpi-rgb-led-matrix#troubleshooting
            )
            self.matrix = RGBMatrix(options=options)

        self.show()
Ejemplo n.º 3
0
async def card_response(context: TurnContext) -> web.Response:
    response = context.activity.text.strip()
    obj = disc.Disc(response)
    cred, ementa = obj.crawl()
    card = create_thumbnail_card(cred, ementa)
    response = await create_reply_activity(context.activity, '', card)
    await context.send_activity(response)
    return web.Response(status=200)
Ejemplo n.º 4
0
 def getSmall(self):
     return disc.Disc(24, self.referenceX, 'RED')
Ejemplo n.º 5
0
 def getLarge(self):
     return disc.Disc(48, self.referenceX, 'BLUE')
Ejemplo n.º 6
0
 def getMedium(self):
     return disc.Disc(36, self.referenceX, 'GREEN')
Ejemplo n.º 7
0
def main(poczatek,poz):
    
    start_ticks=pygame.time.get_ticks()
    lev = 0
    n = 3
    score1=0
    score2 = 0 
    t= 0
    l3= 0 
    
    ball.Bonus.image = const.load_image(const.bonus_image[0],-1)
    
    level.Net.levels = [const.load_image(const.kostka), const.load_image(const.kostka1),const.load_image(const.kostka2),const.load_image(const.kostka3),const.load_image(const.kostka4)]
    level.Net2.levels = [const.load_image(const.kostka), const.load_image(const.kostka1),const.load_image(const.kostka2),const.load_image(const.kostka3),const.load_image(const.kostka4)]
    level.Net3.levels = [const.load_image(const.kostka), const.load_image(const.kostka1),const.load_image(const.kostka2),const.load_image(const.kostka3),const.load_image(const.kostka4)]

    clock = pygame.time.Clock()
    pygame.display.set_caption('Arkanoid by Mateusz')
    levels = const.levels[poz]
    board = level.Level(levels)
    screen.blit(board.background, (0, 0))
   
    pygame.display.flip()  

    while poczatek: 
        disc.Disc.image = const.load_image(const.d)
        ball.Ball.image = const.load_image(const.b, -1)
        speed = const.speed_time
        balls = pygame.sprite.Group()
        bricks = pygame.sprite.Group()
        bricks2 = pygame.sprite.Group()
        bricks3 = pygame.sprite.Group()
        bonus = pygame.sprite.Group()
        
        all = pygame.sprite.RenderUpdates()
    
        disc.Disc.containers = all
        ball.Ball.containers = all, balls
        level.Net.containers = all, bricks
        level.Net2.containers = all, bricks2
        level.Net3.containers = all, bricks3

        ball.Bonus.containers = all, bonus
        
        paddle = disc.Disc(board)
        
        b = ball.Ball(board, paddle, bricks,bricks2,bricks3,n)   
       
        board.draw_level(lev)
        var = [False, False]

        running = True
        run = False 
        run2 = False

        l2=0
        check_live = 3
       
        while running:
                
                l1 = b.live
                live = l1 + l2 + l3
                
                if live != check_live:
                    disc.Disc.image = const.load_image(const.d)
                    ball.Ball.image = const.load_image(const.b,-1)
                    speed = const.speed_time
                    
                if b.start_bonus != 0:
                    
                    if b.start_bonus.liv ==1 or b.start_bonus.liv==-1:
                        l2= b.start_bonus.liv
                        
                    if b.start_bonus.liv == 30:
                        speed = 30
                        disc.Disc.image = const.load_image(const.d3)
                        ball.Ball.image = const.load_image(const.b3,-1)
                        
                    if b.start_bonus.liv==120:
                        speed = 120
                        disc.Disc.image = const.load_image(const.d2)
                        ball.Ball.image = const.load_image(const.b2,-1)
                        
                    if b.start_bonus.liv ==100:
                        score2 += b.start_bonus.liv
                    if b.start_bonus.liv==-100:
                        score1 += b.start_bonus.liv
                        
                check_live = live 
                             
                if board.count == b.count2:
                    lev+=1
                    n =  live
                    run2 = True
                    break
    
                if live == 0 :
                    run = True 
                    break

                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                       menu()

                    if event.type == pygame.KEYDOWN:
                        if event.key == pygame.K_ESCAPE:
                            menu()
                        if event.key == pygame.K_r:                                           
                            l3 -= 1
                            n =  live
                            run2 = True
                            running = False
                                                        
                        if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
                            start_ticks1=pygame.time.get_ticks()
                            while 1: 
                                event = pygame.event.wait()
                                pygame.display.set_caption("Pause")
                                
                                if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
                                    pygame.display.set_caption('Arkanoid by Mateusz')
                                    t += round((-start_ticks1+pygame.time.get_ticks())/1000)
                                    break
                                
                                if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                                   menu()
                                   
                        if event.key == pygame.K_RIGHT:
                            var[0] = True
                        if event.key == pygame.K_LEFT: 
                            var[1] = True 
                            
                                                   
                    if event.type == pygame.KEYUP:
                        if event.key == pygame.K_RIGHT:
                            pygame.display.update()
                            var[0] = False
                        if event.key == pygame.K_LEFT:
                            pygame.display.update()
                            var[1] = False
                if var[0]: #inaczj trzeba było klikac 
                    paddle.move_right() 
                if var[1]:
                    paddle.move_left()
                                    
                screen.fill(pygame.Color("yellow"), (0, 0, 900, 30))     
                all.clear(screen, board.background)
                all.update()

                dirty = all.draw(screen)
                pygame.display.update(dirty)
                
                score =round((-start_ticks+pygame.time.get_ticks())/1000)  + score1 + score2 -t
                
                myfont = pygame.font.SysFont(const.font, 45)  
                myfont2 = pygame.font.SysFont(const.font, 25) 
                label = myfont.render("                         Level: " + str(lev+1) + "        Lives: "+str(live)+'       Score: '+ str(score), 1, (0,0,0),board.background)
                label2 = myfont2.render(str(const.POZ[poz]), 1, (0,0,0),board.background)
                
                screen.blit(label, (0,0))
                screen.blit(label2, (0,8))
                pygame.display.flip()
                screen.fill(pygame.Color("black"), (0, 0, 0, 0))    
    
                clock.tick(speed)
            

        while run:
            sound = const.load_sound('lost.wav')
            sound.play()   
            
            all.clear(screen, board.background)
            screen.fill((255,0,0))
            myfont = pygame.font.SysFont(const.font, 85)
            label = myfont.render("Game over :( ", 1, (255,255,255))
            screen.blit(label, (300,300))
            pygame.display.flip()    
            pygame.display.update()
            
            for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        sound.stop()
                        menu()
    
                    if event.type == pygame.KEYDOWN:
                        if event.key == pygame.K_ESCAPE:
                            sound.stop()
                            menu()
                            
        while run2:
            
            if lev == len(levels):
                sound = const.load_sound('win.wav')
                sound.play()
                all.clear(screen, board.background)
                screen.fill((0,255,0))
                myfont = pygame.font.SysFont(const.font, 85)
                label = myfont.render("You win :)", 1, (255,255,255))
                screen.blit(label, (300,300))
                pygame.display.flip()    
                pygame.display.update()

                for event in pygame.event.get():
                        if event.type == pygame.QUIT:
                            high_scores_filename = 'high_scores.dat'
                            scores = []
                            if os.path.exists(high_scores_filename):
                                with open(high_scores_filename,'rb') as rfp: 
                                    scores = pickle.load(rfp)
                                                
                            first_name = input("Please enter your name:")
                            scor = score
                                            
                            high_scores = scor, const.POZ[poz] ,first_name
                            scores.append(high_scores)
                                            
                            with open(high_scores_filename,'wb') as wfp:
                                pickle.dump(scores, wfp)
                                
                            sound.stop()
                            menu()
        
                        if event.type == pygame.KEYDOWN:
                            if event.key == pygame.K_ESCAPE:
                                high_scores_filename = 'high_scores.dat'
                                scores = []
                                if os.path.exists(high_scores_filename):
                                    with open(high_scores_filename,'rb') as rfp: 
                                        scores = pickle.load(rfp)
                                                
                                first_name = input("Please enter your name:")
                                scor = score
                                                
                                high_scores = scor,const.POZ[poz], first_name
                                scores.append(high_scores)
                                                
                                with open(high_scores_filename,'wb') as wfp:
                                    pickle.dump(scores, wfp)
                                sound.stop()
                                menu()
                                
                
            else:
                
                all.clear(screen, board.background)
                running=True 
                run2 = False