okami 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 295ccf3b84880a0c588c7866d965fe28fc97d81e
4
+ data.tar.gz: 461e0bc923354f20e9866df35e9d18e5c5ac85e3
5
+ SHA512:
6
+ metadata.gz: 0853a1fe7c4d53134197a6186d774c92c06142b54a4503d4e496d5b7ec2b5618b40248eb813496dacac44d222d6370eaf7d13af2e90759b8b71cd51655a2f025
7
+ data.tar.gz: d6051de2e84fb531d6d39628f7b00b8c9ff4b7ac96c0d347bfc60657f7f7491a11d444d454b0b22dd4d1f250cc3e7c05497df9d08816f8ce6d879a03ff07906e
@@ -4,11 +4,9 @@ module Okami
4
4
  require_relative 'okami/window'
5
5
  require_relative 'okami/keyboard'
6
6
  require_relative 'okami/mouse'
7
- require_relative 'okami/mouse_trap'
8
- require_relative 'okami/hit_mask'
9
7
  require_relative 'okami/image'
10
- require_relative 'okami/image_tiles_cache'
11
- require_relative 'okami/image_cache'
8
+ require_relative 'okami/image_tiles'
9
+ require_relative 'okami/image_attributes'
12
10
  require_relative 'okami/sprite'
13
11
 
14
12
  def self.retrofy
@@ -1,25 +1,88 @@
1
- require_relative 'drawable'
1
+ Okami::ImageCache = {}
2
+ Okami::ImageTileCache = {}
2
3
 
3
- class Okami::Image
4
- include Okami::Drawable
5
-
6
- def initialize image_path
7
- @image = Okami::ImageCache[image_path]
8
- init_drawable
4
+ module Okami::DrawMethods
5
+ def draw_using image_attributes
6
+ #draw_rot *image_attributes
7
+ ## or this?
8
+ draw_rot \
9
+ image_attributes.x,
10
+ image_attributes.y,
11
+ image_attributes.z,
12
+ image_attributes.angle,
13
+ image_attributes.center_x,
14
+ image_attributes.center_y,
15
+ image_attributes.factor_x,
16
+ image_attributes.factor_y,
17
+ image_attributes.color,
18
+ image_attributes.mode
9
19
  end
20
+ end
21
+
22
+ class Okami::Image < Gosu::Image
23
+ include Okami::DrawMethods
10
24
 
11
- @tileable = true
12
- @load_path = ""
25
+ @tileable = false
26
+ @load_path = './'
13
27
 
14
28
  class << self
15
- # Set this for a default value for wether the images should be tileable or not
29
+ # Default value for wether the images should be tileable or not
16
30
  attr_accessor :tileable
17
31
  # The directory to load the images from
18
32
  attr_accessor :load_path
19
33
 
20
- def load_path=val
21
- val << "/" unless val[-1] == "/"
22
- @load_path = val
34
+ def load_path= directory
35
+ if @_load_path_set
36
+ warn "It's best practice that '#{self}.load_path = directory'
37
+ is set only once since the image is cached by the relative path"
38
+ end
39
+ @_load_path_set = true
40
+ @load_path = directory
41
+ end
42
+
43
+ ## Character::Will cache the images so they're only loaded once.
44
+ def require relative_path, options=nil
45
+ Okami::ImageCache[relative_path] ||
46
+ load(relative_path, options)
47
+ end
48
+ alias [] require
49
+
50
+ ## Character::Will load and cache even if it's already cached
51
+ def load relative_path, options=nil
52
+ image_path = File.join(@load_path, relative_path)
53
+
54
+ Okami::ImageCache[relative_path] =
55
+ if options
56
+ new_by_options options
57
+ else
58
+ new $window, image_path
59
+ end
60
+ end
61
+
62
+ def new_by_options options
63
+ tileable = options[:tileable] || @tileable
64
+ src_rect = options[:src_rect]
65
+ new $window, image_path, tileable, *src_rect
66
+ end
67
+
68
+ def require_tiles relative_path,
69
+ tile_width=nil,
70
+ tile_height=nil,
71
+ tileable=@tileable
72
+ Okami::ImageTileCache[relative_path] ||
73
+ load_tiles(relative_path, tile_width, tile_height, tileable)
74
+ end
75
+
76
+ ## Character::Will load and cache even if it's already cached
77
+ def load_tiles relative_path,
78
+ tile_width,
79
+ tile_height,
80
+ tileable=@tileable
81
+
82
+ image_path = File.join(@load_path, relative_path)
83
+ tiles = super $window, image_path, tile_width, tile_height, tileable
84
+ tiles.each { |tile| tile.extend Okami::DrawMethods }
85
+ Okami::ImageTileCache[relative_path] = tiles
23
86
  end
24
87
  end
25
88
  end
@@ -0,0 +1,57 @@
1
+ require_relative 'wrapping_angle'
2
+
3
+ class Okami::ImageAttributes
4
+ @default_center_x = 0
5
+ @default_center_y = 0
6
+ @default_x = 0
7
+ @default_y = 0
8
+ @default_z = 0
9
+ @default_angle = 0
10
+
11
+ class << self
12
+ attr_accessor :default_center_x, :default_center_y, :default_x, :default_y, :default_z, :default_angle
13
+ end
14
+
15
+ attr_accessor :x, :y, :z
16
+ attr_accessor :factor_x, :factor_y
17
+ attr_accessor :center_x, :center_y
18
+ attr_accessor :color, :mode
19
+
20
+ def initialize options
21
+ @x = options[:x] || self.class.default_x
22
+ @y = options[:y] || self.class.default_y
23
+ @z = options[:z] || self.class.default_z
24
+
25
+ @wrapping_angle = Okami::WrappingAngle.new
26
+ @wrapping_angle.degrees = options[:angle] || self.class.default_angle
27
+ @degrees = @wrapping_angle.degrees
28
+
29
+ @center_x = options[:center_x] || self.class.default_center_x
30
+ @center_y = options[:center_y] || self.class.default_center_y
31
+ @factor_x = options[:factor_x] || 1
32
+ @factor_y = options[:factor_y] || 1
33
+
34
+ @color = options[:color] || Gosu::Color.argb(255, 255, 255, 255)
35
+ @mode = options[:mode] || :default
36
+ end
37
+
38
+ def to_a
39
+ return @x, @y, @z, @degrees, @center_x, @center_y, @factor_x, @factor_y, @color, @mode
40
+ end
41
+
42
+ alias :draw_rot_parameters :to_a
43
+
44
+ def rotate_radians a; @wrapping_angle.rotate_radians a; @degrees = @wrapping_angle.degrees end
45
+ def rotate_fraction a; @wrapping_angle.rotate_fraction a; @degrees = @wrapping_angle.degrees end
46
+ def rotate_degrees a; @wrapping_angle.rotate_degrees a; @degrees = @wrapping_angle.degrees end
47
+
48
+ def radians; @wrapping_angle.radians end
49
+ def fraction; @wrapping_angle.fraction end
50
+ def degrees; @wrapping_angle.degrees end
51
+ alias :angle :degrees
52
+
53
+ def radians= a; @wrapping_angle.radians = a; @degrees = @wrapping_angle.degrees end
54
+ def fraction= a; @wrapping_angle.fraction = a; @degrees = @wrapping_angle.degrees end
55
+ def degrees= a; @wrapping_angle.degrees = a; @degrees = @wrapping_angle.degrees end
56
+ alias :angle= :degrees=
57
+ end
@@ -0,0 +1,12 @@
1
+ module Okami::ImageTiles
2
+ class << self
3
+ def require *args
4
+ Okami::Image.require_tiles *args
5
+ end
6
+ alias [] require
7
+
8
+ def load *args
9
+ Okami::Image.load_tiles *args
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,3 @@
1
- require_relative 'os'
2
-
3
1
  module Okami::Keyboard
4
2
  DefaultKeySymbols = {
5
3
  Gosu::KbUp => :up,
@@ -71,10 +69,13 @@ module Okami::Keyboard
71
69
  Gosu::KbZ => :z
72
70
  }
73
71
 
74
- if Okami::OS.mac?
75
- DefaultKeySymbols[55] = :left_cmd
76
- DefaultKeySymbols[54] = :right_cmd
77
- end
72
+ # Maybe the command key will be used later
73
+ # Right now it's buggy
74
+ #require_relative 'os'
75
+ #if Okami::OS.mac?
76
+ # DefaultKeySymbols[55] = :left_cmd
77
+ # DefaultKeySymbols[54] = :right_cmd
78
+ #end
78
79
 
79
80
  DefaultKeySymbols.freeze
80
81
 
@@ -172,16 +173,6 @@ module Okami::Keyboard
172
173
  @@key_up_listeners.each { |listener, method| method.call key } if key
173
174
  end
174
175
 
175
- def release_keys
176
- call_key_up_on_down_keys
177
- Mouse.send :call_key_up_on_down_keys
178
- end
179
-
180
- def call_key_up_on_down_keys
181
- @@key_symbols.each do |code, key|
182
- call_key_up_listeners key if key_down? key
183
- end
184
- end
185
176
  end
186
177
 
187
178
  end
@@ -21,34 +21,22 @@ module Okami::Mouse
21
21
  def y=value; $window.mouse_y = value end
22
22
 
23
23
  def onscreen?
24
- if x < 0
25
- if y < 0
26
- if x > $window.width
27
- if y > $window.height
28
- return true
29
- end
30
- end
31
- end
32
- end
33
-
34
- return false
24
+ x >= 0 &&
25
+ y >= 0 &&
26
+ x <= $window.width &&
27
+ y <= $window.height
35
28
  end
36
29
 
37
30
  def offscreen?
38
31
  not onscreen?
39
32
  end
40
33
 
41
- def show; $window.cursor_visible = true end
42
- def hide; $window.cursor_visible = false end
43
- def visible=bool; $window.cursor_visible = bool end
34
+ def show; $window.cursor_visible = true end
35
+ def hide; $window.cursor_visible = false end
36
+ def visible=bool; $window.cursor_visible = bool end
44
37
 
45
- def add_key_down_listener listener_method
46
- @@key_down_listeners[ listener_method.receiver ] = listener_method
47
- end
48
-
49
- def add_key_up_listener listener_method
50
- @@key_up_listeners[ listener_method.receiver ] = listener_method
51
- end
38
+ def add_key_down_listener listener_method; @@key_down_listeners[ listener_method.receiver ] = listener_method end
39
+ def add_key_up_listener listener_method; @@key_up_listeners[ listener_method.receiver ] = listener_method end
52
40
 
53
41
  def remove_key_up_listener listener
54
42
  case listener
@@ -93,7 +81,7 @@ module Okami::Mouse
93
81
 
94
82
  def button_down id
95
83
  key = @@key_symbols[id]
96
- @@key_down_listeners.each { |listener, method| method.call key }
84
+ @@key_down_listeners.each { |listener, method| method.call key } if key
97
85
  end
98
86
 
99
87
  def button_up id
@@ -101,17 +89,6 @@ module Okami::Mouse
101
89
  @@key_up_listeners.each { |listener, method| method.call key } if key
102
90
  end
103
91
 
104
- def release_keys
105
- call_key_up_on_down_keys
106
- Okami::Keyboard.send :call_key_up_on_down_keys
107
- end
108
-
109
- def call_key_up_on_down_keys
110
- @@key_symbols.each do |code, key|
111
- button_up key if key_down? key
112
- end
113
- end
114
-
115
92
  end
116
93
 
117
94
  end
@@ -1,31 +1,42 @@
1
- require_relative 'drawable'
2
-
3
1
  class Okami::Sprite
4
- include Okami::Drawable
5
- AnimationModes = [:forward, :loop, :backward, :backward_loop, :ping_pong]
6
-
7
2
  attr_reader :image, :images, :last_frame_index
8
3
 
4
+ @@modes = {
5
+ loop: {direction: :forward, update_method: :update_loop},
6
+ backward_loop: {direction: :backward, update_method: :update_backward_loop},
7
+ reverse_loop: {direction: :backward, update_method: :update_backward_loop},
8
+ forward: {direction: :forward, update_method: :update_forward},
9
+ backward: {direction: :backward, update_method: :update_backward},
10
+ reverse: {direction: :backward, update_method: :update_backward},
11
+ ping_pong: {direction: :_forward, update_method: :update_ping_pong}
12
+ }
13
+ def self.modes; @@modes end
14
+
9
15
  def initialize options
