shattered_pack 0.4 → 0.4.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,6 +100,11 @@ module ShatteredModel #:nodoc:
100
100
  @fuzzy_logic.update(self)
101
101
  end
102
102
 
103
+ #Delegates to View if view exists
104
+ def method_missing(method, *args, &block)
105
+ raise NoMethodError, "#{self.class} has no method defined '#{method}'" if self.view.nil?
106
+ self.view.send(method, *args, &block)
107
+ end
103
108
  end
104
109
  end
105
110
 
@@ -39,7 +39,7 @@ module ShatteredPack
39
39
  def pre_initialize(options)
40
40
  # update our keyboard input
41
41
  timer.every(:frame) do |time_elapsed|
42
- update_input(time_elapsed, ShatteredController::Runner.environment[:input])
42
+ update_input(time_elapsed, ShatteredState::Runner.environment[:input])
43
43
  end
44
44
  super
45
45
  end
@@ -9,4 +9,4 @@ require 'shattered_support'
9
9
  require 'shattered_ogre'
10
10
  require 'shattered_model'
11
11
  require 'shattered_view'
12
- require 'shattered_controller'
12
+ require 'shattered_state'
@@ -1,4 +1,4 @@
1
- module ShatteredController
1
+ module ShatteredState
2
2
  module Actor #:nodoc:
3
3
  def self.append_features(base)
4
4
  super
@@ -34,9 +34,9 @@ module ShatteredController
34
34
  #
35
35
  # Works fine.
36
36
  #
37
- # Actors delegate to ShatteredController::Base objects, and controllers delegate to Model and View.
37
+ # Actors delegate to ShatteredState::Base objects, and controllers delegate to Model and View.
38
38
  #
39
- # See ShatteredController::Base for more detail.
39
+ # See ShatteredState::Base for more detail.
40
40
  def actor( name, options = {} )
41
41
  before_init_call( :actor, name, options, true )
42
42
  end
@@ -46,7 +46,7 @@ module ShatteredController
46
46
 
47
47
  private
48
48
 
49
- # Same as ShatteredController::Actor::ClassMethods#actor
49
+ # Same as ShatteredState::Actor::ClassMethods#actor
50
50
  #
51
51
  # Returns a newly created actor
52
52
  def actor(name, options={}, created_by_meta_function=false )
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__)+'/actor/actor'
2
2
 
3
- module ShatteredController
3
+ module ShatteredState
4
4
  def self.append_features(base)
5
5
  super
6
6
  base.extend(ClassMethods)
@@ -8,7 +8,7 @@ module ShatteredController
8
8
  module ClassMethods
9
9
  # In order to set the initial position of the camera, and any other attributes you would like,
10
10
  # use the following format.
11
- # class CameraTestState < ShatteredController::Base
11
+ # class CameraTestState < ShatteredState::Base
12
12
  # camera :position => v(10,0,0), :orientation => [0.5, 0.5, 0.5, 0.5]
13
13
  # end
14
14
  #
@@ -16,7 +16,7 @@ module ShatteredController
16
16
  #
17
17
  # This allows for things such as:
18
18
  #
19
- # class CameraTestState < ShatteredController::Base
19
+ # class CameraTestState < ShatteredState::Base
20
20
  # camera :position => :camera_position
21
21
  # def camera_position
22
22
  # return [rand*10,0,0]
@@ -39,7 +39,7 @@ module ShatteredController
39
39
  #
40
40
  # States define the actors, communications between the actors, and control the camera.
41
41
  # You can choose your starting state in config/environment.rb
42
- class State < ShatteredPack::Base
42
+ class Base < ShatteredPack::Base
43
43
  before_init_call :activate_state
44
44
  attr_reader :actors
45
45
 
@@ -56,12 +56,21 @@ module ShatteredController
56
56
  timer.update(time_elapsed)
57
57
  end
58
58
 
59
- # Returns the camera used in the state. See ShatteredController::ClassMethods#camera
59
+ # Returns the camera used in the state. See ShatteredState::ClassMethods#camera
60
60
  def camera(*args)
61
61
  if args.length == 0
