rubydraw 0.2.9 → 0.2.9.3

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.
@@ -0,0 +1,29 @@
1
+ module Rubydraw
2
+ # An instance of this class is returned every time you call
3
+ # Rubydraw.mouse_state.
4
+ class MouseState
5
+ attr_reader(:button, :position)
6
+
7
+ def initialize(button, position)
8
+ @button, @position = button, position
9
+ end
10
+
11
+ def x
12
+ @position.x
13
+ end
14
+
15
+ def y
16
+ @position.y
17
+ end
18
+
19
+ def to_ary
20
+ [@button, x, y]
21
+ end
22
+ end
23
+
24
+ # Return the current mouse condition.
25
+ def self.mouse_state
26
+ state = SDL.GetMouseState
27
+ MouseState.new(state[0], Point[state[1], state[2]])
28
+ end
29
+ end
data/lib/rubydraw.rb CHANGED
@@ -19,7 +19,8 @@ files = %w[
19
19
  point
20
20
  color
21
21
  sdl_error
22
- rectangle]
22
+ rectangle
23
+ mouse_state]
23
24
  files.each { |f| require("rubydraw/" + f) }
24
25
 
25
26
  # This must be loaded last, because it sets up constants that "point" to Rubydraw classes, hence
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rubydraw
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.9
5
+ version: 0.2.9.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - J. Wostenberg
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-02 00:00:00 -07:00
13
+ date: 2011-12-03 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,7 @@ files:
48
48
  - lib/rubydraw/point.rb
49
49
  - lib/rubydraw/color.rb
50
50
  - lib/rubydraw/rectangle.rb
51
+ - lib/rubydraw/mouse_state.rb
51
52
  - examples/window_ex.rb
52
53
  - examples/image_ex.rb
53
54
  - examples/ball_catch_game.rb