Add the following code to your project's shard.yml under:
dependencies
to use in production
- OR -
development_dependencies
to use in development
Crystal binding of Allegro 5.x game library.
Because Allegro is C library, no extra process exists other than building a regular Crystal app.
shard.yml
:
dependencies:
allegro:
github: lugia-kun/crystal-allegro
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
.
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
TODO: Write development instructions here
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)