def on_draw(): window.clear() fps_display.draw() rabbyt.render_unsorted(points) if len(bullets)>0: rabbyt.render_unsorted(bullets) player.render()
def run(queue): running = True game = Game(1240, 780) while running: clock.tick(40) for event in pygame.event.get(): running &= game.handle_event(event) try: item = queue.get(False) update = simplejson.loads(item) for (key, value) in update.iteritems(): print Piece._items[update['id']], key, value current = getattr(Piece._items[update['id']], key) setattr(Piece._items[update['id']], key, rabbyt.lerp(current, value, dt=200)) except Empty: pass #game.render() rabbyt.set_time(pygame.time.get_ticks()) rabbyt.clear() rabbyt.render_unsorted(game.boards) rabbyt.render_unsorted(game.pieces) rabbyt.scheduler.pump() pygame.display.flip()
def on_draw(self): red, green, blue = config.sky_color glClearColor(red, green, blue, 0) self.window.clear() glPushMatrix() glTranslatef(self.window.width // 2, self.window.height // 2, 0) scale = self.window.height / 15 glScalef(scale, scale, scale) camera_position = (self.icarus.body.position + b2.b2Vec2(*config.camera_offset)) camera_position.y = clamp(camera_position.y, config.camera_min_y, config.camera_max_y) glTranslatef(-camera_position.x, -camera_position.y, 0) for cloud in self.clouds: cloud.draw_shadow() self.draw_sea() self.island.draw() self.pearly_gates.render() rabbyt.render_unsorted(self.temples) self.icarus.draw() for cloud in self.clouds: cloud.draw() glPopMatrix() self.draw_fade() if config.fps: self.clock_display.draw() return pyglet.event.EVENT_HANDLED
def on_draw(): window.clear() fps_display.draw() rabbyt.render_unsorted(points) if len(bullets) > 0: rabbyt.render_unsorted(bullets) player.render()
def render(self): # pyglet.gl.glPushAttrib(pyglet.gl.GL_ALL_ATTRIB_BITS) # pyglet.gl.glEnable(pyglet.gl.GL_BLEND) # pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE) rabbyt.render_unsorted(self.trail) # pyglet.gl.glPopAttrib() super(Player, self).render()
def on_draw(): window.clear() fps_display.draw() rabbyt.render_unsorted(collides.enemies) if len(collides.bullets)>0: rabbyt.render_unsorted(collides.bullets) player.render() kills.update()
def on_draw(self): rabbyt.set_time(self.time) self.clear() glPushMatrix() glTranslatef(self.width // 2, self.height // 2, 0) scale = min(self.width, self.height) / self.scale glScalef(scale, scale, scale) rabbyt.render_unsorted(self.sprites) glPopMatrix()
def on_draw(self): if self.fullscreen: self.viewport.begin() rabbyt.clear() rabbyt.render_unsorted(sprites) fps_display.label.color = (0.0, 0.0, 0.0, 0.5) fps_display.label.draw() fps_display.label.color = (1.0, 1.0, 1.0, 0.5) fps_display.label.draw() if self.fullscreen: self.viewport.end()
def on_draw(self): if self.scale_needed(): self.viewport.begin() rabbyt.clear() self.reset_color_hack() self.bg.blit(0, 0, 0) self.sprite.render() rabbyt.render_unsorted(self.factory.bullets) fps_display.label.draw() if self.scale_needed(): self.viewport.end()
def Draw(self, x, y, width, height): ''' draw the layers of the map ''' on_screen = self.tiles[x:x + width, y:y + height] if not self.LayerDimming or self.activeLayer > on_screen.shape[2]: # draw the dimlayer first self.dimmingSprite.render() for z in range(on_screen.shape[2]): if z == self.activeLayer and self.LayerDimming: if self.dimmingSprite is not None: self.dimmingSprite.render() rabbyt.render_unsorted(on_screen[:, :, z].flatten())
def on_draw(self): if self.scale_needed(): self.viewport.begin() rabbyt.clear() self.reset_color_hack() self.bg.blit(0, 0, 0) rabbyt.render_unsorted(self.sprites) self.draw_fps() if self.scale_needed(): self.viewport.end()
def draw(self): ''' Redraw the whole window ''' self.clear_window(self.world.background_color) self.camera.world_projection() # draw all entries in self.sprites for layer in sorted(self.sprites): sprites = self.sprites[layer] if layer == 4: self.draw_hud(sprites) else: rabbyt.render_unsorted(sprites)
def time_travel_animation(self): warp_speed = 20 while self.ship.y < 500: self.ship.y += warp_speed self.ship.render() pygame.display.flip() self.ship.xy = self.ship.saved_xy saved_y = self.ship.y self.ship.y = -500 self.background.render() rabbyt.render_unsorted(self.masks) while self.ship.y < saved_y - 100: self.ship.y += 1 self.ship.render() pygame.display.flip()
def draw(self, width, height): glColor3f(1., 1., 1.) self.stars_texture.blit_tiled(0, 0, 0, width, height) glPushMatrix() glTranslatef(float(width // 2), float(height // 2), 0.) scale = float(min(width, height)) / self.camera.scale glScalef(scale, scale, scale) rabbyt.set_time(self.time) self.sprites.sort(key=attrgetter('z')) rabbyt.render_unsorted(self.sprites) if self.debug: glColor3f(0., 1., 0.) glDisable(GL_TEXTURE_2D) debug_draw(self.world) glPopMatrix()
def Draw(self): ''' draws the rendering batchs to render the mouse sprites to the screen ''' fourCornersFlag = False verticalFlag = False horizontalFlag = False LRFlag = False TBFlag = False width = self.bottomRightPos[0] - self.topLeftPos[0] height = self.bottomRightPos[1] - self.topLeftPos[1] if self.singleMode or (width == 0 and height == 0): # draw the single tile sprite self.singleTileSprite.render() elif width != 0: if abs(width) > 1: horizontalFlag = True if height == 0: LRFlag = True else: fourCornersFlag = True if abs(height) > 1: verticalFlag = True elif height != 0: if abs(height) > 1: verticalFlag = True if width == 0: TBFlag = True else: fourCornersFlag = True if abs(width) > 1: horizontalFlag = True if horizontalFlag: # draw the horizontal sprites rabbyt.render_unsorted(self.horizontalSprites) if verticalFlag: # draw the vertical sprites rabbyt.render_unsorted(self.verticalsprites) # draw the top and Bottom corners in two tiles if TBFlag: rabbyt.render_unsorted(self.TBCorners) if LRFlag: # draw the left and right corners in two tiles rabbyt.render_unsorted(self.LRCorners) if fourCornersFlag: # draw the four corner sprites rabbyt.render_unsorted(self.cornerSprites)
def run(): running = True game = Game(1240, 780) while running: clock.tick(40) for event in pygame.event.get(): running &= game.handle_event(event) #game.render() rabbyt.set_time(pygame.time.get_ticks()) rabbyt.clear() rabbyt.render_unsorted(game.boards) rabbyt.render_unsorted(game.pieces) rabbyt.scheduler.pump() pygame.display.flip()
def on_draw(self): draw_area = self.draw_area() static_projection = (0, draw_area[1], draw_area[0], 0) # Draw background rabbyt.set_viewport(draw_area, projection = static_projection) # reset opengl draw colour glColor(255, 255, 255, 1) GameScene.BACKGROUND.blit_tiled(0, 0, 0, draw_area[0], draw_area[1]) # Draw transformed sprites rabbyt.set_viewport(draw_area, projection = self.camera) rabbyt.render_unsorted(self.entities) # Draw static sprites rabbyt.set_viewport(draw_area, projection = static_projection) for label in self.score_labels: label.draw()
def on_draw(self): if self.scale_needed(): self.viewport.begin() rabbyt.clear() self.reset_color_hack() self.bg.blit(0, 0, 0) self.sprite.render() for shot in self.sprite.shots: for factory in shot.factories: rabbyt.render_unsorted(factory.bullets) self.fps_display.label.draw() self.coll_ctr.draw() if self.scale_needed(): self.viewport.end()
def draw_hud(self, items): ''' Draw any display items overlaid on the world, such as FPS counter ''' self.camera.hud_projection() rabbyt.render_unsorted( items ) gl.glEnableClientState(gl.GL_VERTEX_ARRAY) gl.glEnableClientState(gl.GL_COLOR_ARRAY) if self.options.fps: if self.clock_display is None: self.clock_display = clock.ClockDisplay() self.clock_display.draw() gl.glDisableClientState(gl.GL_VERTEX_ARRAY) gl.glDisableClientState(gl.GL_COLOR_ARRAY)
def on_draw(): rabbyt.clear() gun.render() rabbyt.render_unsorted(aliens) rabbyt.render_unsorted(bullets_my) rabbyt.render_unsorted(bullets_alien) win.flip()
def on_draw(): window.clear() fps_display.draw() rabbyt.render_unsorted(points)
def on_draw(): screen.clear() rabbyt.render_unsorted(render) fps_display.draw()
def on_draw(self): self.clear() rabbyt.render_unsorted(self.stars) self.fps_display.draw()
for i in range(2400): s = rabbyt.Sprite("rounded_square.png") s.rgba = lerp((.5, .2, 1, .2), (0, .8, 0, .6), dt=3 * r() + 2, extend="reverse") s.x = wrap([-320, 320], lerp(r() * 640, r() * 640, dt=2, extend="extrapolate")) s.y = wrap([-240, 240], lerp(r() * 480, r() * 480, dt=2, extend="extrapolate")) s.scale = lerp(.1, 1, dt=r() + .75, extend="reverse") s.rot = lerp(0, 360, dt=2, extend="extrapolate") sprites.append(s) print "Drawing 2400 sprites..." c = pygame.time.Clock() last_fps = 0 while not pygame.event.get(pygame.QUIT): c.tick() if pygame.time.get_ticks() - last_fps > 1000: print "FPS: ", c.get_fps() last_fps = pygame.time.get_ticks() rabbyt.clear() rabbyt.set_time(pygame.time.get_ticks() / 1000.0) rabbyt.render_unsorted(sprites) pygame.display.flip()
def draw(self): # BulletPool.batch.draw() pyglet.gl.glEnable(pyglet.gl.GL_BLEND) pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE) rabbyt.render_unsorted([b.sprite for b in self.active if b.alive])
def draw(self): """draw all of the photos, in stack order""" rabbyt.clear() rabbyt.render_unsorted(self)
while keep_running: handle_events() #rabbyt.clear() color = (0.05, 0.05, 0.20) #color = (1.00, 1.00, 1.00) #color = (1.00, 1.00, 1.00) rabbyt.clear(color) move_stars() #for layer in reversed(layers): # rabbyt.render_unsorted(layer) for layer in layers: rabbyt.render_unsorted(layer) #layers = [filter(in_range, layer) for layer in layers] for n, layer in enumerate(layers): i = 0 while i < len(layer): if in_range(layer[i]): i += 1 else: del layer[i] layer.append(make_star(n)) pygame.display.set_caption('FPS: %6.2f' % the_clock.get_fps()) star_count = sum(map(len, layers)) print star_count, "\r",
def render_after_transform(self): rabbyt.render_unsorted(self.char_sprites)
sprites.append(s) collision_times = [] c = pygame.time.Clock() last_fps = 0 while not pygame.event.get(pygame.QUIT): c.tick() if pygame.time.get_ticks() - last_fps > 1000: print "FPS: ", c.get_fps() last_fps = pygame.time.get_ticks() if collision_times: average = sum(collision_times)/len(collision_times) print "Average ms to find collisions:", average collision_times = [] rabbyt.clear() rabbyt.set_time(pygame.time.get_ticks()/1000.0) start = pygame.time.get_ticks() collisions = rabbyt.collisions.aabb_collide(sprites) collision_times.append(pygame.time.get_ticks()-start) for group in collisions: for s in group: s.rgb = lerp((1,0,0),(1,1,1), dt=.4) #s2.rgb = lerp((1,0,0),(1,1,1), dt=.4) rabbyt.render_unsorted(sprites) pygame.display.flip()
def on_draw(self): rabbyt.clear() rabbyt.render_unsorted(sprites) fps_display.draw()
shot.x = player.x shot.y = player.y shot.scale = 0.25 bullets.append(shot) def move_bullets(): for bullet in bullets: bullet.x += game_settings['bullet-speed'] while keep_running: handle_events() rabbyt.clear() maybe_shoot() move_sprites() move_bullets() bg.render() player.render() # This seems to get about 1FPS more, oh boy rabbyt.render_unsorted(bullets) rabbyt.render_unsorted(sprites) #pygame.display.set_caption("%i objects" % len(sprites)) pygame.display.set_caption('FPS: %6.2f' % the_clock.get_fps()) pygame.display.flip() the_clock.tick(FPS) #print ('FPS: %6.2f\r' % the_clock.get_fps()),
if event.key in (pygame.K_ESCAPE, pygame.K_q): import sys sys.exit(0) elif event.key == pygame.K_SPACE: car1.boost() pressed = pygame.key.get_pressed() car1.accelerating = pressed[pygame.K_UP] car1.turning_right = pressed[pygame.K_RIGHT] car1.turning_left = pressed[pygame.K_LEFT] rabbyt.set_time(pygame.time.get_ticks()/1000.0) for c in cars: c.update() rabbyt.scheduler.pump() rabbyt.clear((.56, .3, 0, 1)) for c in cars: c.render() rabbyt.render_unsorted(Car.dust_particles) rabbyt.render_unsorted(Car.boost_particles) pygame.display.flip()
print "Click and drag the control points." clock = pygame.time.Clock() running = True while running: clock.tick(40) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN: if event.key in (pygame.K_ESCAPE, pygame.K_q): running = False elif event.type == pygame.MOUSEBUTTONDOWN: for c in control_points: if hypot(c.x - event.pos[0], c.y - event.pos[1]) < 20: grabbed_point = c break elif event.type == pygame.MOUSEMOTION: if grabbed_point: grabbed_point.xy = event.pos generate_followers() elif event.type == pygame.MOUSEBUTTONUP: grabbed_point = None rabbyt.set_time(pygame.time.get_ticks()) rabbyt.clear() rabbyt.render_unsorted(control_points) rabbyt.render_unsorted(path_followers) pygame.display.flip()