def __init__(self, size=(800,600), fullscreen=0, caption="snowui"): pyglet_window.Window.__init__(self, width=size[0], height=size[1]) if fullscreen: self.set_fullscreen(True) self.set_caption(caption) rabbyt.set_default_attribs()
def main(): window_w = w window_h = h #window_w = 1280 #window_h = 720 #window_w = 1024 #window_h = 576 #window_w = 800 #window_h = 450 window = MainWindow(width=window_w, height=window_h, vsync=False) #window = MainWindow(vsync=False, fullscreen=True) window.set_caption( "%i sprites :: Super Ultimate Sprite Machine Factory Window" % num_sprites ) rabbyt.set_default_attribs() #window.push_handlers(pyglet.window.event.WindowEventLogger()) #pyglet.clock.schedule_interval(window.update, 1.0/70.0) #pyglet.clock.schedule_interval(window.update, 1.0/4.0) #pyglet.clock.schedule_interval(window.update, 1.0/60.0) pyglet.clock.schedule(window.update) #pyglet.clock.schedule_interval(window.update, 4.0) #pyglet.clock.schedule_interval(window.update, 1.0/120) #window.update(0) pyglet.app.run()
def main(): window_w = WIDTH window_h = HEIGHT #window_w = 1280 #window_h = 720 #window_w = 1024 #window_h = 576 #window_w = 800 #window_h = 450 window = MainWindow(width=window_w, height=window_h, vsync=False) #window = MainWindow(vsync=False, fullscreen=True) window.set_caption( "moving magic!" ) rabbyt.set_default_attribs() #window.push_handlers(pyglet.window.event.WindowEventLogger()) #pyglet.clock.schedule_interval(window.update, 1.0/70.0) #pyglet.clock.schedule_interval(window.update, 1.0/4.0) #pyglet.clock.schedule_interval(window.update, 1.0/60.0) pyglet.clock.schedule(window.update) #pyglet.clock.schedule_interval(window.update, 4.0) #pyglet.clock.schedule_interval(window.update, 1.0/120) #window.update(0) pyglet.app.run()
def main(): global win clock.schedule(rabbyt.add_time) win = pyglet.window.Window(width=leaves.SCREEN_WIDTH, height=leaves.SCREEN_HEIGHT) window.set_window(win) rabbyt.set_default_attribs() garbage = GarbageCan() leafs = leaves.LeafGroup() leafs += [leaves.Leaf(), leaves.Leaf(), leaves.Leaf() ] for i in range(len(leafs)): leafs[i].logicalX = 260 + i*80 leafs[i].logicalY = 100 + i*60 leafs[i].logicalZ = 10 while not win.has_exit: tick = clock.tick() win.dispatch_events() leafs.update(tick) garbage.update(tick) events.ConsumeEventQueue() rabbyt.clear((1, 1, 1)) leafs.draw() garbage.draw() win.flip()
def init(world, options): window = pyglet.window.Window( fullscreen=options.fullscreen, vsync=options.vsync, resizable=not options.fullscreen, caption='Zerkcom', ) rabbyt.set_default_attribs() draw_glyphs = glyph.init(window, world) draw_sprites = sprite.init(window, world, load_all('data/images')) @window.event def on_draw(): rabbyt.clear(rgba=CLEAR_COLOR_DEFAULT) rabbyt.set_viewport( get_viewport(window.width, window.height), WORLD_BOUNDS ) draw_glyphs() draw_sprites() return window
def _create_display(self, width, height): size = width, height flags = pygame.OPENGL | pygame.DOUBLEBUF self.screen = pygame.display.set_mode(size, flags) rabbyt.set_viewport(size) rabbyt.set_default_attribs()
def main(): global fps_display win = Window(width=800, height=600) clock.schedule(rabbyt.add_time) rabbyt.set_default_attribs() bg = Background() fps_display = clock.ClockDisplay() while not win.has_exit: tick = clock.tick() win.dispatch_events() bg.update(tick) rabbyt.clear((bg.color)) bg.draw() fps_display.draw() win.flip()
def __init__(self, size=(800, 600), fullscreen=0, caption="snowui"): pyglet_window.Window.__init__(self, width=size[0], height=size[1]) if fullscreen: self.set_fullscreen(True) self.set_caption(caption) rabbyt.set_default_attribs()
def main(): clock.schedule(rabbyt.add_time) window.game_window = Window(width=SCREEN_WIDTH, height=SCREEN_HEIGHT) rabbyt.set_default_attribs() mower = Mower() bubble = RPMBubble() guage = Guage(mower) objs = [mower, guage, bubble] magicEventRegister(window.game_window, events, objs) while not window.game_window.has_exit: tick = clock.tick() window.game_window.dispatch_events() for obj in objs: obj.update(tick) events.ConsumeEventQueue() rabbyt.clear((1, 1, 1)) guage.draw() mower.draw() bubble.draw() window.game_window.flip()
def main(): global win clock.schedule(rabbyt.add_time) win = Window(width=800, height=600) rabbyt.set_default_attribs() lawn = Lawn() wind = Wind() magicEventRegister(win, events, list(lawn)) while not win.has_exit: tick = clock.tick() win.dispatch_events() lawn.update(tick) wind.update(tick) events.ConsumeEventQueue() rabbyt.clear((1, 1, 1)) lawn.draw() win.flip()
def main(): window = pyglet.window.Window(fullscreen=config.fullscreen) window.set_exclusive_mouse(config.fullscreen) window.set_exclusive_keyboard(config.fullscreen) rabbyt.set_default_attribs() pyglet.resource.path = ['@pycarus'] TitleScreen(window) pyglet.app.run()
def __init__(self): super(Controller, self).__init__(width=constants.WIDTH, height=constants.HEIGHT, caption="Nanobiotics")#, fullscreen=True) self.viewport = fixed_resolution.FixedResolutionViewport(self, constants.WIDTH, constants.HEIGHT, filtered=False) rabbyt.set_viewport((constants.WIDTH, constants.HEIGHT)) rabbyt.set_default_attribs() self.set_exclusive_mouse(True) self.set_mouse_visible(False) self.state = None
def init () : global window flags = pygame.OPENGL | pygame.DOUBLEBUF if BCONF.fullscreen : flags |= pygame.FULLSCREEN pygame.display.init () window = pygame.display.set_mode ( ( BCONF.width, BCONF.height ), flags ) rabbyt.set_viewport ( ( BCONF.width, BCONF.height ), ( -width, height, width, -height ) ) rabbyt.set_default_attribs ()
def other_main(): #window = MainWindow(*size, vsync=False) window = MainWindow(width=size[0], height=size[1], vsync=False) window.set_caption( "%i sprites :: Super Ultimate Sprite Machine Factory Window" % num_sprites ) rabbyt.set_default_attribs() #window.push_handlers(pyglet.window.event.WindowEventLogger()) pyglet.clock.schedule_interval(window.update, 1.0/70.0) #pyglet.clock.schedule_interval(window.update, 1.0/120) pyglet.app.run()
def main(): def tuio(dt): """pyglet callback event to check for OSC messages""" server.recv(0.0333333333333) skreen=canvas(photoDeck(skreenPics().sprites)) server = liblo.Server(3333) server.add_method('/tuio/2Dcur', None, skreen.handleOsc) #server.add_method('/tuio/2Dcur', None, debugtuio) pyglet.clock.schedule_interval(tuio, 0.0001) pyglet.clock.schedule(rabbyt.add_time) rabbyt.set_default_attribs() rabbyt.set_viewport((skreen.window.height,skreen.window.width)) pyglet.app.run()
def __init__(self): super(Controller, self).__init__(width=constants.WIDTH, height=constants.HEIGHT, caption="Nanobiotics") #, fullscreen=True) self.viewport = fixed_resolution.FixedResolutionViewport( self, constants.WIDTH, constants.HEIGHT, filtered=False) rabbyt.set_viewport((constants.WIDTH, constants.HEIGHT)) rabbyt.set_default_attribs() self.set_exclusive_mouse(True) self.set_mouse_visible(False) self.state = None
def __init__(self): self.window = pyglet.window.Window(width=const.GAME_WIDTH, height=const.GAME_HEIGHT, vsync=False, caption="Porcupyne", resizable=True) self.window.invalid = False # resource.path = ['.'] res = resources.Resource() res.load_directory('gamedata') self.player1 = Ball(self, res) self.bg = BG(res) platform_width = 200 platform_height = 96 def get_points(x, y): x -= platform_width / 2.0 y -= platform_height / 2.0 return (((x, y), (x, y + platform_height), (x + platform_width, y + platform_height), (x + platform_width, y))) self.platforms = [ Platform(get_points(0, -128), res), Platform(get_points(128, 0), res), Platform(get_points(-270, -50), res), Platform(get_points(-320, 150), res), Platform(((225, 48), (400, 160), (400, 48)), res) ] self.controller = Controller(self.window, self.player1) self.fps_display = font.Text(pyglet.font.load('', 18, bold=True), '', color=(0.5, 0.5, 0.5, 0.5), x=-150, y=-100) ft = font.load('Arial', 10) color = (0, 0, 0, 1) self.debug_text = [ font.Text(ft, x=-150, y=100, color=color), font.Text(ft, x=-150, y=85, color=color), font.Text(ft, x=-150, y=70, color=color) ] # alpha channels¨ rabbyt.set_default_attribs() glEnable(GL_LINE_SMOOTH) glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
def main(): """Initialize environment, then start game instance.""" pygame.init() pygame.display.set_mode( (WINWIDTH, WINHEIGHT), pygame.OPENGL | pygame.DOUBLEBUF ) # (0,0) is center point of screen rabbyt.set_viewport( (WINWIDTH, WINHEIGHT) ) rabbyt.set_default_attribs() pygame.display.set_icon(pygame.image.load(os.path.join('images', 'gameicon.png')).convert_alpha()) pygame.display.set_caption('Escape from Wikipedia') while True: runGame() # Allows restarts
def main(): def tuio(dt): """pyglet callback event to check for OSC messages""" server.recv(0.0333333333333) skreen = canvas(photoDeck(skreenPics().sprites)) server = liblo.Server(3333) server.add_method('/tuio/2Dcur', None, skreen.handleOsc) #server.add_method('/tuio/2Dcur', None, debugtuio) pyglet.clock.schedule_interval(tuio, 0.0001) pyglet.clock.schedule(rabbyt.add_time) rabbyt.set_default_attribs() rabbyt.set_viewport((skreen.window.height, skreen.window.width)) pyglet.app.run()
def __init__(self, game): # While the game needs to work independently of the client the client # can't work independently of the game. The client will be sending # input to the game as well as looking up different elements (such as # all the blocks so we can draw them and tell the game when we click on # one). self.game = game # Setup our pyglet window. self.window = Window(width=self.game.size_xy[0]*20, height=self.game.size_xy[1]*20+50) self.window.set_caption("Mines") self.window.on_close = sys.exit # The default pyglet OpenGL display is setup a bit different than how # rabbyt would like, thus rabbyt.set_default_attribs rabbyt.set_default_attribs() # Using pyglet for input is really easy. When you get further down # you'll see GameContorl inherits from EventDispatcher. That's how # window.push_handlers does the magic as we'll see further down. self.ctrl = GameContorl(self) self.window.push_handlers(self.ctrl) # Here we have some sprites we are going to use for the client. For # bigger games I think it's better to separate stuff like this out; # but this is quite small and not an issue. self.smile_face = rabbyt.Sprite("data/smile.png") self.smile_face.x = self.window.width/2 self.smile_face.y = self.window.height-25 self.dead_face = rabbyt.Sprite("data/smile_dead.png") self.dead_face.xy = self.smile_face.xy self.won_face = rabbyt.Sprite("data/smile_won.png") self.won_face.xy = self.smile_face.xy # That sprite stuff was pretty self explanatory. It is also very basic. # I'm not going to be going into much depth with rabbyt in these # tutorials so you may want to check out the rabbyt documentation from # http://matthewmarshall.org/projects/rabbyt/ # Very cool and elegant stuff there. Check it out! self.clock = Clock() self.clock.set_fps_limit(20) self.window.push_handlers(self.clock) self.time = 0 self.clock.schedule(self._add_time) self.setup()
def __init__(self, **kwargs): super(MyWindow, self).__init__(**kwargs) self.set_exclusive_mouse(self.fullscreen) self.set_exclusive_keyboard(self.fullscreen) rabbyt.set_default_attribs() glClearColor(1, 1, 1, 0) self.background = load_tileable_texture('background.png') self.ship_texture = pyglet.resource.texture('ship.png') self.ship = rabbyt.Sprite(self.ship_texture, alpha=rabbyt.ease(0, 1, dt=2), rot=rabbyt.lerp(end=60, dt=1, extend='extrapolate')) self.shadow = create_shadow(self.ship, self.ship_texture, x=20, y=-30, alpha=0.5) self.time = 0.
def __init__(self, fps=False, **kwargs): super(MyWindow, self).__init__(**kwargs) rabbyt.set_default_attribs() glClearColor(1, 1, 1, 0) glColor3f(0, 0, 0) self.fps = fps self.fps_display = pyglet.clock.ClockDisplay() if '--animation-editor' in sys.argv: self.my_screen = AnimationEditor(self) elif '--skeleton-editor' in sys.argv: self.my_screen = SkeletonEditor(self) elif '--skin-editor' in sys.argv: self.my_screen = SkinEditor(self) else: self.my_screen = GameScreen(self)
def other_main(): #window = MainWindow(width=w, height=h, vsync=False) window = MainWindow(vsync=False, fullscreen=True) # See bookmarks for scaling... #window = MainWindow(width=w, height=h, vsync=False, fullscreen=True) #window = MainWindow(width=w, height=h, vsync=True) window.set_caption( "%i sprites :: Super Ultimate Sprite Machine Factory Window" % num_sprites ) rabbyt.set_default_attribs() #window.push_handlers(pyglet.window.event.WindowEventLogger()) #pyglet.clock.schedule_interval(window.update, 1.0/70.0) pyglet.clock.schedule_interval(window.update, 1.0/4.0) #pyglet.clock.schedule_interval(window.update, 1.0/120) pyglet.app.run()
def main(): window_w = w window_h = h #window_w = 1280 #window_h = 720 window = MainWindow(width=window_w, height=window_h, vsync=False) #window = MainWindow(vsync=False, fullscreen=True) window.set_caption( "%i sprites :: Super Ultimate Sprite Machine Factory Window" % num_sprites ) rabbyt.set_default_attribs() #pyglet.clock.schedule_interval(window.update, 1.0/60.0) pyglet.clock.schedule(window.update) pyglet.app.run()
def __init__(self, world, camera, options): self.world = world self.camera = camera self.options = options self.clock_display = None rabbyt.set_default_attribs() # lists of sprites to render, keyed by layer # 0: ground level # 1: old images of player # 2: player # 3: treetops # 4: hud self.sprites = {} world.item_added += self.on_item_added world.item_removed += self.on_item_removed
def __init__(self): self.window = pyglet.window.Window(width = const.GAME_WIDTH, height = const.GAME_HEIGHT, vsync = False, caption = "Porcupyne", resizable = True) self.window.invalid = False # resource.path = ['.'] res = resources.Resource() res.load_directory('gamedata') self.player1 = Ball(self, res) self.bg = BG(res) platform_width = 200 platform_height = 96 def get_points(x, y): x -= platform_width / 2.0 y -= platform_height / 2.0 return (( (x, y), (x, y + platform_height), (x + platform_width, y + platform_height), (x + platform_width, y))) self.platforms = [ Platform(get_points(0, -128), res), Platform(get_points(128, 0), res), Platform(get_points(-270, -50), res), Platform(get_points(-320, 150), res), Platform(( (225, 48), (400, 160), (400, 48) ), res) ] self.controller = Controller(self.window, self.player1) self.fps_display = font.Text(pyglet.font.load('', 18, bold = True), '', color=(0.5, 0.5, 0.5, 0.5), x=-150, y=-100) ft = font.load('Arial', 10) color = (0, 0, 0, 1) self.debug_text = [font.Text(ft, x=-150, y=100, color = color), font.Text(ft, x=-150, y=85, color = color), font.Text(ft, x=-150, y=70, color = color)] # alpha channels¨ rabbyt.set_default_attribs() glEnable(GL_LINE_SMOOTH) glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
def main(): global win clock.schedule(rabbyt.add_time) win = pyglet.window.Window(width=SCREEN_WIDTH, height=SCREEN_HEIGHT) window.set_window(win) bgPat = pyglet.image.SolidColorImagePattern((200, 200, 255, 255)) bg = pyglet.image.create(window.game_window.width, window.game_window.height, bgPat) rabbyt.set_default_attribs() bubbles.init() bubbles.win = win storyTeller = narrative.StoryTeller() fGen = FloaterGenerator() fGen.hitRequiredStage = True fGen.active = True sGen = SourcecodeGenerator() sGen.hitRequiredStage = True sGen.active = True events.Fire("NewStage", narrative.terror) scene = sky.Background(None) while not win.has_exit: tick = clock.tick() win.dispatch_events() bubbles.bubbleMaker.update(tick) scene.update(tick) fGen.update(tick) sGen.update(tick) events.ConsumeEventQueue() rabbyt.clear((1, 1, 1)) bg.blit(0, 0) scene.draw() fGen.draw() bubbles.bubbleMaker.draw() sGen.draw() win.flip()
def main(): clock.schedule(rabbyt.add_time) window.game_window.set_window(Window(width=800, height=600)) rabbyt.set_default_attribs() bgPat = pyglet.image.SolidColorImagePattern((0, 0, 0, 255)) bg = pyglet.image.create(window.game_window.width, window.game_window.height, bgPat) bub = ThoughtBubble( "Click to make this disappear." " This is a thought bubble." " asdf asdf .qwer p30n fpin pp) ) *HNPO *H#NN ! #RFL" ) bub2 = HintBubble("This is a hint bubble.") maker = BubbleMaker() magicEventRegister(window.game_window, events, [bub]) counter = 0 objects = [bub, bub2, maker] events.Fire("Shoo", 1, 2, None) while not window.game_window.has_exit: tick = clock.tick() window.game_window.dispatch_events() counter += tick if counter > 8: counter = -10 events.Fire("NewThought", "new thought") events.Fire("Shoo", 3, 4, None) for obj in objects: obj.update(tick) events.ConsumeEventQueue() rabbyt.clear((1, 1, 1)) bg.blit(0, 0) for obj in objects: obj.draw() window.game_window.flip()
def __init__(self, width, height): pygame.display.set_mode((width, height), pygame.OPENGL | pygame.DOUBLEBUF) rabbyt.set_viewport((width, height), projection=(0, 0, width, height)) rabbyt.set_default_attribs() self.size = (width, height) self.ratio = float(width) / height self.pieces = [] self.grabbed_piece = None self.panning = False self.panning_x = 0 self.panning_y = 0 self.viewport_x = 0 self.viewport_y = 0 self.z = 0 self.boards = [rabbyt.Sprite(texture='board.png')] for card_image in glob.glob(os.path.join('cards', '*png')): self.pieces.append(Piece(texture=card_image, back=os.path.join('cards', 'backs', 'back-red-150-2.png')))
def __init__(self, fps=False, debug=False, single=True, **kwargs): super(MyWindow, self).__init__(**kwargs) # Grab mouse and keyboard if we're in fullscreen mode. self.set_exclusive_mouse(self.fullscreen) self.set_exclusive_keyboard(self.fullscreen) # Initialize Rabbyt. rabbyt.set_default_attribs() # Clear to opaque black for opaque screenshots. glClearColor(0., 0., 0., 1.) # Create FPS display. self.fps_display = pyglet.clock.ClockDisplay() if fps else None # Most window calls are delegated to a screen. self.my_screen = GameScreen(self, debug=debug, single=single)
def main(): clock.schedule(rabbyt.add_time) win = Window(width=800, height=600) rabbyt.set_default_attribs() lawn = NewLawn() while not win.has_exit: tick = clock.tick() win.dispatch_events() lawn.update(tick) rabbyt.clear((1, 1, 1)) lawn.draw() win.flip()
def main(): global win clock.schedule(rabbyt.add_time) win = pyglet.window.Window(width=SCREEN_WIDTH, height=SCREEN_HEIGHT) window.set_window(win) rabbyt.set_default_attribs() bubbles.init() bubbles.win = win storyTeller = narrative.StoryTeller() wind = Wind() leafgen = LeafGenerator() leafgen.active = True leaves = LeafGroup() #bg = sky.Background(None) objs = [leafgen, leaves] magicEventRegister(win, events, objs) while not win.has_exit: tick = clock.tick() win.dispatch_events() bubbles.bubbleMaker.update(tick) #bg.update(tick) for obj in objs: obj.update(tick) wind.update(tick) events.ConsumeEventQueue() rabbyt.clear((1, 1, 1)) #bg.draw() leaves.draw() bubbles.bubbleMaker.draw() win.flip()
def __init__(self, *args, **kwargs): # set window size if Game.WINDOW_FULLSCREEN: kwargs['fullscreen'] = True else: kwargs['width'] = Game.WINDOW_WIDTH kwargs['height'] = Game.WINDOW_HEIGHT super(Game, self).__init__( *args, **kwargs) # prevent resize self.resizeable = False self.set_minimum_size(self.width, self.height) self.set_mouse_visible = False # rabbyt set up rabbyt.set_default_attribs() # game scenes, these include the main game and the supporting menu scenes self._current_scene = None
def main(): clock.schedule(rabbyt.add_time) win = pyglet.window.Window(width=800, height=600) window.set_window(win) rabbyt.set_default_attribs() grill = Grill() while not win.has_exit: tick = clock.tick() win.dispatch_events() grill.update(tick) rabbyt.clear((1, 1, 1)) grill.draw() win.flip()
def run(self): # Attempt to set up the display with 0x AA. display = pyglet.window.get_platform().get_default_display() screen = display.get_default_screen() glconfig = pyglet.gl.Config( double_buffer=True, sample_buffers=True, samples=0, ) try: config = screen.get_best_config(glconfig) except window.NoSuchConfigException: # Failed AA config - use a config without AA. config = screen.get_best_config( pyglet.gl.Config(double_buffer=True)) self.window = pyglet.window.Window(config=config, resizable=True, vsync=True) # Load terrain tiles. terrain_grid_image = pyglet.image.ImageGrid( pyglet.image.load("data/tiles.png"), 1, 1, MAP_TILE_SIZE + 1, MAP_TILE_SIZE + 1, 1, 1) terrain_grid = pyglet.image.TextureGrid(terrain_grid_image) terrain_dirt = rabbyt.Sprite(texture=terrain_grid[0], u=0, v=0) self.terrain = [[terrain_dirt] * MAP_WIDTH] * MAP_HEIGHT # Load the player and put it in the middle of the map. self.player = Player() self.player.x = MAP_WIDTH * MAP_TILE_SIZE / 2 self.player.y = MAP_HEIGHT * MAP_TILE_SIZE / 2 # Load the FPS display. self.fps_display = pyglet.clock.ClockDisplay(color=(1, 1, 1, 0.5)) # Init rabbyt rabbyt.set_default_attribs() # Set up the clock and keep track of the time. self.clock = pyglet.clock.get_default() # self.clock.set_fps_limit(30) def track_time(dt): self.dt = dt self.time += dt self.clock.schedule(track_time) self.time = 0 self.dt = 0 # Get a keyboard handler to store the state of all keys. self.keyboard = pyglet.window.key.KeyStateHandler() # Keep track of mouse button states. self.mouse = 0 # Keep track of mouse x, y coordinates. self.mousex = self.mousey = None # Push applicable event handlers to the window. self.window.push_handlers(self.on_draw, self.keyboard, self.on_mouse_press, self.on_mouse_release, self.on_mouse_motion, self.on_mouse_drag) # Go! pyglet.app.run()
Car.dust_particles.add(s) rabbyt.scheduler.add(rabbyt.get_time()+lifetime, lambda:Car.dust_particles.remove(s)) def render(self): self.shadow.render() rabbyt.Sprite.render(self) if __name__ == "__main__": pygame.init() pygame.display.set_mode((800,600), pygame.OPENGL | pygame.DOUBLEBUF) rabbyt.set_viewport((800, 600)) rabbyt.set_default_attribs() print """ This is a simple example for using rabbyt. Use the arrow keys to steer. Press SPACE to boost. """ car1 = Car("car") cars = [car1] clock = pygame.time.Clock() while True: clock.tick(40)
def init(): log.info("Setting up") pygame.init() game.window = pygame.display.set_mode(game.config.size,game.config.screenargs) rabbyt.set_viewport(game.config.size) rabbyt.set_default_attribs()