当前位置: 首页>>代码示例>>Python>>正文


Python pygame.init函数代码示例

本文整理汇总了Python中pygame.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, description, open_dialog, *args, **kwargs):
        tk.Frame.__init__(self, *args, width=WIDTH, height=HEIGHT, **kwargs)

        self.description = description
        self.render_list = []
        self.objects_list = []
        self.walls_list = []
        self.back = (100, 100, 100)
        self.start_pos = None
        self.cursor = DemoCursor(False, False)

        self.open_dialog = open_dialog

        self.root = args[0]
        self.root.geometry("+100+100")
        self.objs_win = None
        self.walls_win = None

        self.embed = tk.Frame(root, width=640, height=480)
        self.embed.grid(row=0, column=2)
        self.root.update()
        os.environ['SDL_WINDOWID'] = str(self.embed.winfo_id())
        if platform == 'windows':
            os.environ['SDL_VIDEODRIVER'] = 'windib'
        pygame.init()
        self.screen = pygame.display.set_mode((640, 480))
        # pygame.display.flip()

        self.show_obj = tk.IntVar()
        self.show_walls = tk.IntVar()
        self.add_menu()
        self.root.bind('<Motion>', self.on_mouse_move)
        self.root.bind('<Button-1>', self.on_mouse_button)
开发者ID:Furaeva,项目名称:Just_game,代码行数:33,代码来源:EditorWindow.py

示例2: __init__

 def __init__(self,scales = [.3,.01,.01,.01,.01,.01]):
     pygame.init()
     pygame.joystick.init()
     self.controller = pygame.joystick.Joystick(0)
     self.controller.init()
     
     self.lStick = LeftStick(self.controller.get_axis(0),
                                self.controller.get_axis(1))
     self.rStick = RightStick(self.controller.get_axis(4),
                                  self.controller.get_axis(3))
     
     # dpad directions ordered as up down left right
     dPadDirs = getDirs(self.controller)
     
     self.dPad = DPad(dPadDirs)
     #self.dPad = DPad(self.controller.get_hat(0))
     self.trigger = Trigger(self.controller.get_axis(2))
     self.inUse = [False,False,False,False]
     
     length = 6
     self.offsets = np.zeros(length)
     self.uScale = np.ones(length)
     self.lScale = np.ones(length)
     self.driftLimit = .05
     self.calibrate()
     self.scales = np.array(scales)
     time.sleep(1)
     self.calibrate()
开发者ID:jon--lee,项目名称:vision-amt,代码行数:28,代码来源:xboxController.py

示例3: test

def test():

    pygame.init()

    size = width, height = 320, 240
    speed = [2, 2]
    black = 0, 0, 0

    screen = pygame.display.set_mode(size)

    ball = pygame.image.load("ball.gif")
    ballrect = ball.get_rect()

    while 1:
        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 or ballrect.bottom > height:
            speed[1] = -speed[1]

        screen.fill(black)
        screen.blit(ball, ballrect)
        pygame.display.flip()
开发者ID:thomasballinger,项目名称:dast,代码行数:26,代码来源:gamelib.py

示例4: __init__

 def __init__(self, input_method, lcm_tag, joy_name):
     print('Initializing...')
     pygame.init()
     self.screen = pygame.display.set_mode((300, 70))
     pygame.display.set_caption(lcm_tag)
     self.font = pygame.font.SysFont('Courier', 20)
     if input_method == 'keyboard':
         self.event_processor = KeyboardEventProcessor()
         print(bcolors.OKBLUE + '--- Keyboard Control Instruction --- '
               + bcolors.ENDC)
         print('To increase the throttle/brake: press and hold the Up/Down'
               + ' Arrow')
         print('To decrease the throttle/brake: release the Up/Down Arrow')
         print(
             'To keep the the current throttle/brake: press the Space Bar')
         print(
             'To increase left/right steering: press the Left/Right Arrow')
         print(bcolors.OKBLUE + '------------------------------------ '
               + bcolors.ENDC)
     else:
         self.event_processor = JoystickEventProcessor(joy_name)
     self.last_value = SteeringThrottleBrake(0, 0, 0)
     self.lc = lcm.LCM()
     self.lcm_tag = lcm_tag
     print('Ready')
