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.
- data/.DS_Store +0 -0
- data/.gitignore +2 -0
- data/.yardoc/checksums +19 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +28 -0
- data/LICENSE +22 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/backlog.md +26 -0
- data/bin/kawaii +13 -0
- data/doc/Kawaii/Animation.html +120 -0
- data/doc/Kawaii/AudioManager.html +202 -0
- data/doc/Kawaii/ContentManager.html +487 -0
- data/doc/Kawaii/Entity.html +604 -0
- data/doc/Kawaii/Game.html +1141 -0
- data/doc/Kawaii/InputManager.html +120 -0
- data/doc/Kawaii/Intro.html +120 -0
- data/doc/Kawaii/Math.html +105 -0
- data/doc/Kawaii/Node.html +1030 -0
- data/doc/Kawaii/NodeManager.html +512 -0
- data/doc/Kawaii/Scene.html +120 -0
- data/doc/Kawaii/SceneManager.html +200 -0
- data/doc/Kawaii/TextField.html +538 -0
- data/doc/Kawaii/TmxLayer.html +836 -0
- data/doc/Kawaii/TmxTileMap.html +972 -0
- data/doc/Kawaii/Tweening.html +120 -0
- data/doc/Kawaii/UnsupportedFormatError.html +123 -0
- data/doc/Kawaii/Vector2.html +514 -0
- data/doc/Kawaii.html +136 -0
- data/doc/_index.html +327 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +130 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +130 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +708 -0
- data/doc/top-level-namespace.html +112 -0
- data/kawaii.gemspec +27 -0
- data/lib/kawaii/animation.rb +4 -0
- data/lib/kawaii/audio_manager.rb +7 -0
- data/lib/kawaii/command.rb +96 -0
- data/lib/kawaii/constants.rb +5 -0
- data/lib/kawaii/content_manager.rb +34 -0
- data/lib/kawaii/entity.rb +25 -0
- data/lib/kawaii/errors.rb +6 -0
- data/lib/kawaii/game.rb +89 -0
- data/lib/kawaii/helpers.rb +22 -0
- data/lib/kawaii/input_manager.rb +51 -0
- data/lib/kawaii/intro.rb +4 -0
- data/lib/kawaii/math.rb +5 -0
- data/lib/kawaii/node.rb +62 -0
- data/lib/kawaii/node_manager.rb +35 -0
- data/lib/kawaii/physics_entity.rb +32 -0
- data/lib/kawaii/physics_manager.rb +27 -0
- data/lib/kawaii/scene.rb +21 -0
- data/lib/kawaii/scene_manager.rb +50 -0
- data/lib/kawaii/text_field.rb +22 -0
- data/lib/kawaii/tmx_layer.rb +44 -0
- data/lib/kawaii/tmx_tile_map.rb +70 -0
- data/lib/kawaii/tweening.rb +4 -0
- data/lib/kawaii/vector2.rb +26 -0
- data/lib/kawaii/version.rb +3 -0
- data/lib/kawaii.rb +22 -0
- data/samples/.DS_Store +0 -0
- data/samples/content/gfx/ball.png +0 -0
- data/samples/content/maps/test_map.json +39 -0
- data/samples/content/maps/test_map.xml +12 -0
- data/samples/sample.rb +25 -0
- data/samples/sample_1/.DS_Store +0 -0
- data/samples/sample_1/content/gfx/ball.png +0 -0
- data/samples/sample_1/content/gfx/map1.png +0 -0
- data/samples/sample_1/content/maps/map1.json +50 -0
- data/samples/sample_1/content/maps/map1.tmx +16 -0
- data/samples/sample_1/content/maps/test_map.json +39 -0
- data/samples/sample_1/content/maps/test_map.xml +12 -0
- data/samples/sample_1/enemy.rb +11 -0
- data/samples/sample_1/sample_game.rb +51 -0
- data/samples/sample_chipmunk/sample.rb +0 -0
- data/spec/kawaii/audio_manager_spec.rb +9 -0
- data/spec/kawaii/content/gfx/ball.png +0 -0
- data/spec/kawaii/content/maps/test_map.json +39 -0
- data/spec/kawaii/content/maps/test_map.xml +12 -0
- data/spec/kawaii/content_manager_spec.rb +33 -0
- data/spec/kawaii/entity_spec.rb +38 -0
- data/spec/kawaii/game_spec.rb +23 -0
- data/spec/kawaii/helpers_spec.rb +31 -0
- data/spec/kawaii/input_manager_spec.rb +29 -0
- data/spec/kawaii/node_manager_spec.rb +36 -0
- data/spec/kawaii/node_spec.rb +81 -0
- data/spec/kawaii/physics_entity_spec.rb +37 -0
- data/spec/kawaii/physics_manager_spec.rb +45 -0
- data/spec/kawaii/scene_manager_spec.rb +34 -0
- data/spec/kawaii/scene_spec.rb +31 -0
- data/spec/kawaii/text_field_spec.rb +17 -0
- data/spec/kawaii/tmx_layer_spec.rb +21 -0
- data/spec/kawaii/tmx_tile_map_spec.rb +38 -0
- data/spec/kawaii/vector2_spec.rb +34 -0
- data/spec/spec_helper.rb +1 -0
- 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
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'kawaii'
|