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 +4 -4
- data/README.md +17 -1
- data/examples/screenshots/tile_brush.png +0 -0
- data/examples/tile_brush.rb +52 -0
- data/gosu_texture_packer.gemspec +1 -0
- data/lib/gosu_texture_packer/version.rb +1 -1
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 859d881aa99b72a958e2059726d6ca93dbdfab5a
|
4
|
+
data.tar.gz: 613d17c1959e4c36e321f42f655f22be63ca380c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/gosu_texture_packer.gemspec
CHANGED
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
|
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
|