开发者ID:RobotLocomotion,项目名称:drake,代码行数:25,代码来源:steering_command_driver.py

示例5: __init__

    def __init__(self, width=config.screen_width, height=config.screen_height):
        # initialization all pygame modules
        pygame.init()

        self.width, self.height = width, height
        self.screen = pygame.display.set_mode((self.width, self.height))
        pygame.display.set_caption("Pacman")
        pygame.mouse.set_visible(0)
        #set repetition  (set_repeat(after first keydown, after any other))
        pygame.key.set_repeat(30,30)

        #text font
        self.font48 = pygame.font.SysFont(None, 48)
        self.font30 = pygame.font.SysFont(None, 30)

        ##sounds
        pygame.mixer.init()
        self.sounds = {'die': pygame.mixer.Sound(os.path.join(config.snd_dir, "die.ogg")),
                        'intro': pygame.mixer.Sound(os.path.join(config.snd_dir, "intro.ogg"))}

        ##intro music
        self.sounds['intro'].play()

        ##gameplay variables
        self.enemy_max_cols = 3 # equal to pacman.lives
        self.enemy_cols = 0
        self.prev_life_score = 0
        self.lives_cntr = 3
        self.max_pellets = 181
        #bool var for check enabled menu or not
        self.set_menu = False
开发者ID:bcrudolph,项目名称:pacman,代码行数:31,代码来源:game.py

示例6: __init__

    def __init__(self, win_width=640, win_height=480):
        """Initialization of pygame environment and hand joint coordinates."""
        pygame.init()
        self.clock = pygame.time.Clock()
        self.screen = pygame.display.set_mode((win_width, win_height))
        pygame.display.set_caption("3D Wireframe Hand Model Simulation")

        # Read in joint positions from csv file (argument from command line).
        self.joints = []
        with open(sys.argv[1], 'rU') as f:
            csvf = csv.reader(f)
            for line in csvf:
                try:
                    self.joints.append(Point3D(line[0], line[1], line[2]))
                except IndexError:
                    raise InvalidInputFile("Each line must have following \
                                            format:  'x, y, z'")
        if len(self.joints) % 21 != 0:
            raise InvalidInputFile("Total number of lines in input file must \
                                    be a multiple of 21.")

        # Define the points that compose each of the fingers.
        self.index = (0, 1, 2, 3, 19)
        self.middle = (4, 5, 6, 7, 19)
        self.ring = (8, 9, 10, 11, 19)
        self.pinky = (12, 13, 14, 15, 19)
        self.thumb = (16, 17, 18, 19, 20)

        self.angleX = 0
        self.angleY = 0
        self.angleZ = 0
        self.play = 0
开发者ID:nhowarth,项目名称:pyhand,代码行数:32,代码来源:pyhand.py

示例7: runGame

def runGame():
    # Initialize game, settings and screen object
    pygame.init()
    drSettings = Settings()
    screen = pygame.display.set_mode(
        (drSettings.screenWidth, drSettings.screenHeight))
    pygame.display.set_caption("Drag Race")
    totalTime = 0

    # Make the car
    car = Car(drSettings, screen)

    # Initialize the timer, gear text and speed
    hud = HeadUpDisplay(drSettings, screen, totalTime, car) 

    # Store the game statistics
    stats = GameStats()

    # Start the main loop for the game
    while True:
        # Check for keypresses
        gf.checkEvents(car, stats)

        # Update the game active state
        if not car.onScreen:
            stats.gameActive = False

        if stats.gameActive:
            # Update the position of the car and the hud
            car.update() 
            hud.update(stats.totalTime, car)
            stats.totalTime += drSettings.timeIncrement

        # Update the screen
        gf.updateScreen(drSettings, screen, car, hud)