62
62
  return @camera ||= Runner.environment[:camera]
63
63
  end
64
- call_object_function_for_each_key(:camera, args[0])
64
+
65
+ options = args[0]
66
+
67
+ # Cameras are special, in that we have to have the position
68
+ # called before looking_at or the view matrix gets way messed up
69
+ call_object_function :camera, :position=, options.delete(:position) if options.has_key?(:position)
70
+ call_object_function :camera, :looking_at=, options.delete(:looking_at) if options.has_key?(:looking_at)
71
+
72
+ # Call the other methods
73
+ call_object_function_for_each_key(:camera, options)
65
74
  end
66
75
 
67
76
  def sky=(type, material) #:nodoc:
@@ -78,7 +87,7 @@ module ShatteredController
78
87
  end
79
88
 
80
89
 
81
- ShatteredController::State.class_eval do
82
- include ShatteredController::Actor
90
+ ShatteredState::Base.class_eval do
91
+ include ShatteredState::Actor
83
92
  end
84
93
 
@@ -1,5 +1,5 @@
1
1
 
2
- module ShatteredController
2
+ module ShatteredState
3
3
  #The class Runner is present in model, view, and controller, and signifies the
4
4
  #main entry point into the program. This is called by script/runner.rb
5
5
  class Runner #:nodoc:
@@ -0,0 +1,4 @@
1
+ %w(runner base).each do |dependency|
2
+ dependency = "shattered_state/#{dependency}"
3
+ require dependency
4
+ end
@@ -35,7 +35,7 @@ module ShatteredView
35
35
  before_init_call( :mesh, file, options )
36
36
  end
37
37
 
38
- # Note: The following is broken in 0.4
38
+ # Note: The following is broken in 0.4.0.1
39
39
  # Animations declare helper functions for mesh animations.
40
40
  #
41
41
  # class AnimatedRubyView < ...
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: shattered_pack
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.4"
7
- date: 2006-09-10 00:00:00 -06:00
6
+ version: 0.4.0.1
7
+ date: 2006-09-12 00:00:00 -06:00
8
8
  summary: "Shattered Pack: The combination of model/view/controllers and the domain specific language for each."
9
9
  require_paths:
10
10
  - lib
@@ -29,9 +29,9 @@ authors: []
29
29
 
30
30
  files:
31
31
  - lib/mock_objects.rb
32
- - lib/shattered_controller.rb
33
32
  - lib/shattered_model.rb
34
33
  - lib/shattered_pack.rb
34
+ - lib/shattered_state.rb
35
35
  - lib/shattered_view.rb
36
36
  - lib/mock_objects/shattered_ogre/input.rb
37
37
  - lib/mock_objects/shattered_ogre/light.rb
@@ -40,9 +40,6 @@ files:
40
40
  - lib/mock_objects/shattered_ogre/renderer.rb
41
41
  - lib/mock_objects/shattered_ogre/resource_handler.rb
42
42
  - lib/mock_objects/shattered_ogre/scene.rb
43
- - lib/shattered_controller/runner.rb
44
- - lib/shattered_controller/state.rb
45
- - lib/shattered_controller/actor/actor.rb
46
43
  - lib/shattered_model/base.rb
47
44
  - lib/shattered_model/fuzzy_logic.rb
48
45
  - lib/shattered_model/linear_interpolator.rb
@@ -53,6 +50,9 @@ files:
53
50
  - lib/shattered_pack/pre_initialize/pre_initialize.rb
54
51
  - lib/shattered_pack/timer/timed_event.rb
55
52
  - lib/shattered_pack/timer/timer.rb
53
+ - lib/shattered_state/base.rb
54
+ - lib/shattered_state/runner.rb
55
+ - lib/shattered_state/actor/actor.rb
56
56
  - lib/shattered_view/base.rb
57
57
  - lib/shattered_view/camera.rb
58
58
  - lib/shattered_view/extensions.rb
@@ -1,4 +0,0 @@
1
- %w(runner state).each do |dependency|
2
- dependency = "shattered_controller/#{dependency}"
3
- require dependency
4
- end