Skip to content

Latest commit

History

309 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

boleite

Boleite

Work In Progress Framework for developing Games in Crystal. You can view it in use at my other project Ego.

Installation

Add this to your application's shard.yml:

dependencies:
boleite:
github: Groogy/boleite

You will also need to install libraries needed for the backend to work. As long as they are in PATH it will work just fine, if you are using a package manager you probably don't need to worry about it. Needed dependencies are:

  • libfreetype-6
  • libfreeimage-3
  • libGL
  • libglfw-3

Usage

To get everything setup and started you need to create an Application and a state to push onto it's StateStack. The application is also responsible for finding the configuration the framework will be using or defining it's default values. The configuration needs to define the backend configuration data so the frameworks backend can be properly setup.

require"boleite"classMyConfiguration < Boleite::Configurationproperty:backend@backend=Boleite::BackendConfiguration.new
structSerializerdefmarshal(obj, node)
node.marshal "backend", obj.backend
enddefunmarshal(node)
config =MyConfiguration.new
config.backend = node.unmarshal "backend", Boleite::BackendConfiguration
config
endendextendBoleite::Serializable(Serializer)
endclassMyApplication < Boleite::ApplicationCONFIGURATION_FILE="config.yml"defcreate_configuration : Boleite::ConfigurationifFile.exists? CONFIGURATION_FILEFile.open(CONFIGURATION_FILE, "r") do |file|
serializer =Boleite::Serializer.new nil
serializer.read(file)
config = serializer.unmarshal(MyConfiguration)
config.as(MyConfiguration)
endelseFile.open(CONFIGURATION_FILE, "w") do |file|
config =MyConfiguration.new config.backend =@backend.default_config
serializer =Boleite::Serializer.new nil
serializer.marshal(config)
serializer.dump(file)
config
endendendendSHADER_STR="#version 330vertex{ layout(location = 0) in vec4 pos; void main() { gl_Position = pos; }}fragment{ layout(location = 0) out vec4 outputAlbedo; void main() { outputAlbedo = vec4(1, 0, 0, 1); }}"classMyState < Boleite::Statedefinitialize(@app : MyApplication)
super()
gfx =@app.graphics
target = gfx.main_target
shader =Boleite::Shader.load_string SHADER_STR, gfx
@camera2d=Boleite::Camera2D.new(target.width.to_f32, target.height.to_f32, 0f32, 1f32)
@renderer=Boleite::ForwardRenderer.new gfx, @camera2d, shader
enddefenableenddefdisableenddefupdate(delta)
enddefrender(delta)
@renderer.clear Boleite::Color.black
@renderer.present
endend
app =MyApplication.new
app.state_stack.push MyState.new(app)
app.run

Development

TODO: Write development instructions here

Contributing

  1. Fork it ( https://github.com/Groogy/boleite/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • Groogy Henrik Valter Vogelius Hansson - creator, maintainer

About

Framework for developing Games in Crystal

Resources

Stars

29 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages