/crystal2d

A small, super-easy-to-use 2D game engine for Crystal

Primary LanguageCrystalMIT LicenseMIT

Crystal 2D
-----------

A small, super-easy-to-use , which has a Rails-like API, 2D game engine made using Crystal and SDL.

Example
--------
This renders "char_1_side.png" and moves it if A is pressed, and closes upon receiving a close or a escape key press event:
```
require "sdl2"
require "./sdlFix"
require "./crystal2d"

class MyGame < Crystal2d::App
	
	define_signals :is_running,  LibSDL2::Key::ESCAPE,  Toggle,
			       :is_running,  SDL2::EventType::QUIT, Toggle,
	               :should_move, SDL2::Scancode::A,     OnOff

	def on_init
		@spr = Crystal2d::Sprite.new("char_1_side.png",0)
	end

	def on_game_frame(timestep)	
		@spr.x =@spr.x + 100*timestep if @should_move
	end
end

MyGame.new.run
```
Note: "sdlFix.cr" is just a (temporary) patch to the existing SDL2 library