kawaii 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +2 -0
  3. data/.yardoc/checksums +19 -0
  4. data/.yardoc/object_types +0 -0
  5. data/.yardoc/objects/root.dat +0 -0
  6. data/.yardoc/proxy_types +0 -0
  7. data/Gemfile +3 -0
  8. data/Gemfile.lock +28 -0
  9. data/LICENSE +22 -0
  10. data/README.md +46 -0
  11. data/Rakefile +2 -0
  12. data/backlog.md +26 -0
  13. data/bin/kawaii +13 -0
  14. data/doc/Kawaii/Animation.html +120 -0
  15. data/doc/Kawaii/AudioManager.html +202 -0
  16. data/doc/Kawaii/ContentManager.html +487 -0
  17. data/doc/Kawaii/Entity.html +604 -0
  18. data/doc/Kawaii/Game.html +1141 -0
  19. data/doc/Kawaii/InputManager.html +120 -0
  20. data/doc/Kawaii/Intro.html +120 -0
  21. data/doc/Kawaii/Math.html +105 -0
  22. data/doc/Kawaii/Node.html +1030 -0
  23. data/doc/Kawaii/NodeManager.html +512 -0
  24. data/doc/Kawaii/Scene.html +120 -0
  25. data/doc/Kawaii/SceneManager.html +200 -0
  26. data/doc/Kawaii/TextField.html +538 -0
  27. data/doc/Kawaii/TmxLayer.html +836 -0
  28. data/doc/Kawaii/TmxTileMap.html +972 -0
  29. data/doc/Kawaii/Tweening.html +120 -0
  30. data/doc/Kawaii/UnsupportedFormatError.html +123 -0
  31. data/doc/Kawaii/Vector2.html +514 -0
  32. data/doc/Kawaii.html +136 -0
  33. data/doc/_index.html +327 -0
  34. data/doc/class_list.html +53 -0
  35. data/doc/css/common.css +1 -0
  36. data/doc/css/full_list.css +57 -0
  37. data/doc/css/style.css +328 -0
  38. data/doc/file.README.html +130 -0
  39. data/doc/file_list.html +55 -0
  40. data/doc/frames.html +28 -0
  41. data/doc/index.html +130 -0
  42. data/doc/js/app.js +214 -0
  43. data/doc/js/full_list.js +173 -0
  44. data/doc/js/jquery.js +4 -0
  45. data/doc/method_list.html +708 -0
  46. data/doc/top-level-namespace.html +112 -0
  47. data/kawaii.gemspec +27 -0
  48. data/lib/kawaii/animation.rb +4 -0
  49. data/lib/kawaii/audio_manager.rb +7 -0
  50. data/lib/kawaii/command.rb +96 -0
  51. data/lib/kawaii/constants.rb +5 -0
  52. data/lib/kawaii/content_manager.rb +34 -0
  53. data/lib/kawaii/entity.rb +25 -0
  54. data/lib/kawaii/errors.rb +6 -0
  55. data/lib/kawaii/game.rb +89 -0
  56. data/lib/kawaii/helpers.rb +22 -0
  57. data/lib/kawaii/input_manager.rb +51 -0
  58. data/lib/kawaii/intro.rb +4 -0
  59. data/lib/kawaii/math.rb +5 -0
  60. data/lib/kawaii/node.rb +62 -0
  61. data/lib/kawaii/node_manager.rb +35 -0
  62. data/lib/kawaii/physics_entity.rb +32 -0
  63. data/lib/kawaii/physics_manager.rb +27 -0
  64. data/lib/kawaii/scene.rb +21 -0
  65. data/lib/kawaii/scene_manager.rb +50 -0
  66. data/lib/kawaii/text_field.rb +22 -0
  67. data/lib/kawaii/tmx_layer.rb +44 -0
  68. data/lib/kawaii/tmx_tile_map.rb +70 -0
  69. data/lib/kawaii/tweening.rb +4 -0
  70. data/lib/kawaii/vector2.rb +26 -0
  71. data/lib/kawaii/version.rb +3 -0
  72. data/lib/kawaii.rb +22 -0
  73. data/samples/.DS_Store +0 -0
  74. data/samples/content/gfx/ball.png +0 -0
  75. data/samples/content/maps/test_map.json +39 -0
  76. data/samples/content/maps/test_map.xml +12 -0
  77. data/samples/sample.rb +25 -0
  78. data/samples/sample_1/.DS_Store +0 -0
  79. data/samples/sample_1/content/gfx/ball.png +0 -0
  80. data/samples/sample_1/content/gfx/map1.png +0 -0
  81. data/samples/sample_1/content/maps/map1.json +50 -0
  82. data/samples/sample_1/content/maps/map1.tmx +16 -0
  83. data/samples/sample_1/content/maps/test_map.json +39 -0
  84. data/samples/sample_1/content/maps/test_map.xml +12 -0
  85. data/samples/sample_1/enemy.rb +11 -0
  86. data/samples/sample_1/sample_game.rb +51 -0
  87. data/samples/sample_chipmunk/sample.rb +0 -0
  88. data/spec/kawaii/audio_manager_spec.rb +9 -0
  89. data/spec/kawaii/content/gfx/ball.png +0 -0
  90. data/spec/kawaii/content/maps/test_map.json +39 -0
  91. data/spec/kawaii/content/maps/test_map.xml +12 -0
  92. data/spec/kawaii/content_manager_spec.rb +33 -0
  93. data/spec/kawaii/entity_spec.rb +38 -0
  94. data/spec/kawaii/game_spec.rb +23 -0
  95. data/spec/kawaii/helpers_spec.rb +31 -0
  96. data/spec/kawaii/input_manager_spec.rb +29 -0
  97. data/spec/kawaii/node_manager_spec.rb +36 -0
  98. data/spec/kawaii/node_spec.rb +81 -0
  99. data/spec/kawaii/physics_entity_spec.rb +37 -0
  100. data/spec/kawaii/physics_manager_spec.rb +45 -0
  101. data/spec/kawaii/scene_manager_spec.rb +34 -0
  102. data/spec/kawaii/scene_spec.rb +31 -0
  103. data/spec/kawaii/text_field_spec.rb +17 -0
  104. data/spec/kawaii/tmx_layer_spec.rb +21 -0
  105. data/spec/kawaii/tmx_tile_map_spec.rb +38 -0
  106. data/spec/kawaii/vector2_spec.rb +34 -0
  107. data/spec/spec_helper.rb +1 -0
  108. metadata +205 -0
