mancala
Mancala
Mancala name is inspired from one of the oldest known games to still be widely played today.
It's goal is to simplify the creation of a multi-view SFML app in Crystal Lang.
Installation
-
Add the dependency to your
shard.yml
:dependencies: mancala: github: alex-lairan/mancala
-
Add crsfml to your project.
-
Run
shards install
Usage
First, require the shard :
require "mancala"
Then, create a context for our game :
struct Context
property texture = Mancala::Resource(SF::Texture).new
end
Now you can create a controller :
mode = SF::VideoMode.new(width, height)
window = SF::RenderWindow.new(mode, name, SF::Style::Fullscreen)
context = Context.new
controller = Mancala::Controller(Context).new(window, context)
Let's register some activities !
class Menu < Mancala::Activity(Context)
end
class Game < Mancala::Activity(Context)
end
controller.register(:game) { |controller| Game.new(controller) }
controller.register(:menu) { |controller| Menu.new(controller) }
Finally, push an activity !
controller.push(:menu)
This controller need to be called on your program loop.
This is an example :
clock = SF::Clock.new
while window.open?
dt = clock.restart
while event = @window.poll_event
controller.handle_event(event)
end
controller.update(dt)
controller.render
window.display
end
Contributing
- Fork it (https://github.com/alex-lairan/mancala/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Alexandre Lairan - creator and maintainer
Repository
mancala
Owner
Statistic
- 3
- 0
- 0
- 1
- 0
- over 5 years ago
- March 10, 2019
License
MIT License
Links
Synced at
Wed, 06 Nov 2024 15:54:38 GMT
Languages