crystal-allegro
crystal-allegro
Crystal binding of Allegro 5.x game library.
Because Allegro is C library, no extra process exists other than building a regular Crystal app.
Installation
- Install development files (header files, pkg-config files, and libraries) of Allegro 5.
- Add the dependency to your
shard.yml
:dependencies: allegro: github: lugia-kun/crystal-allegro
- Run
shards install
We are using GCC or Clang (or any compiler supports -dM
option which lists defined macros instead of compile) to obtain specific values of macros defined by Allegro library. The compiler to be used for this can be changed using the enviroment variable CRYSTAL_ALLEGRO_CC
.
Usage
Basic Example
require "allegro"
Allegro.initialize
Allegro::Keyboard.initialize
timer = Allegro::Timer.for(1.0 / 30.0)
display = Allegro::Display.new(320, 240)
font = Allegro::Font.builtin_font
queue = Allegro::EventQueue.new
queue.register_keyboard_events
queue.register(display)
queue.register(timer)
timer.start
redraw = false
loop do
event = queue.wait_for_event
case event
when Allegro::KeyDownEvent, Allegro::DisplayCloseEvent
break
when Allegro::TimerEvent
redraw = true
end
if redraw && queue.is_empty?
Allegro::Display.clear_to_color(Allegro::Color.new(0, 0, 0))
font.draw("Hello, World!", Allegro::Color.new(255, 255, 255), 0, 0, 0)
Allegro::Display.flip
redraw = false
end
end
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/lugia-kun/crystal-allegro/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
- Hajime Yoshimori - creator and maintainer
Repository
crystal-allegro
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- about 4 years ago
- August 14, 2020
License
zlib License
Links
Synced at
Fri, 22 Nov 2024 12:33:07 GMT
Languages