@@ -0,0 +1,50 @@
1
+ module Kawaii
2
+ class SceneManager
3
+ attr_accessor :scene
4
+
5
+ def initialize scene = nil
6
+ @scene = scene
7
+ @old_scene = nil
8
+ @current_transition = 0.0
9
+ @state = :none
10
+ @state = :transition if @scene != nil
11
+ end
12
+
13
+ def push_scene scene
14
+ @old_scene = @scene
15
+ @scene = scene
16
+ end
17
+
18
+ def update dt
19
+ case @state
20
+ when :none
21
+ when :transition
22
+ if @scene != nil
23
+ @scene.transition_in @current_transition, SCENE_TRANSITION_DURATION
24
+ end
25
+ if @old_scene != nil
26
+ @old_scene.transition_out @current_transition, SCENE_TRANSITION_DURATION
27
+ end
28
+
29
+ @current_transition += dt
30
+ if @current_transition > SCENE_TRANSITION_DURATION
31
+ @state = :transition_done
32
+ end
33
+ when :transition_done
34
+ @current_transition = 0.0
35
+ @old_scene = nil
36
+ @state = :none
37
+ else
38
+ end
39
+ end
40
+
41
+ def draw
42
+ if @old_scene != nil
43
+ @old_scene.draw
44
+ end
45
+ if @scene != nil
46
+ @scene.draw
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,22 @@
1
+ require 'gosu'
2
+
3
+ module Kawaii
4
+ class TextField
5
+ attr_accessor :font, :text, :position
6
+
7
+ def initialize font = nil, position = Kawaii::Vector2.new, text = ""
8
+ # TODO: complete
9
+ @font, @position, @text = font, position, text
10
+ end
11
+
12
+ def set_text text
13
+ @text = text
14
+ # TODO: complete
15
+ end
16
+
17
+ def draw
18
+ # TODO: complete
19
+ @font.draw(@position.x, @position.y, 0)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,44 @@
1
+ module Kawaii
2
+ class TmxLayer
3
+
4
+ attr_accessor :data, :name, :opacity, :width, :height, :x, :y, :textures
5
+
6
+ def initialize hash
7
+ @data = []
8
+ hash['data'].each{|cell| @data.push cell}
9
+ @name = hash['name']
10
+ @opacity = hash['opacity']
11
+ @width = hash['width']
12
+ @height = hash['height']
13
+ @x = hash['x']
14
+ @y = hash['y']
15
+ @textures = nil
16
+ end
17
+
18
+ def get_cell col, row
19
+ #puts "Getting cell w col:#{col} and row: #{row} and it has the value #{@data[col + row * @width]}"
20
+ #puts @data
21
+ @data[col + row * @width]
22
+ end
23
+
24
+ def to_s
25
+ puts "Name: #{name}"
26
+ puts "Opacity: #{opacity}"
27
+ puts "Width: #{width}"
28
+ puts "Height: #{height}"
29
+ puts "X: #{x}"
30
+ puts "Y: #{y}"
31
+ end
32
+
33
+ def draw
34
+ @width.times do |i|
35
+ @height.times do |j|
36
+ cell = get_cell(i, j)
37
+ if(cell != 0)
38
+ @textures[cell-1].draw(i * 32, j * 32, 0)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,70 @@
1
+ require 'json'
2
+
3
+ module Kawaii
4
+ class TmxTileMap
5
+
6
+ attr_accessor :layers, :width, :height, :tile_width, :tile_height, :properties, :orientation, :texture
7
+
8
+ def initialize
9
+ @layers = []
10
+ @properties = {}
11
+ end
12
+
13
+ def draw
14
+ @layers.each do |layer|
15
+ layer.draw
16
+ end
17
+ end
18
+
19
+ def load path, content_manager
20
+ if path.end_with? ".json"
21
+ load_json path
22
+ @layers.each do |layer|
23
+ layer.textures = content_manager.load_tiled_images("gfx/map1.png", 32)
24
+ end
25
+ else
26
+ raise UnsupportedFormatError, "only json is supported"
27
+ end
28
+ end
29
+
30
+ def to_s
31
+ puts "Width: #{@width}"
32
+ puts "Height: #{@height}"
33
+ puts "Orientation: #{@orientation}"
34
+ puts "Tile width: #{@tile_width}"
35
+ puts "Tile height: #{@tile_height}"
36
+ puts ""
37
+ puts "Properties"
38
+ properties.each do |k, v|
39
+ puts "Key: #{k}, Value: #{v}"
40
+ end
41
+
42
+ puts ""
43
+ puts "Layers: "
44
+ @layers.each do |l|
45
+ puts l.to_s
46
+ end
47
+ end
48
+
49
+ private
50
+ def load_json path
51
+ File.open(path) do |f|
52
+ populate JSON.parse(f.read)
53
+ end
54
+ end
55
+
56
+ def populate hash
57
+ @width = hash['width']
58
+ @height = hash['height']
59
+ @tile_width = hash['tilewidth']
60
+ @tile_height = hash['tileheight']
61
+ @orientation = hash['orientation']
62
+ hash['layers'].each do |layer|
63
+ @layers.push TmxLayer.new layer
64
+ end
65
+ hash['properties'].each do |property|
66
+ @properties[property['key']] = property['value']
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,4 @@
1
+ module Kawaii
2
+ class Tweening
3
+ end
4
+ end
@@ -0,0 +1,26 @@
1
+ module Kawaii
2
+ class Vector2
3
+
4
+ attr_accessor :x, :y
5
+
6
+ def initialize x = 0, y = 0
7
+ @x, @y = x, y
8
+ end
9
+
10
+ def normalize
11
+ length = Math::sqrt((@x * @x) + (@y * @y))
12
+ if (length != 0)
13
+ @x = @x / length
14
+ @y = @y / length
15
+ end
16
+ end
17
+
18
+ def length
19
+ Math::sqrt((@x * @x) + (@y * @y))
20
+ end
21
+
22
+ def direction
23
+ Math::atan2(y, x)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Kawaii
2
+ VERSION = "0.1.0"
3
+ end
data/lib/kawaii.rb ADDED
@@ -0,0 +1,22 @@
1
+ require_relative 'kawaii/version'
2
+ require_relative 'kawaii/content_manager'
3
+ require_relative 'kawaii/entity'
4
+ require_relative 'kawaii/game'
5
+ require_relative 'kawaii/node'
6
+ require_relative 'kawaii/node_manager'
7
+ require_relative 'kawaii/vector2'
8
+ require_relative 'kawaii/text_field'
9
+ require_relative 'kawaii/audio_manager'
10
+ require_relative 'kawaii/input_manager'
11
+ require_relative 'kawaii/tmx_tile_map'
12
+ require_relative 'kawaii/tmx_layer'
13
+ require_relative 'kawaii/errors'
14
+ require_relative 'kawaii/physics_entity'
15
+ require_relative 'kawaii/physics_manager'
16
+ require_relative 'kawaii/constants'
17
+ require_relative 'kawaii/scene_manager'
18
+ require_relative 'kawaii/scene'
19
+ require_relative 'kawaii/helpers'
20
+
21
+ module Kawaii
22
+ end
data/samples/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,39 @@
1
+ { "height":32,
2
+ "layers":[
3
+ {
4
+ "data":[20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 0, 21, 20, 21, 20, 0, 0, 8, 0, 0, 0, 8, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 63, 0, 0, 20, 20, 20, 49, 50, 20, 20, 20, 20, 49, 58, 58, 58, 58, 58, 58, 58, 50, 20, 21, 20, 20, 20, 20, 20, 20, 21, 20, 21, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20],
5
+ "height":32,
6
+ "name":"Tile Layer 1",
7
+ "opacity":1,
8
+ "type":"tilelayer",
9
+ "visible":true,
10
+ "width":32,
11
+ "x":0,
12
+ "y":0
13
+ }],
14
+ "orientation":"orthogonal",
15
+ "properties":
16
+ {
17
+
18
+ },
19
+ "tileheight":16,
20
+ "tilesets":[
21
+ {
22
+ "firstgid":1,
23
+ "image":"..\/texture.png",
24
+ "imageheight":128,
25
+ "imagewidth":128,
26
+ "margin":0,
27
+ "name":"texture",
28
+ "properties":
29
+ {
30
+
31
+ },
32
+ "spacing":0,
33
+ "tileheight":16,
34
+ "tilewidth":16
35
+ }],
36
+ "tilewidth":16,
37
+ "version":1,
38
+ "width":32
39
+ }
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
3
+ <map version="1.0" orientation="orthogonal" width="100" height="80" tilewidth="32" tileheight="32">
4
+ <layer name="Ground" width="100" height="80">
5
+ <data encoding="base64" compression="gzip">
6
+ H4sIAAAAAAAAA+3BMQEAAADCoPVP7WENoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABucSjRWwB9AAA=
7
+ </data>
8
+ </layer>
9
+ <objectgroup name="Objects" width="0" height="0">
10
+ <object name="Some object" type="WARP" x="200" y="200" width="128" height="64"/>
11
+ </objectgroup>
12
+ </map>
data/samples/sample.rb ADDED
@@ -0,0 +1,25 @@
1
+ # hello world sample
2
+
3
+ require '../lib/kawaii'
4
+
5
+ class Game < Kawaii::Game
6
+
7
+ WIDTH = 800
8
+ HEIGHT = 600
9
+ FULLSCREEN = false
10
+ CONTENT_ROOT = "content"
11
+
12
+ def initialize
13
+ super WIDTH, HEIGHT, FULLSCREEN, CONTENT_ROOT
14
+ end
15
+
16
+ def update_game dt
17
+ if button_down?Gosu::KbEscape
18
+ exit
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ game = Game.new
25
+ game.show
Binary file
@@ -0,0 +1,50 @@
1
+ { "height":16,
2
+ "layers":[
3
+ {
4
+ "data":[73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73],
5
+ "height":16,
6
+ "name":"bg",
7
+ "opacity":1,
8
+ "type":"tilelayer",
9
+ "visible":true,
10
+ "width":16,
11
+ "x":0,
12
+ "y":0
13
+ },
14
+ {
15
+ "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 62, 74, 74, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 74, 74, 74, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 74, 74, 74, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 74, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 62, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 62, 0, 0, 0, 124, 124, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 74, 0, 0, 0, 137, 137, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 124, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 0, 0, 0, 138, 136, 136, 138, 0, 0, 0, 0, 0, 0, 0, 0, 110, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
16
+ "height":16,
17
+ "name":"Tile Layer 1",
18
+ "opacity":1,
19
+ "type":"tilelayer",
20
+ "visible":true,
21
+ "width":16,
22
+ "x":0,
23
+ "y":0
24
+ }],
25
+ "orientation":"orthogonal",
26
+ "properties":
27
+ {
28
+
29
+ },
30
+ "tileheight":32,
31
+ "tilesets":[
32
+ {
33
+ "firstgid":1,
34
+ "image":"..\/gfx\/map1.png",
35
+ "imageheight":384,
36
+ "imagewidth":384,
37
+ "margin":0,
38
+ "name":"map1",
39
+ "properties":
40
+ {
41
+
42
+ },
43
+ "spacing":0,
44
+ "tileheight":32,
45
+ "tilewidth":32
46
+ }],
47
+ "tilewidth":32,
48
+ "version":1,
49
+ "width":16
50
+ }
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <map version="1.0" orientation="orthogonal" width="16" height="16" tilewidth="32" tileheight="32">
3
+ <tileset firstgid="1" name="map1" tilewidth="32" tileheight="32">
4
+ <image source="../gfx/map1.png" width="384" height="384"/>
5
+ </tileset>
6
+ <layer name="bg" width="16" height="16">
7
+ <data encoding="base64" compression="zlib">
8
+ eJzzZGBg8BzFo3gUj0gMAJ6OSQE=
9
+ </data>
10
+ </layer>
11
+ <layer name="Tile Layer 1" width="16" height="16">
12
+ <data encoding="base64" compression="zlib">
13
+ eJxjYBgagAkHJkW/FxDbQWkYJlU/MrajUD+p9iNjUvWjmwULB3L1U2o/NfSjh38NFJNrfycUE6MfW/oj1n4QSELjdwFxBxR3EaE/D4tbyMEA8q8N3w==
14
+ </data>
15
+ </layer>
16
+ </map>
@@ -0,0 +1,39 @@
1
+ { "height":32,
2
+ "layers":[
3
+ {
4
+ "data":[20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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17, 17, 17, 17, 17, 0, 0, 63, 0, 0, 20, 20, 20, 49, 50, 20, 20, 20, 20, 49, 58, 58, 58, 58, 58, 58, 58, 50, 20, 21, 20, 20, 20, 20, 20, 20, 21, 20, 21, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20],
5
+ "height":32,
6
+ "name":"Tile Layer 1",
7
+ "opacity":1,
8
+ "type":"tilelayer",
9
+ "visible":true,
10
+ "width":32,
11
+ "x":0,
12
+ "y":0
13
+ }],
14
+ "orientation":"orthogonal",
15
+ "properties":
16
+ {
17
+
18
+ },
19
+ "tileheight":16,
20
+ "tilesets":[
21
+ {
22
+ "firstgid":1,
23
+ "image":"..\/texture.png",
24
+ "imageheight":128,
25
+ "imagewidth":128,
26
+ "margin":0,
27
+ "name":"texture",
28
+ "properties":
29
+ {
30
+
31
+ },
32
+ "spacing":0,
33
+ "tileheight":16,
34
+ "tilewidth":16
35
+ }],
36
+ "tilewidth":16,
37
+ "version":1,
38
+ "width":32
39
+ }
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
3
+ <map version="1.0" orientation="orthogonal" width="100" height="80" tilewidth="32" tileheight="32">
4
+ <layer name="Ground" width="100" height="80">
5
+ <data encoding="base64" compression="gzip">
6
+ H4sIAAAAAAAAA+3BMQEAAADCoPVP7WENoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABucSjRWwB9AAA=
7
+ </data>
8
+ </layer>
9
+ <objectgroup name="Objects" width="0" height="0">
10
+ <object name="Some object" type="WARP" x="200" y="200" width="128" height="64"/>
11
+ </objectgroup>
12
+ </map>
@@ -0,0 +1,11 @@
1
+ require '../../lib/kawaii'
2
+
3
+ class Enemy < Kawaii::Entity
4
+
5
+ def before_update dt
6
+ if @position.y > 600
7
+ @position.y = 600
8
+ @velocity.y *= -1
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,51 @@
1
+ require '../../lib/kawaii'
2
+ require_relative 'enemy'
3
+
4
+ class Game < Kawaii::Game
5
+
6
+ WIDTH = 800
7
+ HEIGHT = 600
8
+ FULLSCREEN = false
9
+ CONTENT_ROOT = "content"
10
+
11
+ def initialize
12
+ super WIDTH, HEIGHT, FULLSCREEN, CONTENT_ROOT
13
+ self.caption = "My sample game"
14
+ self.show_fps = true
15
+ load_game
16
+ end
17
+
18
+ def load_game
19
+ @tile_map = Kawaii::TmxTileMap.new
20
+ @tile_map.load "content/maps/map1.json", @content_manager
21
+
22
+ enemies = Kawaii::Node.new(true)
23
+ enemy_count = 20
24
+ enemy_count.times do |i|
25
+ enemy = Enemy.new @content_manager.load_image "gfx/ball.png"
26
+ enemy.position.x = Kawaii::lerp(0, WIDTH, i / enemy_count.to_f) + 32
27
+ enemy.gravity.y = 0
28
+ enemies.add_child enemy
29
+ end
30
+ add_child enemies
31
+ add_child Kawaii::Entity.new @content_manager.load_image "gfx/ball.png" # player
32
+ print_stats
33
+ end
34
+
35
+ def input
36
+ if button_down? Gosu::KbEscape
37
+ exit
38
+ end
39
+ end
40
+
41
+ def before_update
42
+ input
43
+ end
44
+
45
+ def before_draw
46
+ @tile_map.draw
47
+ end
48
+ end
49
+
50
+ game = Game.new
51
+ game.show
File without changes
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe AudioManager do
5
+ before(:each) do
6
+ @audio_manager = AudioManager.new
7
+ end
8
+ end
9
+ end
Binary file
@@ -0,0 +1,39 @@
1
+ { "height":32,
2
+ "layers":[
3
+ {
4
+ "data":[20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 0, 21, 20, 21, 20, 0, 0, 8, 0, 0, 0, 8, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 63, 0, 0, 20, 20, 20, 49, 50, 20, 20, 20, 20, 49, 58, 58, 58, 58, 58, 58, 58, 50, 20, 21, 20, 20, 20, 20, 20, 20, 21, 20, 21, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20],
5
+ "height":32,
6
+ "name":"Tile Layer 1",
7
+ "opacity":1,
8
+ "type":"tilelayer",
9
+ "visible":true,
10
+ "width":32,
11
+ "x":0,
12
+ "y":0
13
+ }],
14
+ "orientation":"orthogonal",
15
+ "properties":
16
+ {
17
+
18
+ },
19
+ "tileheight":16,
20
+ "tilesets":[
21
+ {
22
+ "firstgid":1,
23
+ "image":"..\/texture.png",
24
+ "imageheight":128,
25
+ "imagewidth":128,
26
+ "margin":0,
27
+ "name":"texture",
28
+ "properties":
29
+ {
30
+
31
+ },
32
+ "spacing":0,
33
+ "tileheight":16,
34
+ "tilewidth":16
35
+ }],
36
+ "tilewidth":16,
37
+ "version":1,
38
+ "width":32
39
+ }
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
3
+ <map version="1.0" orientation="orthogonal" width="100" height="80" tilewidth="32" tileheight="32">
4
+ <layer name="Ground" width="100" height="80">
5
+ <data encoding="base64" compression="gzip">
6
+ H4sIAAAAAAAAA+3BMQEAAADCoPVP7WENoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABucSjRWwB9AAA=
7
+ </data>
8
+ </layer>
9
+ <objectgroup name="Objects" width="0" height="0">
10
+ <object name="Some object" type="WARP" x="200" y="200" width="128" height="64"/>
11
+ </objectgroup>
12
+ </map>
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe ContentManager do
5
+ before(:each) do
6
+ @img_name = "gfx/ball.png"
7
+ @root = "/Users/ILab/Documents/ruby/kawaii/spec/kawaii/content"
8
+ window = Gosu::Window.new(800, 600, false)
9
+ @content = ContentManager.new(window, @root)
10
+ end
11
+
12
+ it "should set root directory" do
13
+ @content.root.should == @root
14
+ end
15
+
16
+ it "should load an image" do
17
+ image = @content.load_image @img_name
18
+ image.should_not be_nil
19
+ end
20
+
21
+ it "should cache images loaded multiple times" do
22
+ image = @content.load_image @img_name
23
+ image_copy = @content.load_image @img_name
24
+ image.should == image_copy
25
+ end
26
+
27
+ it "should be able to clear cached images" do
28
+ image = @content.load_image @img_name
29
+ @content.clear
30
+ @content.images.size.should == 0
31
+ end
32
+ end
33
+ end