예제 #1
0
        def build(self):
                state = factory.create(screen_width, screen_height, tile_size)

                tiles.add_tile_def(state, ' ', ("assets/img/tiles/blank.png",))
                tiles.add_tile_def(state, '+', ("assets/img/tiles/block.png",),
                                   (("rectangle", 0, 0, 1, 1),))
                area_strings = (
                        "    ",
                        " +  ",
                        "    ",
                        " +  ",
                        "    ",
                        )
                tiles.set_area(state, tiles_helpers.strings_to_chars(area_strings))

                collisions.set_handler(state, collision_handler)

                BALL_SIZE = (1.0 / 4.0)
                CIRCLE_RADIUS = BALL_SIZE / 2
                entities.insert(state,
                                "ball",
                                {
                                 "*": {
                                       "textures": ("assets/img/sprites/quarter_ball.png",),
                                       },
                                 },
                                (1.25, 0, 0,),
                                collision=(("circle", CIRCLE_RADIUS, CIRCLE_RADIUS, CIRCLE_RADIUS,),)
                                )

                linear_mover.add(state, "ball", (0, 7), 1.5)

                return ScreenWidget(state, debugging=True)
예제 #2
0
    def build(self):
        state = factory.create(screen_width, screen_height, tile_size)

        tiles.add_tile_def(state, ' ', ("assets/img/tiles/blank.png", ))
        tiles.add_tile_def(state, '+', ("assets/img/tiles/block.png", ),
                           (("rectangle", 0, 0, 1, 1), ))
        area_strings = (
            "    ",
            " +  ",
            "    ",
            " +  ",
            "    ",
        )
        tiles.set_area(state, tiles_helpers.strings_to_chars(area_strings))

        collisions.set_handler(state, collision_handler)

        BALL_SIZE = (1.0 / 4.0)
        CIRCLE_RADIUS = BALL_SIZE / 2
        entities.insert(state,
                        "ball", {
                            "*": {
                                "textures":
                                ("assets/img/sprites/quarter_ball.png", ),
                            },
                        }, (
                            1.25,
                            0,
                            0,
                        ),
                        collision=((
                            "circle",
                            CIRCLE_RADIUS,
                            CIRCLE_RADIUS,
                            CIRCLE_RADIUS,
                        ), ))

        linear_mover.add(state, "ball", (0, 7), 1.5)

        return ScreenWidget(state, debugging=True)
예제 #3
0
파일: demo_tiles.py 프로젝트: hanez/yapyg
def create(screen_width, screen_height, tile_size):
    state = factory.create(screen_width, screen_height, tile_size)

    tiles.add_tile_def(state, " ", ("assets/img/tiles/grass.png", ))
    tiles.add_tile_def(
        state, "+",
        ("assets/img/tiles/grass.png", "assets/img/tiles/brown_ground.png"))
    tiles.add_tile_def(
        state, "t",
        ("assets/img/tiles/grass.png", "assets/img/tiles/tree.png"))

    tiles_helpers.load_walls(state, "", "assets/img/tiles/grass.png",
                             "assets/img/tiles/bricks_walls.png")

    area_strings = (
        "      +           ",
        "      +           ",
        "      +           ",
        "      +           ",
        "      +           ",
        "      +           ",
        "      +           ",
        "      +           ",
        "      +.____,     ",
        "      +)<-->(     ",
        "      +)(tt)(     ",
        "      +)(tt)(     ",
        "      +)[__](     ",
        "      +:----;     ",
        "      +           ",
        "      +           ",
        "      +           ",
        "      +           ",
        "      +           ",
    )
    area = tiles_helpers.strings_to_chars(area_strings)
    tiles.set_area(state, area)

    entities.insert(
        state, "man", {
            "idle": {
                "textures": (
                    "assets/img/sprites/man_idle/0.png",
                    "assets/img/sprites/man_idle/1.png",
                    "assets/img/sprites/man_idle/2.png",
                    "assets/img/sprites/man_idle/3.png",
                    "assets/img/sprites/man_idle/1.png",
                    "assets/img/sprites/man_idle/0.png",
                    "assets/img/sprites/man_idle/3.png",
                    "assets/img/sprites/man_idle/2.png",
                ),
                "speed":
                333.0,
            },
            "walk": {
                "textures": (
                    "assets/img/sprites/man_walk/1.png",
                    "assets/img/sprites/man_walk/2.png",
                    "assets/img/sprites/man_walk/3.png",
                ),
                "speed":
                150.0,
            },
        }, (7.0, 5.0, 0), (0.25, 0.25))

    start_movement(state, None)

    view.set_viewer(state, relative_viewer.create(state, "man", [-1.5, -2.5]))

    return state
예제 #4
0
파일: demo_tiles.py 프로젝트: rkibria/yapyg
def create(screen_width, screen_height, tile_size):
        state = factory.create(screen_width, screen_height, tile_size)

        tiles.add_tile_def(state, " ", ("assets/img/tiles/grass.png",))
        tiles.add_tile_def(state, "+", ("assets/img/tiles/grass.png", "assets/img/tiles/brown_ground.png"))
        tiles.add_tile_def(state, "t", ("assets/img/tiles/grass.png", "assets/img/tiles/tree.png"))

        tiles_helpers.load_walls(state, "", "assets/img/tiles/grass.png", "assets/img/tiles/bricks_walls.png")

        area_strings = (
                "      +           ",
                "      +           ",
                "      +           ",
                "      +           ",
                "      +           ",
                "      +           ",
                "      +           ",
                "      +           ",
                "      +.____,     ",
                "      +)<-->(     ",
                "      +)(tt)(     ",
                "      +)(tt)(     ",
                "      +)[__](     ",
                "      +:----;     ",
                "      +           ",
                "      +           ",
                "      +           ",
                "      +           ",
                "      +           ",
                )
        area = tiles_helpers.strings_to_chars(area_strings)
        tiles.set_area(state, area)

        entities.insert(state, "man",
                {
                        "idle": {
                                "textures": (
                                        "assets/img/sprites/man_idle/0.png",
                                        "assets/img/sprites/man_idle/1.png",
                                        "assets/img/sprites/man_idle/2.png",
                                        "assets/img/sprites/man_idle/3.png",
                                        "assets/img/sprites/man_idle/1.png",
                                        "assets/img/sprites/man_idle/0.png",
                                        "assets/img/sprites/man_idle/3.png",
                                        "assets/img/sprites/man_idle/2.png",
                                        ),
                                "speed": 333.0,
                        },
                        "walk": {
                                "textures": (
                                        "assets/img/sprites/man_walk/1.png",
                                        "assets/img/sprites/man_walk/2.png",
                                        "assets/img/sprites/man_walk/3.png",
                                        ),
                                "speed" : 150.0,
                        },
                }, (7.0, 5.0, 0), (0.25, 0.25))

        start_movement(state, None)

        view.set_viewer(state, relative_viewer.create(state, "man", [-1.5, -2.5]))

        return state