okami 0.0.0 → 0.0.1

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.
@@ -1,7 +1,7 @@
1
- ## The image of the hitmask, white is hitpoints, black is not
2
1
  require 'texplay'
3
2
 
4
- class Okami::HitMask
3
+ class Okami::HitMask
4
+ ## The mask is of the type Image, white is hitpoints, black is not
5
5
  def initialize mask, parent
6
6
  @hit_mask = mask
7
7
  @parent = parent
@@ -13,8 +13,13 @@ class Okami::HitMask
13
13
  return c[1] > 0.9 # quick 'n dirty
14
14
  end
15
15
 
16
+ def hit_line? x1, y1, x2, y2
17
+ !!hit_line( x1, y1, x2, y2 )
18
+ end
19
+
20
+ # Returns an array with the coordinates of the first hit point [x,y] or nil if it doesn't hit
16
21
  def hit_line x1, y1, x2, y2
17
22
  hit_vertex = @hit_mask.line x1, y1, x2, y2, trace: { :until_color => :white, :tolerance => 0.1 }
18
- hit_vertex || false
23
+ hit_vertex ? hit_vertex[0..1] : nil
19
24
  end
20
25
  end
data/lib/okami/image.rb CHANGED
@@ -3,27 +3,28 @@ class Okami::Image < Gosu::Image
3
3
  @load_path = ""
4
4
 
5
5
  class << self
6
- attr_accessor :tileable, :load_path
7
-
8
6
  Images = {}
9
7
  ImageTiles = {}
8
+
9
+ # Set this for a default value for wether the images should be tileable or not
10
+ attr_accessor :tileable
11
+ # The directory to load the images from
12
+ attr_accessor :load_path
10
13
 
11
14
  def new path, tileable=@tileable, *src_rect
12
15
  super $window, @load_path + path, tileable, *src_rect
13
16
  end
14
- alias load new
15
17
 
16
- def load_tiles path, tile_width, tile_height, tileable=@tileable
18
+ def new_tiles path, tile_width, tile_height, tileable=@tileable
17
19
  super $window, @load_path + path, tile_width, tile_height, tileable
18
20
  end
19
- alias new_tiles load_tiles
20
21
 
21
- ## Require will only load the image the first time it is called.
22
+ # require / [] will cache the images so they're only loaded once.
22
23
  def require path, tileable=@tileable, *src_rect
23
24
  Images[ @load_path + path + src_rect.to_s ] ||= load path, tileable, *src_rect
24
25
  end
25
26
  alias [] require
26
-
27
+
27
28
  def require_tiles path, tile_width, tile_height, tileable=@tileable
28
29
  ImageTiles[ "size:#{tile_width},#{tile_height}&" + @load_path + path ] ||= load_tiles path, tile_width, tile_height, tileable
29
30
  end
@@ -1,4 +1,4 @@
1
- require 'okami/operating_system'
1
+ require 'okami/os'
2
2
 
3
3
  module Okami::Keyboard
4
4
  DefaultKeySymbols = {
@@ -125,7 +125,7 @@ module Okami::Keyboard
125
125
 
126
126
  end
127
127
 
128
- ## Returns true if all key_symbols is down
128
+ ## Returns true if all key_symbol arguments is down
129
129
  def keys_down? *key_symbols
130
130
  key_symbols.each do |key_symbol|
131
131
  return false unless key_down? key_symbol
@@ -133,7 +133,7 @@ module Okami::Keyboard
133
133
  return true
134
134
  end
135
135
 
136
- ## Returns true if one of the key_symbols is down
136
+ ## Returns true if one of the key_symbol arguments is down
137
137
  def any_key_down? *key_symbols
138
138
  key_symbols << :any_key if key_symbols.empty?
139
139
  key_symbols.each do |key_symbol|
@@ -1,16 +1,18 @@
1
1
  module Okami
2
- MouseTrap = Struct.new(:captured)
3
- class << MouseTrap
4
- def capture
5
- @captured ? false : @captured = true
6
- end
2
+ module MouseTrap
3
+ class << self
4
+ def capture
5
+ @captured ? false : @captured = true
6
+ end
7
7
 
8
- def release
9
- @captured = false
10
- return true
11
- end
8
+ def release
9
+ @captured = false
10
+ return true
11
+ end
12
12
 
13
- def captured?; !!@captured end
14
- def released?; !@captured end
13
+ def captured?
14
+ @captured
15
+ end
16
+ end
15
17
  end
16
18
  end
File without changes
data/lib/okami/sprite.rb CHANGED
@@ -57,7 +57,6 @@ class Okami::Sprite
57
57
 
58
58
  attr_reader :mode
59
59
  def mode= symbol
60
-
61
60
  case symbol
62
61
  when :loop
63
62
  @direction = :forward
@@ -132,7 +131,7 @@ class Okami::Sprite
132
131
 
133
132
  end
134
133
  end
135
- end
134
+ end # Okami::Sprite
136
135
 
137
136
  =begin
138
137
  ## Example ##
data/lib/okami/window.rb CHANGED
@@ -1,11 +1,6 @@
1
1
  module Okami
2
- def self.method_missing *args
3
- Gosu.send *args
4
- end
5
-
6
- def self.const_missing const
7
- Gosu.const_get const
8
- end
2
+ def self.method_missing *args; Gosu.send *args end
3
+ def self.const_missing const; Gosu.const_get const end
9
4
 
10
5
  class Window < Gosu::Window
11
6
  include Gosu
@@ -53,7 +48,6 @@ module Okami
53
48
  end
54
49
  end
55
50
 
56
-
57
- end
58
- end
51
+ end # Window
52
+ end # Okami
59
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-03-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gosu
16
- requirement: &70258649056920 !ruby/object:Gem::Requirement
16
+ requirement: &70099941648900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,18 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70258649056920
25
- - !ruby/object:Gem::Dependency
26
- name: texplay
27
- requirement: &70258649056300 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70258649056300
24
+ version_requirements: *70099941648900
36
25
  description: Gosu Interface with fancy functionality for simplicity.
37
26
  email: aerotune@gmail.com
38
27
  executables: []
@@ -47,7 +36,7 @@ files:
47
36
  - lib/okami/image.rb
48
37
  - lib/okami/hit_mask.rb
49
38
  - lib/okami/sprite.rb
50
- - lib/okami/operating_system.rb
39
+ - lib/okami/os.rb
51
40
  homepage: https://github.com/Aerotune/Okami
52
41
  licenses: []
53
42
  post_install_message:
@@ -66,7 +55,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
55
  - - ! '>='
67
56
  - !ruby/object:Gem::Version
68
57
  version: '0'
69
- requirements: []
58
+ requirements:
59
+ - To use Okami::HitMask you need to have the 'texplay' gem installed
70
60
  rubyforge_project:
71
61
  rubygems_version: 1.8.10
72
62
  signing_key: