Project

gosu_tiled

0.01
No commit activity in last 3 years
No release in over 3 years
Makes it easy to load tile maps built with Tiled editor into Gosu games
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
~> 3.0.0

Runtime

>= 0
>= 0
 Project Readme

gosu-tiled

Gem Version Code Climate

Tiled map loader for Gosu game development library.

How to use it?

Install the gem:

gem install gosu_tiled

Create yourself a game map with Tiled:

Tiled Map

Create your TMX, make sure "Tile Layer Format" is set to "CSV" and your tilesets are embedded, then export it as JSON and use with Gosu like this:

require 'gosu'
require 'gosu_tiled'

class GameWindow < Gosu::Window
  def initialize
    super(800, 600, false)
    @map = Gosu::Tiled.load_json(self, 'path/to/map.json')
    @x = @y = 0
    @speed = 3
  end

  def update
    @x -= @speed if button_down?(Gosu::KbLeft)
    @x += @speed if button_down?(Gosu::KbRight)
    @y -= @speed if button_down?(Gosu::KbUp)
    @y += @speed if button_down?(Gosu::KbDown)
  end

  def draw
    @map.draw(@x, @y)
  end
end

GameWindow.new.show

Run it and enjoy your game map:

Gosu Game

See full example code.

TODO

  • Caching and other performance improvements

Why JSON and not TMX?

  • TMX is based on XML
  • XML is a terrible format that should be extinct
  • XML parsing in Ruby is done with Nokogiri, which is a heavy library
  • JSON is simple and elegant

Contributing

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