开发者ID:AdamD2,项目名称:drag-race,代码行数:35,代码来源:dragRace.py

示例8: main

def main():

    pygame.init()
    pygame.display.set_mode((640, 480))
    pygame.display.set_caption("1")
    pygame.key.set_repeat(50, 50)

    pygame.time.set_timer(REDRAWEVENT,16)
    pygame.time.set_timer(UPDATEEVENT, UPDATE_TIME)
    pygame.time.set_timer(SPAWNEVENT, 2500)

    p = player.HumanPlayer("0", (255, 0, 0), (0, 0))

    loop = get_loop()
    loop.add_object(RedrawHandler())
    loop.add_object(UpdateHandler())
    loop.add_object(SpawnHandler(p))
    loop.add_object(PrintHandler())
    loop.add_object(QuitHandler())
    loop.add_object(WASDHandler(p))
    loop.add_object(CleanupHandler())
    loop.add_object(p, "you")
    loop.add_object(ProjectileCreationHandler())
    loop.add_object(MouseHandler())

    while True:
        loop.tick()
开发者ID:alecain,项目名称:one,代码行数:27,代码来源:1.py

示例9: __init__

    def __init__(self):
 
        pygame.init()
 
        self.screen = pygame.display.set_mode( (800,600) )
        pygame.display.set_caption("Collisions")
        
        self.player = Player(keyboard={
            'left': pygame.K_LEFT,
            'right': pygame.K_RIGHT,
            'up': pygame.K_UP,
            'down': pygame.K_DOWN,
        })
        
        self.enemy  = Player(keyboard={
            'left': pygame.K_a,
            'right': pygame.K_d,
            'up': pygame.K_w,
            'down': pygame.K_s,
        })
        
        self.enemy.set_center(self.screen)
 
        self.font = pygame.font.SysFont("", 32)
        self.text = ''
开发者ID:furas,项目名称:my-python-codes,代码行数:25,代码来源:main_4.py

示例10: __init__

    def __init__(self, lev_width):
        
	self.lev_width = lev_width
	self.mainS = pygame.display.set_mode((SCREEN_W, SCREEN_H))
        self.mouse_state = SAFE
        self.itemGroup = pygame.sprite.Group()
	self.borderRectList = list()        
        self.iconGroup = pygame.sprite.Group()
        self.itemExistGroup = pygame.sprite.Group()
        
	self.cam = scrollerC.Camera(scrollerC.complex_camera, \
	                           lev_width, SCREEN_H - PANEL_H)
 	self.straw_man = dummy.Dummy((HALF_W, HALF_W)) # DUMMY FOR CAMERA
	
	self.right_arrow = arrow.Arrow((SCREEN_W - 40 , 5), RIGHT,\
                                       self.straw_man, self.lev_width, self.mainS)
	self.left_arrow = arrow.Arrow((0, 5), LEFT,\
                                       self.straw_man, self.lev_width,  self.mainS)

	
	self.curPos = (0, 0)

    	self.clock = pygame.time.Clock()
	self.create_panels()
	self.create_icons()
       
	pygame.init()
开发者ID:drakinosh,项目名称:python-projects,代码行数:27,代码来源:editor_bak.py

示例11: test

def test():
    pygame.init()
    screen = pygame.display.set_mode((1280, 720))
    width = 1280
    height = 720
    pygame.display.set_caption('Dirty Blitting')
    a = LoadingBar(screen, 'a')
    loop = True
    b = 0
    counter = 0
    while loop and b<100:
        a.update(1)
        time.sleep(.2)
        for event in pygame.event.get():
            if event.type == QUIT:
                    loop = False
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                    loop = False
        for i in range(3):
            pygame.image.save(screen, "image\image{c}.jpg"
                          .format (c = counter))
            counter += 1
        b+=1
    
    pygame.quit()   
