gosu_texture_packer 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05c6b2ef4f697ecc5d133b1315f6507dafd9b9c9
4
- data.tar.gz: 70971f454fd295da0cbbd326b6d53661d639fe69
3
+ metadata.gz: 859d881aa99b72a958e2059726d6ca93dbdfab5a
4
+ data.tar.gz: 613d17c1959e4c36e321f42f655f22be63ca380c
5
5
  SHA512:
6
- metadata.gz: 0e7c3a349d04bcfc44c142ea82186abe0b7eaac9d7839291b2683159bc7c4db8886ae4d75927e957629e14e7598e8fe835a0df5862778cca19505b57afaaa6bb
7
- data.tar.gz: 777610a8c2b40eaf69f1201911b00e464172ffcaa685499b3b0ba427184e64c3e1494560eb5b66884d78281aa752211c0b21b85d0390dcdbb59205af49c9c9ef
6
+ metadata.gz: c562495a09c87284d07ebb4d6923640e77ab14eaf17eef9fac2e6ef6547156d12448a319667d143718b32cd95bb731678582ca649887c6c268ac23a57c2d4f5d
7
+ data.tar.gz: 27bcc8fe38d88f1489baefdf5066fa5b1698d0b74d1088e0fbdd214fca078914de4e23dd09f5385a1c755021a28c343cad3c52eeddc1bb8203a84ac555a7ee00
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # GosuTexturePacker
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/gosu_texture_packer.svg)](http://badge.fury.io/rb/gosu_texture_packer)
4
+ [![Code Climate](https://codeclimate.com/github/spajus/gosu-texture-packer.png?branch=master)](https://codeclimate.com/github/spajus/gosu-texture-packer)
5
+
3
6
  [TexturePacker](http://www.codeandweb.com/texturepacker) support for [Gosu](https://github.com/jlnr/gosu) game engine.
4
7
 
5
8
  ## Installation
@@ -19,12 +22,25 @@ Or install it yourself as:
19
22
  ## Usage
20
23
 
21
24
  ```ruby
22
- tileset = Gosu::TexturePacker::Tileset.load_json('/path/to/tileset.json')
25
+ tileset = Gosu::TexturePacker::Tileset.load_json(gosu_window, '/path/to/tileset.json')
23
26
  frame_names = tileset.frame_list
24
27
  tile = tileset.frame(frame_names.first)
25
28
  tile.draw(0, 0, 0) # tile is Gosu::Image
26
29
  ```
27
30
 
31
+ ## Example Code
32
+
33
+ Run
34
+ [examples/tile_brush.rb](https://github.com/spajus/gosu-texture-packer/blob/master/examples/tile_brush.rb)
35
+ to see `gosu_texture_packer` in action.
36
+
37
+ Example tileset is loaded from
38
+ [spec/files](https://github.com/spajus/gosu-texture-packer/tree/master/spec/files) directory.
39
+
40
+ Click the window to draw random tiles.
41
+
42
+ ![Gosu TexturePacker Example](https://raw.githubusercontent.com/spajus/gosu-texture-packer/master/examples/screenshots/tile_brush.png)
43
+
28
44
  ## Contributing
29
45
 
30
46
  1. Fork it ( https://github.com/[my-github-username]/gosu_texture_packer/fork )
Binary file
@@ -0,0 +1,52 @@
1
+ ROOT_DIR = File.dirname(File.dirname(__FILE__))
2
+
3
+ # Add ../lib to load path
4
+ $:.unshift File.join(ROOT_DIR, 'lib')
5
+
6
+ require 'gosu'
7
+ require 'gosu_texture_packer'
8
+
9
+ class GameWindow < Gosu::Window
10
+ def initialize
11
+ super(640, 480, false)
12
+ self.caption = 'Click screen with mouse to draw textures'
13
+ @tileset = Gosu::TexturePacker::Tileset.load_json(
14
+ self, File.join(ROOT_DIR, 'spec', 'files', '_UI.json'))
15
+ @drawing = {}
16
+ end
17
+
18
+ def needs_cursor?
19
+ true
20
+ end
21
+
22
+ def update
23
+ @fps = Gosu::Image.from_text(
24
+ self, "FPS: #{Gosu.fps}; Mem Usage: #{memory_usage}",
25
+ Gosu.default_font_name, 30)
26
+ end
27
+
28
+ def button_down(id)
29
+ close if id == Gosu::KbEscape
30
+ if id == Gosu::MsLeft
31
+ @drawing[[mouse_x, mouse_y]] = @tileset.frame(@tileset.frame_list.sample)
32
+ end
33
+ end
34
+
35
+ def draw
36
+ @drawing.each do |coords, tile|
37
+ tile.draw(coords[0], coords[1], 0)
38
+ end
39
+ @fps.draw(10, 10, 1)
40
+ end
41
+
42
+ private
43
+
44
+ def memory_usage
45
+ `ps -o rss= -p #{Process.pid}`
46
+ .chomp.gsub(/(\d)(?=(\d{3})+(\..*)?$)/,'\1,') + ' KB'
47
+ rescue
48
+ "Unavailable. Using Windows?"
49
+ end
50
+ end
51
+
52
+ GameWindow.new.show
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.add_dependency 'gosu'
21
22
  spec.add_dependency 'json'
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.6'
@@ -1,5 +1,5 @@
1
1
  module Gosu
2
2
  module TexturePacker
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu_texture_packer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Varaneckas
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gosu
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: json
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,8 @@ files:
94
108
  - LICENSE.txt
95
109
  - README.md
96
110
  - Rakefile
111
+ - examples/screenshots/tile_brush.png
112
+ - examples/tile_brush.rb
97
113
  - gosu_texture_packer.gemspec
98
114
  - lib/gosu_texture_packer.rb
99
115
  - lib/gosu_texture_packer/tileset.rb