Beispiel #1
0
 def make_board_scene(self, center_frame):
     board_scene = SkChessBoardScene(self.game, center_frame)
     scene_view = sk.View(board_scene)
     scene_view.frame = center_frame  # center_square()
     scene_view.shows_fps = True
     scene_view.shows_node_count = True
     scene_view.shows_physics = True
     return scene_view
Beispiel #2
0
            if len(y) == 0:
                return

            for i, n in enumerate(self.v):
                iy = int(i / Np * len(y))
                n.position = (i / Np * W, y[iy] * H + H / 2)

        def did_stop(self):
            print('stopping')
            #raise Error()
            self['n'][0].remove_all_actions()
            [rec.stop() for rec in r]
            ui.delay(cleanup, 0.25)
            # the scene seems to crash when restarting, unless we raise an error here
            raise KeyboardInterrupt

    #sc=Vis(dofft=True)
    sc = Vis(dofft=False)
    v = sk.View(sc)
    v.shows_fps = True
    v.shows_node_count = True
    v.present()

    def cleanup():
        # required b/c beta always clears globals
        print('cleaning up')
        del globals()['r']
        del globals()['sc']
        del globals()['v']
Beispiel #3
0
def main():
    game = Game()
    scene_view = sk.View()
    scene_view.run(game)
    scene_view.present()
Beispiel #4
0
def main():
    clock = Clock()
    scene_view = sk.View()
    scene_view.frame_interval = 2  #30 fps
    scene_view.run_scene(clock)
    scene_view.present()
Beispiel #5
0
def main():
    scene = ClockScene()
    scene_view = sk.View()
    scene_view.run_scene(scene)
    scene_view.present(orientations=['portrait'])
Beispiel #6
0
import ui
W = ui.get_screen_size().width
H = ui.get_screen_size().height
import sk


class Vis(sk.Scene):
    def __init__(self):
        self.v = [sk.SpriteNode() for x in xrange(int(W) * 2)]
        for i, sp in enumerate(self.v):
            sp.size = (5, 5)
            sp.position = (i / 2., H / 2)
            sp.color = (i / W / 2, (1 - i / W / 2), (0.5 + i / 800.0))
            self.add_child(sp)
        self.a1 = sk.Action.call(self.update_y)
        self.a2 = sk.wait(0.1)
        self.a3 = sk.sequence([self.a1, self.a2])
        self.a4 = sk.Action.repeat_forever(self.a3)
        n = sk.Node()
        self.add_child(n)
        n.run_action(self.a4)

    def update_y(self):
        y = record()
        for i, n in enumerate(self.v):
            iy = int(i / W / 2.0 * len(y))
            n.position = (i / 2., y[iy] * H + H / 2)


v = sk.View(Vis())
v.present()
Beispiel #7
0
def main():
    scene = ShaderScene()
    scene_view = sk.View()
    scene_view.run_scene(scene)
    scene_view.present()
Beispiel #8
0
def main():
    game = ParticleScene()
    scene_view = sk.View(game)
    scene_view.shows_fps = True
    scene_view.shows_node_count = True
    scene_view.present()
Beispiel #9
0
    def update_camera(self):
        if self.game_finished: return
        player_pos = self.player.position
        center = sk.Point(self.size.w / 5 / zoom, self.size.h / 2 / zoom)
        cam_pos = min(0, center.x - player_pos.x), min(0,
                                                       center.y - player_pos.y)
        cam_pos = (cam_pos[0] * zoom, cam_pos[1] * zoom)
        self.foreground_layer.position = cam_pos
        self.tiled_bg.tile_offset = (
            (-self.foreground_layer.position.x * 0.75) % 512.0, 0)
        self.tiled_bg.position = (512, 256 + cam_pos[1] * 0.75)

    def show_dust_effect(self, pos):
        self.dust_effect.num_particles_to_emit = 5
        self.dust_effect.position = pos
        self.dust_effect.reset_simulation()
        self.dust_effect.advance_simulation_time(0.2)

    def jump(self, strength=6.5):
        self.v = sk.Vector2(self.v.x, min(15, strength))
        self.standing = False
        self.ground_t = 0

    def did_stop(self):
        self.music.stop()


scene_view = sk.View()
game = Game()
scene_view.run_scene(game)
scene_view.present(orientations=['landscape'])