10
16
  raise_possible_errors options
11
- options[:animation_mode] ||= :loop
12
17
 
13
- options.each do |key, value|
14
- send "#{key}=", value
15
- end
18
+ self.images = options[:images]
19
+ self.fps = options[:fps]
20
+ self.frame_index = options[:frame_index] if options[:frame_index]
21
+ self.mode = options[:mode] || :loop
16
22
 
17
23
  set_initial_frame_index
18
- init_drawable
19
24
  update_current_image
25
+
26
+ @@default_dt ||= $window.update_interval / 1000.0
20
27
  end
21
28
 
29
+ def draw *args; @image.draw *args end
30
+ def draw_rot *args; @image.draw_rot *args end
31
+ def draw_using image_attributes; @image.draw_using image_attributes end
32
+
22
33
  def fps; @delta_frame_index * 60.0 end
23
34
  def fps=fps; @delta_frame_index = fps / 60.0 end
24
35
 
25
- def update
36
+ def update dt=@@default_dt
26
37
  case @direction
27
- when :forward then @frame_index += @delta_frame_index*$window.dt*60.0
28
- when :backward then @frame_index -= @delta_frame_index*$window.dt*60.0
38
+ when :forward then @frame_index += @delta_frame_index * dt * 60.0
39
+ when :backward then @frame_index -= @delta_frame_index * dt * 60.0
29
40
  end
30
41
 
31
42
  @update_method.call
@@ -34,43 +45,20 @@ class Okami::Sprite
34
45
 
35
46
 
36
47
  def finished?
37
- case @animation_mode
48
+ case @mode
38
49
  when :forward; @frame_index == @last_frame_index
39
50
  when :backward; @frame_index == 0
40
51
  end
41
52
  end
42
53
  alias animation_finished? finished?
43
54
 
44
- attr_reader :animation_mode
45
- def animation_mode= symbol
46
- case symbol
47
- when :loop
48
- @direction = :forward
49
- use_update method :update_loop
50
-
51
- when :backward_loop
52
- @direction = :backward
53
- use_update method :update_backward_loop
54
-
55
- when :forward
56
- @direction = :forward
57
- use_update method :update_forward
58
-
59
- when :backward
60
- @direction = :backward
61
- use_update method :update_backward
62
-
63
- when :ping_pong
64
- @direction ||= :forward
65
- use_update method :update_ping_pong
66
-
67
- else
68
- puts "Supported AnimatedSprite animation modes:"
69
- puts AnimationModes
70
- raise ArgumentError, "AnimatedSprite, animation_mode #{symbol.inspect} not supported"
71
- end
72
-
73
- @animation_mode = symbol
55
+ attr_reader :mode
56
+ def mode= name
57
+ mode_config = @@modes[name]
58
+ mode_config or raise_no_mode name
59
+ self.direction = mode_config[:direction]
60
+ @update_method = method mode_config[:update_method]
61
+ @mode = name
74
62
  end
75
63
 
76
64
  attr_reader :frame_index
@@ -82,60 +70,62 @@ class Okami::Sprite
82
70
  end
83
71
 
84
72
  def random_frame_index
85
- (rand()*@images.length)
73
+ rand * @images.length
86
74
  end
87
75
 
88
76
  protected
89
77
 
90
78
  def images=images
91
79
  @images = images
92
- @last_frame_index = @images.length - 1
80
+ @last_frame_index = @images.length - 1
93
81
  end
94
82
 
95
83
  def direction=direction
96
- @direction = direction
84
+ case direction
85
+ when :forward; @direction = :forward
86
+ when :backward; @direction = :backward
87
+ when :_forward; @direction ||= :forward
88
+ when :_backward; @direction ||= :backward
89
+ end
97
90
  end
98
91
 
99
92
  private
100
93
 
101
94
  def set_initial_frame_index
