Skip to main content

2D scene+actor framework built on top of raylib

Project description

PySpriteKit

[!WARNING] Work in progress, see TODO

2D scene+actor framework built on top of raylib, based off SpriteKit by Apple.

[!NOTE] pip install spritekit==0.1.2

Features

  • Raylib bindings (using raylib-python-cffi)
  • 2D rendering (shapes, sprites, text)
  • Audio (music, sound effects)
  • Scene management
  • Actor framework
  • Linear algebra (vector2,3,4, matrix4, taken from Pyrr)
  • Easing functions (taken from raylib-py)
  • Finite state machine (build on top of transitions)
  • Action framework

Example

import spritekit as sk
from typing import override

@sk.main_scene
class TestScene(sk.Scene):
    config = {
        "width": 800,
        "height": 600,
        "title": "Test",
        "exit_key": sk.Keys.escape,
        "flags": sk.Flags.window_resizable,
        "fps": 60
    }

    def add_stuff(self):
        self.add_child(sk.RectangleNode(name="test",
                                        width=100,
                                        height=100,
                                        color=sk.Color(1., 0, 0)))
        self.add_child(sk.CircleNode(name="test",
                                     position=sk.Vector2([100, 100]),
                                     radius=100,
                                     color=sk.Color(0, 1., 0)))
        self.add_child(sk.TriangleNode(name="test",
                                       position2=sk.Vector2([100, 200]),
                                       position3=sk.Vector2([200, 100]),
                                       color=sk.Color(0, 0, 1.)))
        self.add_child(sk.SpriteNode(name="test",
                                     texture=sk.Texture(f"assets/textures/LA.png"),
                                     origin=sk.Vector2([1., 1.]),
                                     scale=sk.Vector2([0.5, 0.5])))

    @override
    def enter(self):
        self.add_child(sk.LabelNode(name="tset",
                                    text="Hello, World!",
                                    font_size=24,
                                    color=sk.Color(1., 0., 1.)))
        self.add_child(sk.MusicNode(name="bg",
                                    music=sk.Music(f"assets/audio/country.mp3"),
                                    autostart=True))
        self.add_stuff()

    @override
    def step(self, delta):
        if sk.Keyboard.key_pressed("r"):
            if self.find_children("test"):
                self.remove_children("test")
            else:
                self.add_stuff()
        if sk.Keyboard.key_pressed("space"):
            for child in self.find_children("bg"):
                child.toggle()

        for child in self.children("test"):
            child.position.x += 100 * delta
        for child in self.children("tset"):
            child.rotation += 100 * delta
        super().step(delta) # update scene internal step

Requirements

numpy==2.2.2
raylib==5.5.0.2
transitions==0.9.2
slimrr==0.1.0

TODO

  • Action Nodes
  • Timer Node
  • RenderTexture wrapper
  • Emitter Node
  • TileMap Node
  • 3D Nodes (displayed in 2D)
  • 2D Physics
  • Video Node
  • Transform Node
  • Add examples
  • Add documentation

LICENSE

PySpriteKit

Copyright (C) 2025 George Watson

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spritekit-0.1.2-py3-none-any.whl (46.9 kB view details)

Uploaded Python 3

File details

Details for the file spritekit-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: spritekit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 46.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for spritekit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 12e545d013e475993a6d91980f8a4995f1123d5ce45f813782b264b46a435523
MD5 380b95a512ddfb0713230d06ed559a36
BLAKE2b-256 05ad5c381613a02eb08d44b00862fc6595f722a56e4dd1a908129e8012ceebb5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page