Skip to main content

A python wrapper for raylib using ctypes

Project description

raylib-python-ctypes

A python wrapper for the greatest graphic library raylib.

Prerequisites

raypyc uses type annotations in its source, so a Python version that supports it is required.

Installing

the fastest way to use raypyc is by using the pip install command:

pip install raypyc

or

python -m pip install raypyc

Using raypyc

using raypyc is really simple, make a look at an example[^1]:

"""

raylib [core] example - Basic Window

"""

# Import
# ------------------------------------------------------------------------------------
from raypyc import *
# ------------------------------------------------------------------------------------

# ------------------------------------------------------------------------------------
# Program main entry point
# ------------------------------------------------------------------------------------
def main():
    # Initialization
    # ------------------------------------------------------------------------------------
    SCREEN_WIDTH = 800
    SCREEN_HEIGHT = 450

    init_window(SCREEN_WIDTH, SCREEN_HEIGHT, b"raylib [core] example - basic window")

    # TODO: Load resources / Initialize variables at this point

    set_target_fps(60)  # Set our game to run at 60 frames-per-second
    # ------------------------------------------------------------------------------------

    # Main game loop
    while not window_should_close():  # Detect window close button or ESC key
        # Update
        # ----------------------------------------------------------------------------------
        # TODO: Update variables / Implement example logic at this point
        # ----------------------------------------------------------------------------------

        # Draw
        # ----------------------------------------------------------------------------------
        begin_drawing()

        clear_background(RAYWHITE)
        draw_text(b"Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY)

        end_drawing()
        # ----------------------------------------------------------------------------------

    # De-Initialization
    # ----------------------------------------------------------------------------------

    # TODO: Unload all loaded resources at this point

    close_window()  # Close window and OpenGL context
    # ----------------------------------------------------------------------------------


# Execute the main function
if __name__ == '__main__':
    main()

[^1]the example use a main function to run, you don't have to use that if you don't want to...

raylib vs raypyc

Below are the differences in usage between raylib and raypyc.

Enums

All C typeof enums got translated to Python 'constants'. Enums got translated to Python enums.

Structures

In general, all structures inherit from ctypes.Structure class. At the moment, all the structures have a setters & getter

Contributing

firstly, Contributions of any kind welcome!.

secondly, here are some of the things that contributing on will help this wrapper the most:

  • porting examples from c to python(if you can, please follow along with the conventions when porting). (C examples, Python examples)
  • fixing(refactoring) my fileGeneration code: so it will be able to accept arrays of pointer, so it will look neater...
  • making the wrapper able to port to more operating systems
  • adding support to sound with the library. (make the library wrap sound functions/structures)
  • wrapping more c raylib header to this library[^2]

[^2] NOTE: at least for now, all the non-functions wrapper stuff need be implemented in the filesGeneration.py file, and all the functions wrapper stuff need be implemented in the raypyc/init.py

thanks

thanks for raysun5, raylibpy and pyray for their good work, I took all the inspiration (and some code ;) ) from them, so thanks you guys very much

Project details


Download files

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

Source Distribution

raypyc-0.0.2.tar.gz (750.6 kB view details)

Uploaded Source

Built Distribution

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

raypyc-0.0.2-py3-none-any.whl (756.6 kB view details)

Uploaded Python 3

File details

Details for the file raypyc-0.0.2.tar.gz.

File metadata

  • Download URL: raypyc-0.0.2.tar.gz
  • Upload date:
  • Size: 750.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for raypyc-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ce58098a510ede7415294a61b5f88f7be498b7e00590cad0d7bb895a07f4a2c5
MD5 f4bd50938481a449bda820039c00c108
BLAKE2b-256 89177f512a5317ae8a3b0776116a5eb125287d9a6f0bfefb066e412188b87f7b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raypyc-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 756.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for raypyc-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88faff2186bb05d87ba8c651e8d3215a2a5f3af7e9e7168ff6e22ea510bd30ce
MD5 cf75d45368072a0d4ce3c2a0bd721926
BLAKE2b-256 713ba15df9ea860f61662dc8b9d45dbbbe15355067c5b999d4e1dc01bfe22bbb

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