102
95
  case @direction
103
- when :forward then @frame_index = 0
104
- when :backward then @frame_index = @last_frame_index+0.999
96
+ when :forward then @frame_index ||= 0
97
+ when :backward then @frame_index ||= @last_frame_index+0.999
105
98
  end
106
99
  end
107
100
 
108
- def use_update method; @update_method = method end
109
101
  def update_current_image; @image = @images[@frame_index] end
110
-
102
+
103
+ #################
104
+ ## update_methods
105
+
111
106
  def update_loop; @frame_index %= @images.length end
112
107
  def update_backward_loop; @frame_index %= @images.length end
113
108
 
114
- def update_backward
115
- @frame_index = 0 if @frame_index < 0
116
- end
117
-
118
- def update_forward
119
- @frame_index = @last_frame_index if @frame_index > @last_frame_index
120
- end
109
+ def update_backward; @frame_index = 0 if @frame_index < 0 end
110
+ def update_forward; @frame_index = @last_frame_index if @frame_index > @last_frame_index end
121
111
 
122
112
  def update_ping_pong
123
113
  case @direction
124
114
  when :forward
125
115
  if @frame_index >= @last_frame_index+0.5
126
- @direction = :backward
127
- @frame_index = @last_frame_index+0.5
116
+ @direction = :backward
117
+ @frame_index = @last_frame_index+0.5
128
118
  end
129
119
 
130
120
  when :backward
131
- if @frame_index < 0.5
132
- @frame_index = 0.5
133
- @direction = :forward
121
+ if @frame_index <= 0.5
122
+ @frame_index = 0.5
123
+ @direction = :forward
134
124
  end
135
-
136
125
  end
137
126
  end
138
127
 
128
+
139
129
  def raise_possible_errors options
140
130
  raise ArgumentError, "Sprite.new options must contain option :images" unless options[:images]
141
131
  raise TypeError, "Sprite.new option :images must be of type Array" unless options[:images].kind_of? Array
@@ -144,4 +134,10 @@ class Okami::Sprite
144
134
  raise ArgumentError, "Sprite.new options must contain option :fps" unless options[:fps]
145
135
  raise TypeError, "Sprite.new option :fps must be of type Numeric" unless options[:fps].kind_of? Numeric
146
136
  end
137
+
138
+ def raise_no_mode symbol
139
+ puts "Supported AnimatedSprite modes:"
140
+ puts @@modes.keys
141
+ raise ArgumentError, "AnimatedSprite, mode #{symbol.inspect} not supported"
142
+ end
147
143
  end # Okami::Sprite
@@ -1,52 +1,42 @@
1
1
  module Okami
2
2
  class Window < Gosu::Window
3
- attr_reader :dt, :current_time
4
- attr_accessor :cursor_visible
5
3
 
6
4
  def initialize *args
7
5
  $window = super *args
8
6
  end
9
-
7
+
8
+ attr_accessor :cursor_visible
10
9
  def show_cursor; @cursor_visible = true end
11
10
  def hide_cursor; @cursor_visible = false end
12
11
  def needs_cursor?; @cursor_visible end
13
12
 
14
13
  def button_down id
15
- Okami::Keyboard.button_down id
16
- Okami::Mouse.button_down id
14
+ Okami::Keyboard .button_down id
15
+ Okami::Mouse .button_down id
17
16
  end
18
17
 
19
- def button_up id
20
- Okami::Keyboard.button_up id
21
- Okami::Mouse.button_up id
18
+ def button_up id
19
+ Okami::Keyboard .button_up id
20
+ Okami::Mouse .button_up id
22
21
  end
23
22
 
24
- def fill color, z=0
23
+ def fill color, z=0, mode=:default
25
24
  draw_quad 0, 0, color,
26
25
  width, 0, color,
27
26
  0, height, color,
28
27
  width, height, color,
29
- z, mode = :default
28
+ z, mode
30
29
  end
31
30
 
32
31
  def calculate_dt
