コード例 #1
0
ファイル: logic.py プロジェクト: tankorsmash/Shooter
def key_event(event):
    
    ##WORKING ON THIS: TRY TO MAKE THIS A LIST INSTEAD 
    ## OF ALL THE DIRECTIONS ONE AFTER ANOTHER
    if event.type == pygame.KEYUP:
        #tuple below is directions
        if event.key in keyDirs.keys():
            #for brick in bricks:
                #brick.setMove(moving=False, dir =brick.dir)
            actors.player.go(False)
    elif event.type == pygame.KEYDOWN:
        if event.key in keyDirs.keys():
            

            #print 'keys pressed'
            direction= keyDirs[event.key] 
            actors.player.changeDir(direction)
            actors.player.go(True)


        elif isKey(event, 'n'):
            reload(GUI2)
            print 'reloaded module GUI'
            pass

        elif isKey(event, 'c'):
            actors.player.shooter.fire(actors.player.direction,'bullet')
            print 'FIRED {0} TIMES'.format(actors.player.shooter.timesFired)
            pass 
        
        #clear screen, slopilly.
        elif isKey(event,'RETURN'):
            visuals.screen.fill((0,0,0))

        #elif isKey(event,'z'):
            #print 'circle: ',circle.getPos(), ' bob: ', bob.getPos()
            
        elif isKey(event,'z'):
            if hasattr(GUI2, 'root'):
                print GUI2.root.TEST
            
        #elif isKey(event,'x'):
            #'''check if circle is in bob's rect'''
            #print 'RECTS for circle: ', actors.player.rect.x,\
                                        #actors.player.rect.y,
            #print 'RECTS for bob: ', bob.rect.x,\
                                     #bob.rect.y
             
            #if actors.player.rect.colliderect(bob):
                #print 'COLLISION!!'   
               
        elif isKey(event,'x'):
            print 'player getPos', actors.player.getPos()
                            
                                        
            

        #change animation 
        elif event.key in (pygame.K_0,pygame.K_1,pygame.K_2,
                           pygame.K_3,pygame.K_4,pygame.K_5,
                           pygame.K_6,pygame.K_7,pygame.K_8,
                           pygame.K_9):
            
            keys = {pygame.K_0 :9,
                    pygame.K_1 :0,
                    pygame.K_2 :1,
                    pygame.K_3 :2,
                    pygame.K_4 :3,
                    pygame.K_5 :4,
                    pygame.K_6 :5,
                    pygame.K_7 :6,
                    pygame.K_8 :7,
                    pygame.K_9 :8}
            
            actors.player.curFrameNum = keys[event.key]
            actors.player.curFrame = actors.player.animList[actors.player.curFrameNum].copy()
            actors.player.direction = RIGHT
            actors.player.rotate()
            print 'changed frame'


        elif isKey(event,'m'):
            #func = GUI2.run
            #threading module
            #thread_GUI2 = threading.Thread(group = None, target = func, name='GUI THREAD')
            #thread_GUI2.start()
            
            #no threading
            GUI2.run()
            
            #multiprocessing module
            #thread_GUI2 = multi.Process(target = func, name='GUI THREAD')
            #thread_GUI2.start()
            
            print 'thread ran'
            
        elif isKey(event, 'b'):
            actors.spawner.spawn('mob')
            
        elif isKey(event, 'v'):
            global allGrids
            allGrids = tools.createGrid()
            print allGrids[0].coords, 'is the first grid'
            
        elif isKey(event, 'f'):
            tools.inWhichGrid(actors.player, allGrids)
            stats.lineDraw =  True
            
        elif isKey(event, 't'):
            
            visuals.multiLine('t**s though')
コード例 #2
0
ファイル: logic.py プロジェクト: tankorsmash/Shooter
def textDisplays():
    """displays text in specialzed boxes"""
    
    text = visuals.multiLine('Player\'s pos: {0}, Mouse pos: {1}'.format(actors.player.getPos(), pygame.mouse.get_pos())) 
    #TextBox('Player\'s pos: {0}, Mouse pos: {1}'.format(actors.player.getPos(), pygame.mouse.get_pos()))
    pass