GitXplorerGitXplorer
s

gosu-tiled

public
19 stars
7 forks
2 issues

Commits

List of commits on branch master.
Unverified
7ed30ee681efbe690d1c658725dd76ba13f90898

Updated bundler and rspec versions in gemspec

jjohncrudo committed 5 years ago
Unverified
0c6654263595b01d20eb619a14129945a778e796

Update readme with info about tile layer format

sspajus committed 8 years ago
Unverified
c67d4b66c98adcf9605d5b70244fcada829f171d

Add reasoning about JSON vs TMX

sspajus committed 11 years ago
Unverified
f4e9fb9e86adca40cc3eb9fc79b5edf5a62a11d8

Reduce gem size

sspajus committed 11 years ago
Unverified
9726cd4617076e44c0864682e49d98f505dc504a

Restrict example panorama to map boundaries

sspajus committed 11 years ago
Unverified
354ac5dd70a2e5d67c8389b1bbd8b869e6173b88

Rearrange text

sspajus committed 11 years ago

README

The README file for this repository.

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