Add the following code to your project's shard.yml under:
to use in production
- OR -
development_dependencies to use in development
dependencies: game: github: mswieboda/game
For now this is basically just an object-oriented wrapper around Cray/RayLib functionality.
Eventually will include more concepts such as a Viewport, basic Player or Player Controllers, UI messages, loading/saving, and other miscelleneous concepts to assist developing a game.
See the examples
examples/shapes.cr on how to use the provided classes.
Inherit your main game project class from
Game to enable the RayLib setup and game loop.
require "game" class FooGame < Game def initialize super( name: "FooGame", screen_width: 1024, screen_height: 768 ) end def update(frame_time) end def draw end end FooGame.new.run
Game#run will initialize RayLib, and begin the game loop, calling
Game#draw which are meant to be overriden with your game and drawing logic. Use the built-in classes to draw with using
#draw or call drawing methods directly with
LibRay (available via the cray shard dependency).
def draw # use built-in classes created in `initialize` or elsewhere to draw, such as `Rectangle` @rectangle.draw # or call LibRay draw methods directly LibRay.draw_rectangle(x: 30, y: 30, width: 100, height: 25, color: Color::Red.to_struct) end
Note: Since many features are currently WIP, interacting with
LibRay directly is a valid option.
Game#load_spritesmethod to override
Game#load_soundsmethod to override
git checkout -b my-new-feature)
git commit -am 'Add some feature')
git push origin my-new-feature)