33
- @current_time = Gosu::milliseconds/1000.0
34
- @previous_time ||= @current_time - update_interval/1000.0
35
- @dt = @current_time - @previous_time
36
- @previous_time = @current_time
37
- end
38
-
39
- def self.inherited(subclass)
40
- def subclass.method_added(name)
41
- if name == :update
42
- ## Prevent infinite loop
43
- return if caller.first.match(/^(.+?):(\d+)(?::in `(.*)')?/)[1].match /eval/i
44
- ## Calculate_dt before update
45
- class_eval "def update_hook\n calculate_dt\n update_without_hook\nend"
46
- class_eval "alias update_without_hook update"
47
- class_eval "alias update update_hook"
48
- end
49
- end
32
+ update_interval = self.update_interval / 1000.0
33
+ seconds = Time.now.to_f
34
+ @_current_time = seconds
35
+ @_previous_time ||= @_current_time - update_interval
36
+ dt = @_current_time - @_previous_time
37
+ @_previous_time = @_current_time
38
+ dt = update_interval if dt < update_interval
39
+ return dt, seconds
50
40
  end
51
41
 
52
42
  end # Window
@@ -1,44 +1,42 @@
1
- class WrappingAngle
1
+ class Okami::WrappingAngle
2
2
  Tau = Math::PI * 2
3
3
 
4
- def initialize
5
- @c = Complex(0,1)
4
+ def initialize options={}
5
+ self.fraction = options[:fraction] if options.has_key? :fraction
6
+ self.degrees = options[:degrees] if options.has_key? :degrees
7
+ self.radians = options[:radians] if options.has_key? :radians
8
+ @radians ||= 0
6
9
  end
7
10
 
8
- def rotate_radians a; @c *= Complex(0,1)**(a/Tau * 4) end
9
- def rotate_fraction a; @c *= Complex(0,1)**(a*4) end
10
- def rotate_degrees a; @c *= Complex(0,1)**(a/90.0) end
11
+ def radians; @radians end
12
+ def fraction; @radians / Tau end
13
+ def degrees; @radians / Tau * 360.0 end
11
14
 
12
- def radians; @c.angle end
13
- def fraction; @c.angle / Tau end
14
- def degrees; @c.angle / Tau * 360 end
15
-
16
- def radians= a; @c = Complex(0,1)**(a/Tau * 4) end
17
- def fraction= a; @c = Complex(0,1)**(a*4.0) end
18
- def degrees= a; @c = Complex(0,1)**(a/90.0) end
15
+ def radians= a; @radians = a % Tau end
16
+ def fraction= a; @radians = (a % 1.0 ) * Tau end
17
+ def degrees= a; @radians = (a % 360.0 ) / 360.0 * Tau end
19
18
 
20
19
  ### Displaying
21
-
22
- begin
23
- require 'fraction'
24
- def pretty_angle unit=@standard_unit
25
- case unit
26
- when :degrees
27
- "#{angle(:degrees).round}°"
28
- when :fraction, :radians
29
- nom, den = angle(:fraction).fraction
30
- return "0τ" if nom == 0
31
- return "#{nom}/#{den}τ"
32
- end
33
- end
34
- rescue LoadError
35
- def pretty_angle unit=@standard_unit
36
- case unit
37
- when :degrees; "#{angle(:degrees).round}°"
38
- when :radians; "#{angle(:radians)} radians"
39
- when :fraction; "#{angle(:fraction)}"
40
- end
41
- end
42
- end
20
+ #begin
21
+ # require 'fraction'
22
+ # def pretty_angle unit=@standard_unit
23
+ # case unit
24
+ # when :degrees
25
+ # "#{angle(:degrees).round}°"
26
+ # when :fraction, :radians
27
+ # nom, den = angle(:fraction).fraction
28
+ # return "0τ" if nom == 0
29
+ # return "#{nom}/#{den}τ"
30
+ # end
31
+ # end
32
+ #rescue LoadError
33
+ # def pretty_angle unit=@standard_unit
34
+ # case unit
35
+ # when :degrees; "#{angle(:degrees).round}°"
36
+ # when :radians; "#{angle(:radians)} radians"
37
+ # when :fraction; "#{angle(:fraction)}"
38
+ # end
39
+ # end
40
+ #end
43
41
 
44
42
  end
metadata CHANGED
@@ -1,90 +1,67 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bue Grønlund
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-12 00:00:00.000000000 Z
11
+ date: 2013-10-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: gosu
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: texplay
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- description: Gosu Interface with fancy functionality for simplicity.
27
+ description: Different features like simple image loading, input check, input listeners,
28
+ and using symbols instead of integers for input ids. Eg. :left instead of Gosu::KbLeft
47
29
  email: aerotune@gmail.com
48
30
  executables: []
49
31
  extensions: []
50
32
  extra_rdoc_files: []
51
33
  files:
52
34
  - lib/okami.rb
53
- - lib/okami/drawable.rb
54
35
  - lib/okami/window.rb
55
36
  - lib/okami/keyboard.rb
56
37
  - lib/okami/mouse.rb
57
- - lib/okami/mouse_trap.rb
58
38
  - lib/okami/image.rb
59
- - lib/okami/image_cache.rb
60
- - lib/okami/image_tiles_cache.rb
61
- - lib/okami/hit_mask.rb
39
+ - lib/okami/image_tiles.rb
40
+ - lib/okami/image_attributes.rb
62
41
  - lib/okami/sprite.rb
63
42
  - lib/okami/os.rb
64
43
  - lib/okami/wrapping_angle.rb
65
44
  homepage: https://github.com/Aerotune/Okami
66
45
  licenses: []
46
+ metadata: {}
67
47
  post_install_message:
68
48
  rdoc_options: []
69
49
  require_paths:
70
50
  - lib
71
51
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
52
  requirements:
74
- - - ! '>='
53
+ - - '>='
75
54
  - !ruby/object:Gem::Version
76
55
  version: '0'
77
56
  required_rubygems_version: !ruby/object:Gem::Requirement
78
- none: false
79
57
  requirements:
80
- - - ! '>='
58
+ - - '>='
81
59
  - !ruby/object:Gem::Version
82
60
  version: '0'
83
61
  requirements: []
84
62
  rubyforge_project:
85
- rubygems_version: 1.8.25
63
+ rubygems_version: 2.1.5
86
64
  signing_key:
87
- specification_version: 3
88
- summary: Okami minimal Gosu!
65
+ specification_version: 4
66
+ summary: Sugar coated Gosu
89
67
  test_files: []
90
- has_rdoc:
@@ -1,74 +0,0 @@
1
- require_relative 'wrapping_angle'
2
-
3
- module Okami::Drawable
4
- @default_center_x = 0
5
- @default_center_y = 0
6
-
7
- class << self
8
- attr_accessor :default_center_x, :default_center_y
9
- end
10
-
11
- attr_accessor :x, :y, :z
12
- attr_accessor :factor_x, :factor_y
13
- attr_accessor :center_x, :center_y
14
- attr_accessor :color, :draw_mode
15
-
16
- def init_drawable
17
- @factor_x = 1
18
- @factor_y = 1
19
- self.center_x = Okami::Drawable.default_center_x
20
- self.center_y = Okami::Drawable.default_center_y
21
- @x = 0
22
- @y = 0
23
- @z = 0
24
- @wrapping_angle = WrappingAngle.new
25
- @wrapping_angle.degrees = 0
26
- @degrees = @wrapping_angle.degrees
27
- @color = 0xFFFFFFFF
28
- @draw_mode = :default
29
- @color = Gosu::Color.argb(255, 255, 255, 255)
30
- @alpha = 1.0
31
- end
32
-
33
- def draw
34
- @image.draw_rot @x, @y, @z, @degrees, @center_x, @center_y, @factor_x, @factor_y, @color, @draw_mode
35
- end
36
-
37
- def rotate_radians a; @wrapping_angle.rotate_radians a; @degrees = @wrapping_angle.degrees end
38
- def rotate_fraction a; @wrapping_angle.rotate_fraction a; @degrees = @wrapping_angle.degrees end
39
- def rotate_degrees a; @wrapping_angle.rotate_degrees a; @degrees = @wrapping_angle.degrees end
40
-
41
- def radians; @wrapping_angle.radians end
42
- def fraction; @wrapping_angle.fraction end
43
- def degrees; @wrapping_angle.degrees end
44
-
45
- def radians= a; @wrapping_angle.radians = a; @degrees = @wrapping_angle.degrees end
46
- def fraction= a; @wrapping_angle.fraction = a; @degrees = @wrapping_angle.degrees end
47
- def degrees= a; @wrapping_angle.degrees = a; @degrees = @wrapping_angle.degrees end
48
-
49
- attr_reader :alpha
50
- def alpha=a
51
- @alpha = a
52
- @color.alpha = a*255
53
- end
54
-
55
- def argb= a, r, g, b
56
- @color.alpha = a * 255
57
- @color.red = r * 255
58
- @color.green = g * 255
59
- @color.blue = b * 255
60
- end
61
-
62
- def rgba= r, g, b, a
63
- @color.red = r * 255
64
- @color.green = g * 255
65
- @color.blue = b * 255
66
- @color.alpha = a * 255
67
- end
68
-
69
- def rgb= r, g, b
70
- @color.red = r * 255
71
- @color.green = g * 255
72
- @color.blue = b * 255
73
- end
74
- end
@@ -1,23 +0,0 @@
1
- class Okami::HitMask
2
- ## white is hitpoints, black is not
3
- def initialize image, parent
4
- @hit_mask = image
5
- @parent = parent
6
- end
7
-
8
- def hit_point? x, y
9
- c = @hit_mask.get_pixel( x - @parent.x, y - @parent.y )
10
- return false unless c
11
- return c[1] > 0.9 # quick 'n dirty
12
- end
13
-
14
- def hit_line? x1, y1, x2, y2
15
- !!hit_line( x1, y1, x2, y2 )
16
- end
17
-
18
- # Returns an array with the coordinates of the first hit point [x,y] or nil if it doesn't hit
19
- def hit_line x1, y1, x2, y2
20
- hit_vertex = @hit_mask.line x1, y1, x2, y2, trace: { :until_color => :white, :tolerance => 0.1 }
21
- hit_vertex ? hit_vertex[0..1] : nil
22
- end
23
- end
@@ -1,18 +0,0 @@
1
- Okami::Images = {}
2
-
3
- class Okami::ImageCache
4
- class << self
5
- ## Will cache the images so they're only loaded once.
6
- def require path, tileable=Okami::Image.tileable, *src_rect
7
- path = Okami::Image.load_path + path
8
- Okami::Images[ path + src_rect.to_s ] ||= Gosu::Image.new $window, path, tileable, *src_rect
9
- end
10
- alias [] require
11
-
12
- ## Will load and cache even if it's already cached
13
- def load path, tileable=Okami::Image.tileable, *src_rect
14
- path = Okami::Image.load_path + path
15
- Okami::Images[ path + src_rect.to_s ] = Gosu::Image.new $window, path, tileable, *src_rect
16
- end
17
- end
18
- end
@@ -1,17 +0,0 @@
1
- Okami::ImageTiles = {}
2
-
3
- class Okami::ImageTilesCache
4
- class << self
5
- def require path, tile_width, tile_height, tileable=Okami::Image.tileable
6
- path = Okami::Image.load_path + path
7
- Okami::ImageTiles[ "size:#{tile_width},#{tile_height}&" + path ] ||= Gosu::Image.load_tiles $window, path, tile_width, tile_height, tileable
8
- end
9
- alias [] require
10
-
11
- ## Will load and cache even if it's already cached
12
- def load path, tile_width, tile_height, tileable=Okami::Image.tileable
13
- path = Okami::Image.load_path + path
14
- Okami::ImageTiles[ "size:#{tile_width},#{tile_height}&" + path ] = Gosu::Image.load_tiles $window, path, tile_width, tile_height, tileable
15
- end
16
- end
17
- end
@@ -1,18 +0,0 @@
1
- module Okami
2
- module MouseTrap
3
- class << self
4
- def capture
5
- @captured ? false : @captured = true
6
- end
7
-
8
- def release
9
- @captured = false
10
- return true
11
- end
12
-
13
- def captured?
14
- @captured
15
- end
16
- end
17
- end
18
- end