crsfml

Bindings to SFML multimedia/game library sfml game-framework bindings
2.2.0 released
oprypin/crsfml
343 13 4
Oleh Prypin

CrSFML

Crystal bindings to Simple and Fast Multimedia Library (through CSFML).

See introduction, examples, documentation.

CrSFML supports CSFML 2.2. It has been tested on Linux 64-bit. It should work on other major systems if Crystal supports them.

CSFML 2.2, which requires SFML 2.2, must be installed to use it.

Crystal 0.6.1 and earlier are not supported.

Troubleshooting

Introduction

CrSFML allows you to use SFML, which is a library made in C++. So most information and tutorials for SFML revolve around C++. It is a good idea to get familiar with SFML itself first.

Each SFML module is implemented with 3 source files.

  • lib-files are an auto-generated definition of CSFML API: lib CSFML. These can be used directly, by themselves or in combination with wrappers.
  • obj-files are auto-generated convenient object and function wrappers. These make up the module SF. The main file for each SFML module just imports these and adds some more convenience functionality, like overloaded functions that were dropped in CSFML compared to SFML, and ways to avoid dealing with the remaining exposed pointers.

The API attempts to be similar to SFML's, but some general changes are present:

  • There is a clear separation between "classes" and "structs". Classes are wrapped, and structs are taken directly from libs, making them limited, for example, instead of instance methods they have functions in the root of the namespace.
  • Everything is renamed to snake_case.
  • To construct an object (sf::SomeType x(param)):
    • x = SF::SomeType.new(param) for classes.
    • x = SF::some_type(param) for structs.
    • Use SF::Vector2(T), SF.vector2(x, y) instead of Vector2(f|i). 2-tuples can often be used instead.
    • Member functions, such as loadFromFile, that are used for initialization, become class methods (from_file).
  • Getter, setter functions are changed:
    • x.getSomeProperty() becomes x.some_property.
    • x.isSomeProperty() becomes x.some_property?.
    • x.setSomeProperty(v) becomes x.some_property = v.
  • SFML sometimes uses enum values as bitmasks. You can combine them using the | operator.
  • Unicode just works.
  • Type differences:
    • unsigned int is mapped as Int32, etc., so you don't have to bother with unsigned types. This shouldn't cause problems, but it might.
  • Most of the documentation is taken directly from CSFML, so don't be surprised if it talks in C/C++ terms.

See examples to learn more.

Acknowledgements

License: zlib/libpng

This library uses and is based on SFML and CSFML.

Crystal and Python programming languages are used.

crsfml:
  github: oprypin/crsfml
  version: ~> 2.2.0
Crystal none

Dependencies 0

Development Dependencies 0

Other repos 1

Last synced .
search fire star recently