开发者ID:Maocx,项目名称:Pygame,代码行数:25,代码来源:loadingbar.py

示例12: __init__

 def __init__(self):
     pg.mixer.pre_init(44100, -16, 4, 2048)
     pg.init()
     self.screen = pg.display.set_mode((WIDTH, HEIGHT))
     pg.display.set_caption(TITLE)
     self.clock = pg.time.Clock()
     self.load_data()
开发者ID:kidscancode,项目名称:gamedev,代码行数:7,代码来源:main.py

示例13: __init__

    def __init__(self, win_width = 640, win_height = 480):
        pygame.init()
 
        self.screen = pygame.display.set_mode((win_width, win_height))
        pygame.display.set_caption("Simulation of a rotating 3D Cube (tamilselvan)")
 
        self.clock = pygame.time.Clock()
 
        self.vertices = [
            Point3D(-1,1,-1),
            Point3D(1,1,-1),
            Point3D(1,-1,-1),
            Point3D(-1,-1,-1),
            Point3D(-1,1,1),
            Point3D(1,1,1),
            Point3D(1,-1,1),
            Point3D(-1,-1,1)
        ]
 
        # Define the vertices that compose each of the 6 faces. These numbers are
        # indices to the vertices list defined above.
        self.faces  = [(0,1,2,3),(1,5,6,2),(5,4,7,6),(4,0,3,7),(0,4,5,1),(3,2,6,7)]
 
        # Define colors for each face
        self.colors = [(255,0,255),(255,0,0),(0,255,0),(0,0,255),(0,255,255),(255,255,0)]
 
        self.angle = 0
开发者ID:Tamilselvan95,项目名称:android-cube,代码行数:27,代码来源:cube.py

示例14: main

def main():
    pg.init()
    hrl.initializeOpenGL(1024,766)
    dpx = hrl.initializeDPX()

    done = False

    im1 = hrl.Texture('data/alien.png')
    im2 = hrl.Texture('data/cow.png')
    #im = hrl.Texture(flatGradient(1024,766),dpx=True)
    #im = hrl.Texture('data/linear_rg_gradient.bmp')

    while not done:
        circleTileDraw(im1,im2)
        #im.draw()
        #im1.draw((0,0),300,300)
        #im1.draw((300,550),200,200)
        #im2.draw((550,300),200,200)
        #im2.draw((300,50),200,200)
        #im2.draw((50,300),200,200)

        pg.display.flip()

        eventlist = pg.event.get()
        for event in eventlist:
            if event.type == QUIT \
               or event.type == KEYDOWN and event.key == K_ESCAPE:
                done = True
开发者ID:TUBvision,项目名称:hrl,代码行数:28,代码来源:simpledisplay.py

示例15: __init__

    def __init__ (self, screen):
        pygame.mouse.set_visible(False)
        pygame.mouse.get_focused(True)
        pygame.init()
        music1='testBack.aud'
        music2='testBack2.aud'
        #play_file(music1)
        self.screen=screen
        self.size=screen.get_size()
        self.object_list=[]
        self.cur_fol=CursorFollower(self)
        self.wind=WindowObj(self)
        self.parent=screen
        self.myfont = pygame.font.SysFont("monospace", 15)
        create_window(self.wind,'mainMenu')
        self.order=Item(self,[200,100])
        self.chaos=Item(self,[100,100])


        self.order.image_name='Order'
        self.chaos.image_name='Chaos'
        self.order.interactive_name='order'
        self.chaos.interactive_name='chaos'
        #self.chaos.bondedTo=self.rufusRake
        self.create(self.order)
        self.create(self.chaos)

        self.create(self.cur_fol)
        self.create(self.wind)

        print("Damn you, world!")

        self.update()
开发者ID:creators1303,项目名称:VPL-GUI,代码行数:33,代码来源:mainMenu.py


注:本文中的pygame.init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。