def ease ( start = None, end = None, ** kws ) : assert end != None if kws [ 'dt' ] > TOLERANCE : if start == None : return rabbyt.ease ( end = end, ** kws ) else : return rabbyt.ease ( start, end, ** kws ) else : return end
def g(): x = random.randrange(w) y = random.randrange(h) sprite = rabbyt.Sprite(DAT_IMG) sprite.shape.width = 17 sprite.shape.height = 25 # TODO: Not exact! #sprite.tex_shape.width = 1.0 #sprite.tex_shape.width = 32.0/64.0 #sprite.tex_shape.height = 0.5 #sprite.tex_shape.width = 32.0/64.0 #sprite.tex_shape.height = 1.0/5.0 # So, who knows what the hell these values are actually being set to, or rather, why... # What I do know is that we can do everything as multiples of these crazy values... sprite.lol_w = sprite.tex_shape.width sprite.lol_h = sprite.tex_shape.height # Dividing by the number of frames in the sprite sheet sprite.tex_shape.width = sprite.lol_w/2.0 sprite.tex_shape.height = sprite.lol_h/1.0 sprite.tex_shape.left = 0 sprite.tex_shape.bottom = 0 # TODO: WHY DOES THIS WORK #sprite.u = rabbyt.lerp(0, 1.0/4.0, dt=4, extend="constant") sprite.xy = (x, y) #sprite.scale = rabbyt.ease(0.25, 1.50, dt=1, extend="reverse") sprite.scale = rabbyt.ease(1.00, 2.00, dt=2, extend="reverse") sprite.rot = rabbyt.ease(0.00, 360.00, dt=8, extend="extrapolate") #sprite.rot = 45 sprite.x = rabbyt.ease_out(x-50, x+50, dt=6, extend="reverse") sprite.y = rabbyt.ease_in( y+50, y-50, dt=6, extend="reverse") rgb1 = (1.0, 0.0, 0.0) rgb2 = (0.0, 1.0, 0.0) rgb3 = (0.0, 0.0, 1.0) #sprite.rgb = rabbyt.chain( # rabbyt.lerp(rgb1, rgb2, dt=5), # rabbyt.lerp(rgb2, rgb3, dt=5, extend="reverse") #) #sprite.red = rabbyt.lerp(0.50, 1.00, dt=2, extend="reverse") #sprite.green = rabbyt.lerp(0.50, 1.00, dt=4, extend="reverse") #sprite.blue = rabbyt.lerp(0.50, 1.00, dt=8, extend="reverse") #sprite.alpha = rabbyt.lerp(0.25, 0.75, dt=1, extend="reverse") return sprite
def g(): x = random.randrange(w) y = random.randrange(h) sprite = rabbyt.Sprite(DAT_IMG) sprite.shape.width = 32 sprite.shape.height = 32 # TODO: Not exact! #sprite.tex_shape.width = 1.0/3.0/3.0 sprite.tex_shape.width = 1.0/8.0 sprite.tex_shape.height = 1.0/8.0 sprite.tex_shape.left = 0 sprite.tex_shape.bottom = 0 # TODO: WHY DOES THIS WORK #sprite.u = rabbyt.lerp(0, 1.0/4.0, dt=4, extend="constant") sprite.xy = (x, y) sprite.scale = rabbyt.ease(0.25, 1.50, dt=1, extend="reverse") sprite.rot = rabbyt.ease(0.00, 360.00, dt=1, extend="extrapolate") sprite.x = rabbyt.ease_out(x-50, x+50, dt=1, extend="reverse") sprite.y = rabbyt.ease_in( y+50, y-50, dt=1, extend="reverse") rgb1 = (1.0, 0.0, 0.0) rgb2 = (0.0, 1.0, 0.0) rgb3 = (0.0, 0.0, 1.0) #sprite.rgb = rabbyt.chain( # rabbyt.lerp(rgb1, rgb2, dt=5), # rabbyt.lerp(rgb2, rgb3, dt=5, extend="reverse") #) sprite.red = rabbyt.lerp(0.50, 1.00, dt=2, extend="reverse") sprite.green = rabbyt.lerp(0.50, 1.00, dt=4, extend="reverse") sprite.blue = rabbyt.lerp(0.50, 1.00, dt=8, extend="reverse") sprite.alpha = rabbyt.lerp(0.25, 0.75, dt=1, extend="reverse") return sprite
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.
chimp.y, fist.y = 50, 50 @win.event def on_draw(): rabbyt.clear() fist.render() chimp.render() # Step 3 - Make the hand move from pyglet.window import mouse @win.event def on_mouse_motion(x, y, dx, dy): fist.xy = x, y # Step 4 - Make the chip move chimp.x = rabbyt.ease(50, 750, dt=1.3, extend="reverse") pyglet.clock.schedule(rabbyt.add_time) # Step 5 - Add violance @win.event def on_mouse_press(x, y, b, m): # Check the chimp and hand positions if rabbyt.collisions.aabb_collide([chimp, fist]): # Play some sound sound.play() # Make the chimp angry chimp.texture = 'ca.png' # Stop the chimp
rabbyt.set_default_attribs() quit = False image, size = rabbyt.pygame_load_texture('big.png') sprite = rabbyt.Sprite(image, size) #"../cocos2d/player.png") sprites = [sprite] #sprite.x = rabbyt.ease(0, 200, dt=4000, method='sine') anim = rabbyt.chain( rabbyt.ease(0, 360, dt=1000, method='sine'), rabbyt.ease(360, 0, dt=1000, method='sine'), ) sprite.rot = anim scheduler = rabbyt.Scheduler() def saludar(): print "Hola mundo" return True scheduler.add(2001, saludar) while not quit:
def bstraight_across(start, time=4): """pattern""" return rabbyt.ease(start, start-1000, dt=time)
def straight_down(start, time=4): return rabbyt.ease(start, start-800, dt=time)
def straight_across(start, time=4): return rabbyt.ease(start, start+1000, dt=time)
def movpatterny(start): return rabbyt.chain( rabbyt.ease(start, start-400, dt=1), rabbyt.ease(start-400, start-200, dt=2), rabbyt.ease(start-200, start-400, dt=1, extend="reverse"),)