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.0.2

Features

  • Raylib bindings (using raylib-python-cffi)
  • 2D rendering (shapes, sprites, text)
  • Audio (music, sound effects)
  • Scene management
  • Actor framework
  • Linear algebra (vector, matrix, quaternion, 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

attrs==25.1.0
cffi==1.17.1
multipledispatch==1.0.0
numpy==2.2.2
pycparser==2.22
pyglsl==0.0.5
raylib==5.5.0.2
six==1.17.0
transitions==0.9.2
typing==3.7.4.3

TODO

  • Action Nodes
  • Timer Node
  • RenderTexture wrapper
  • Emitter Node
  • TileMap Node
  • 3D Nodes
  • 2D + 3D Collision
  • 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.0.2-py3-none-any.whl (49.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for spritekit-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 749bc9a83ea1453e3cdd7675dfd29281d828e432c5a32d66a957e67f093abb97
MD5 8ad989ba162b471cdb580f51a9480b6d
BLAKE2b-256 fe01689dee954630b8080a66702fb261b1b68095f454eff3f84694bb9a7f03d6

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