Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.
/ crystal2d Public archive

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

License

Notifications You must be signed in to change notification settings

sheosi/crystal2d

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published