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,38 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe Entity do
5
+ before(:each) do
6
+ @entity = Entity.new nil
7
+ end
8
+
9
+ it "should not be flipped horizontally default" do
10
+ @entity.flipped_h.should be_false
11
+ end
12
+
13
+ it "should not be flipped vertically default" do
14
+ @entity.flipped_v.should be_false
15
+ end
16
+
17
+ it "should have an accessable texture" do
18
+ @entity.should respond_to :texture
19
+ end
20
+
21
+ describe "#before_update" do
22
+ it "should respond to before_update" do
23
+ @entity.should respond_to :before_update
24
+ end
25
+ end
26
+ describe "#after_update" do
27
+ it "should respond to after_update" do
28
+ @entity.should respond_to :after_update
29
+ end
30
+ end
31
+
32
+ describe "#draw" do
33
+ it "should respond to draw" do
34
+ @entity.should respond_to :draw
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe Game do
5
+ before(:each) do
6
+ @game = Game.new 800, 600, false, "content", debug = false
7
+ end
8
+
9
+ it "should be able to add children" do
10
+ @game.should respond_to :add_child
11
+ end
12
+
13
+ it "should be able to remove children" do
14
+ @game.should respond_to :remove_child
15
+ end
16
+
17
+ describe "properties" do
18
+ it "should contain a physics manager" do
19
+ @game.should respond_to :physics_manager
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe "helpers" do
5
+ it "should be able to perform linear interpolation" do
6
+ Kawaii::lerp(0, 100, 0.5).should eq(50)
7
+ end
8
+
9
+ it "should be able to perform a cousine interpolation" do
10
+ Kawaii::clerp(0, 100, 0.6).should eq(65.45084971874738)
11
+ end
12
+
13
+ it "should be able to perform smooth step interpolation" do
14
+ line = {}
15
+ 0..500.times do |i|
16
+ y0 = 0
17
+ y1 = 500
18
+ y2 = 0
19
+ y3 = 500
20
+ key = Kawaii::lerp(0, 50, Kawaii::smooth_step(y0, y1, y2, y3, i / 500.0) / 500.0).to_i
21
+ if !line[key]
22
+ line[key] = ""
23
+ end
24
+ line[key] += "-"
25
+ end
26
+ line.each do |k, v|
27
+ # puts v
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'gosu'
3
+
4
+ module Kawaii
5
+ describe InputManager do
6
+ before(:each) do
7
+ @input_manager = InputManager.new(Game.new, [Gosu::KbLeft, Gosu::KbRight])
8
+ end
9
+
10
+ describe "properties" do
11
+ it "must have an instance of the game" do
12
+ @input_manager.game.should_not be(nil)
13
+ end
14
+ it "should be able to update states" do
15
+ @input_manager.should respond_to :update
16
+ end
17
+ end
18
+
19
+ describe "input states" do
20
+ it "should be able to check if a button is pressed" do
21
+ @input_manager.button_down?(Gosu::KbLeft).should_not be_true
22
+ end
23
+
24
+ it "should be able to check if a button is clicked" do
25
+ @input_manager.button_clicked?(Gosu::KbLeft).should_not be_true
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe NodeManager do
5
+ before(:each) do
6
+ @node_manager = NodeManager.new
7
+ end
8
+
9
+ it "should have a list of nodes" do
10
+ @node_manager.should respond_to :nodes
11
+ @node_manager.nodes.should == []
12
+ end
13
+
14
+ describe "#clear" do
15
+ it "should be able to remove all nodes" do
16
+ @node_manager.nodes.push Node.new
17
+ @node_manager.nodes.size.should_not == 0
18
+
19
+ @node_manager.clear
20
+ @node_manager.nodes.size.should == 0
21
+ end
22
+ end
23
+
24
+ describe "#update" do
25
+ it "should be able to update itself" do
26
+ @node_manager.should respond_to :update
27
+ end
28
+ end
29
+
30
+ describe "#draw" do
31
+ it "should be able to draw itseld" do
32
+ @node_manager.should respond_to :draw
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe Node do
5
+
6
+ before(:each) do
7
+ @node = Node.new
8
+ end
9
+
10
+ it "should have a position vector" do
11
+ @node.should respond_to :position
12
+ end
13
+
14
+ it "should have a velocity vector" do
15
+ @node.should respond_to :velocity
16
+ end
17
+
18
+ it "should have a gravitational vector" do
19
+ @node.should respond_to :gravity
20
+ end
21
+
22
+ it "should have a rotation" do
23
+ @node.should respond_to :rotation
24
+ end
25
+
26
+ it "should default to not static" do
27
+ @node.static.should_not be_true
28
+ end
29
+
30
+
31
+ describe "should have its children accessible" do
32
+ it "should respond to children" do
33
+ @node.should respond_to :children
34
+ end
35
+ end
36
+
37
+ describe "#add_child" do
38
+ it "should be able to add children" do
39
+ @node.add_child Node.new
40
+ @node.children.size.should == 1
41
+ end
42
+ end
43
+
44
+ describe "#remove_child" do
45
+ it "should be able to remove children" do
46
+ @node.add_child Node.new
47
+ @node.remove_child(@node.children.first)
48
+ @node.children.size.should == 0
49
+ end
50
+ end
51
+
52
+ describe "#has_children" do
53
+ it "should be able to tell if it has any children" do
54
+ @node.has_children?.should be_false
55
+ @node.add_child Node.new
56
+ @node.has_children?.should be_true
57
+ end
58
+ end
59
+
60
+ describe "#update" do
61
+ it "should respond to update" do
62
+ @node.should respond_to :update
63
+ end
64
+ end
65
+
66
+ describe "#draw" do
67
+ it "should respond to draw" do
68
+ @node.should respond_to :draw
69
+ end
70
+ end
71
+
72
+ describe "#count" do
73
+ it "should be able to count itself and its children" do
74
+ (0..15).each do
75
+ @node.add_child Node.new
76
+ end
77
+ @node.count.should == @node.children.size + 1
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe PhysicsEntity do
5
+ before(:each) do
6
+ @circle = PhysicsEntity.new :circle, {:radius => 16}
7
+ @rectangle = PhysicsEntity.new :rectangle, { :width => 32, :height => 64}
8
+ @physix = PhysicsManager.new
9
+ end
10
+
11
+ describe "properties" do
12
+ it "should have a body" do
13
+ @circle.should respond_to :body
14
+ end
15
+ it "should have a shape" do
16
+ @circle.should respond_to :shape
17
+ end
18
+ it "should have a geom" do
19
+ @circle.should respond_to :geom
20
+ end
21
+ it "should be either a circle or a rectangle" do
22
+ @circle.geom.should be(:circle)
23
+ @rectangle.geom.should be(:rectangle)
24
+ end
25
+ end
26
+
27
+ describe "physics integration" do
28
+ it "should be able to add itself to a cp physics space" do
29
+ @circle.add_to_space @physix.space
30
+ end
31
+
32
+ it "should be able to remove itself from the cp physics space" do
33
+ @circle.remove_from_space @physix.space
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe PhysicsManager do
5
+ before(:each) do
6
+ @phys_man = PhysicsManager.new
7
+ end
8
+
9
+ describe "properties" do
10
+ it "should have an object space" do
11
+ @phys_man.should respond_to :space
12
+ end
13
+ end
14
+
15
+ describe "entities" do
16
+ it "should contain a list of entities" do
17
+ @phys_man.should respond_to :entities
18
+ end
19
+
20
+ describe "#add_physics_entity" do
21
+ it "should be able to add entities" do
22
+ @phys_man.should respond_to :add_physics_entity
23
+ end
24
+ it "should raise error about non-physics entities" do
25
+ lambda{
26
+ @phys_man.add_physics_entity(Entity.new(nil))
27
+ }.should raise_error(WrongTypeError)
28
+ end
29
+ it "should add physics entities" do
30
+ @phys_man.add_physics_entity(PhysicsEntity.new :circle, {:radius => 16})
31
+ @phys_man.entities.size.should be(1)
32
+ end
33
+ end
34
+
35
+ describe "#remove_physics_entity" do
36
+ it "should remove physics entities" do
37
+ entity = PhysicsEntity.new :circle, {:radius => 16}
38
+ @phys_man.add_physics_entity(entity)
39
+ @phys_man.remove_physics_entity(entity)
40
+ @phys_man.entities.size.should be(0)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe SceneManager do
5
+ before(:each) do
6
+ @scene_manager = SceneManager.new
7
+ end
8
+
9
+ describe "properties" do
10
+ it "should have one active scene or none" do
11
+ @scene_manager.should respond_to :scene
12
+ end
13
+ end
14
+
15
+ describe "#push_scene" do
16
+ it "should be able to push a new scene" do
17
+ scene1 = Scene.new @scene_manager
18
+ scene1.name = "Scene1"
19
+ @scene_manager.push_scene(scene1)
20
+ @scene_manager.scene.should_not be(nil)
21
+ end
22
+
23
+ it "should remove the old scene" do
24
+ scene1 = Scene.new @scene_manager
25
+ scene1.name = "Scene1"
26
+ @scene_manager.push_scene(scene1)
27
+ scene2 = Scene.new @scene_manager
28
+ scene2.name = "Scene2"
29
+ @scene_manager.push_scene(scene2)
30
+ @scene_manager.scene.name.should == "Scene2"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe Scene do
5
+ before(:each) do
6
+ @scene_manager = SceneManager.new
7
+ @scene = Scene.new @scene_manager
8
+ end
9
+
10
+ describe "properties" do
11
+ it "should have a name" do
12
+ @scene.should respond_to :name
13
+ end
14
+ it "must have a scene_manager" do
15
+ @scene.should respond_to :scene_manager
16
+ @scene.scene_manager.should_not be(nil)
17
+ end
18
+ end
19
+
20
+ describe "#update" do
21
+ it "should respond to update" do
22
+ @scene.should respond_to :update
23
+ end
24
+ end
25
+ describe "#draw" do
26
+ it "should respond to draw" do
27
+ @scene.should respond_to :draw
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe TextField do
5
+
6
+ before(:each) do
7
+ @text_field = TextField.new
8
+ end
9
+
10
+ describe "#set_text" do
11
+ it "should be able to change the text" do
12
+ @text_field.set_text "Hello World!"
13
+ @text_field.text.should == "Hello World!"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe TmxTileMap do
5
+ before(:each) do
6
+ @map = TmxTileMap.new
7
+ @map.load('/Users/ILab/Documents/ruby/kawaii/spec/kawaii/content/maps/test_map.json')
8
+ @layer = @map.layers.first
9
+ end
10
+
11
+ describe "#get_cell" do
12
+ it "should return the cell based on column and row" do
13
+ @layer.data = [0, 4, 6, 1]
14
+ @layer.width = 2
15
+ @layer.height = 2
16
+ @layer.get_cell(1, 0).should == 4
17
+ @layer.get_cell(0, 1).should == 6
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe TmxTileMap do
5
+ before(:each) do
6
+ @tile_map = TmxTileMap.new
7
+ end
8
+
9
+ it "should contain layers" do
10
+ @tile_map.should respond_to :layers
11
+ end
12
+ it "should contain a width" do
13
+ @tile_map.should respond_to :width
14
+ end
15
+ it "should contain a height" do
16
+ @tile_map.should respond_to :height
17
+ end
18
+ it "should contain a texture" do
19
+ @tile_map.should respond_to :texture
20
+ end
21
+ it "should contain properties" do
22
+ @tile_map.should respond_to :properties
23
+ end
24
+
25
+ describe "#load" do
26
+ it "should be able to load a tmx.json file" do
27
+ @tile_map.load('/Users/ILab/Documents/ruby/kawaii/spec/kawaii/content/maps/test_map.json')
28
+ @tile_map.width.should == 32
29
+ @tile_map.height.should == 32
30
+ @tile_map.layers.size.should be(1)
31
+ end
32
+
33
+ it "should only load json" do
34
+ lambda {@tile_map.load('test/file.yml')}.should raise_error(UnsupportedFormatError)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ module Kawaii
4
+ describe Vector2 do
5
+ before(:each) do
6
+ @vector = Vector2.new
7
+ end
8
+
9
+ it "should have an x axis" do
10
+ @vector.should respond_to :x
11
+ end
12
+
13
+ it "should have a y axis" do
14
+ @vector.should respond_to :y
15
+ end
16
+
17
+ describe "helpers" do
18
+ it "should be able to normalize itself" do
19
+ @vector.x = 14.6
20
+ @vector.y = -0.346
21
+ @vector.normalize
22
+ @vector.length.should eq(1.0)
23
+ end
24
+
25
+ it "should be able to calculate its own length" do
26
+ x = -0.531
27
+ y = 1242.412
28
+ @vector.x = x
29
+ @vector.y = y
30
+ @vector.length.should eq(Math::sqrt((x * x) + (y * y)))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1 @@
1
+ require 'kawaii'