GitXplorerGitXplorer
s

gosu-tiled

public
19 stars
7 forks
2 issues

Commits

List of commits on branch master.
Verified
3a0da93a1f23f5bfba91f2b1ea7a9647d1051ef2

Merge pull request #5 from phylor/features/note-embedded-tilesets

sspajus committed 5 years ago
Verified
44cb99b7a16896e40ae54a952e5e5dd9af7bfbab

Add note about embedding tilesets

pphylor committed 5 years ago
Verified
c7302b1b47139c49aeb79524af3862133a7cdc00

Merge pull request #4 from johncrudo/master

sspajus committed 5 years ago
Unverified
6095372850700acde2f365948bff7e51a13d182e

Updated specs and added a few new ones to ensure options hash works.

jjohncrudo committed 5 years ago
Unverified
1689454b7829b72f9e44eae5c75c77510eb0e57a

Gosu::Image.load_tiles no longer requires window as first arg and final arg is now an options hash

jjohncrudo committed 5 years ago
Unverified
c683ee1f375307538e48e014ec191c31504e3fe5

Updated gosu dependency in gemspec

jjohncrudo committed 5 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