gosu 0.7.41-x86-mingw32 → 0.7.43-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2004-2011 Julian Raschke, Jan Lücker and all contributors.
1
+ Copyright (C) 2004-2012 Julian Raschke, Jan Lücker and all contributors.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a
4
4
  copy of this software and associated documentation files (the "Software"),
@@ -67,8 +67,8 @@ namespace Gosu
67
67
  kbRightControl = XK_Control_R,
68
68
  kbLeftAlt = XK_Alt_L,
69
69
  kbRightAlt = XK_Alt_R,
70
- kbLeftMeta = 0, // TODO?!
71
- kbRightMeta = 0,
70
+ kbLeftMeta = XK_Meta_L,
71
+ kbRightMeta = XK_Meta_R,
72
72
  kbBackspace = XK_BackSpace,
73
73
  kbLeft = XK_Left,
74
74
  kbRight = XK_Right,
@@ -3,8 +3,8 @@
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
5
  #define GOSU_MINOR_VERSION 7
6
- #define GOSU_POINT_VERSION 41
7
- #define GOSU_VERSION "0.7.41"
6
+ #define GOSU_POINT_VERSION 43
7
+ #define GOSU_VERSION "0.7.43"
8
8
 
9
9
  #define GOSU_COPYRIGHT_NOTICE \
10
10
  " " \
@@ -0,0 +1,68 @@
1
+ # Gosu Zen example based on erisdiscord's comment here:
2
+ # https://github.com/jlnr/gosu/pull/120
3
+
4
+ # Gosu Zen is the (inline) Sinatra of Ruby multimedia programming.
5
+ # The interface is still in flux. If you want to tune the interface
6
+ # a little further or provide more examples, please fork Gosu and
7
+ # send a pull request. Thanks!
8
+
9
+ require 'rubygems'
10
+ require 'gosu/zen'
11
+ include Gosu::Zen
12
+
13
+ window 480, 240, :fullscreen => false
14
+
15
+ button_down Gosu::KbEscape do
16
+ close
17
+ end
18
+
19
+ update do
20
+ t = Gosu.milliseconds / 1000.0
21
+
22
+ @radius = [width, height].min * 0.37
23
+ @angle = t * Math::PI
24
+
25
+ a, b =\
26
+ (Math.cos(t) + 0.5) * 0xff,
27
+ (Math.sin(t) + 0.5) * 0xff
28
+
29
+ c = (a + b) / 2
30
+
31
+ @colors = [
32
+ Gosu::Color.rgb(a, b, 0xff),
33
+ Gosu::Color.rgb(a, 0x00, b),
34
+ Gosu::Color.rgb(0xff, b, a),
35
+ Gosu::Color.rgb(b, a, 0x00),
36
+ Gosu::Color.rgb(b, 0xff, a),
37
+ Gosu::Color.rgb(0x00, a, b) ]
38
+
39
+ @background = Gosu::Color.rgb(c, c, c)
40
+ end
41
+
42
+ draw do
43
+ draw_quad\
44
+ 0, 0, @background,
45
+ 0, height, @background,
46
+ width, height, @background,
47
+ width, 0, @background, 0
48
+
49
+ translate width / 2, height / 2 do
50
+ @colors.each.with_index do |color, i|
51
+
52
+ angle = @angle + i.to_f / @colors.length * 2.0 * Math::PI
53
+ x = @radius * Math.sin(angle)
54
+ y = @radius * Math.cos(angle)
55
+ w, h = x, y
56
+
57
+ translate x, y do
58
+ rotate Gosu.radians_to_degrees(angle) do
59
+ draw_quad\
60
+ -w, +h, color,
61
+ -w, -h, color,
62
+ +w, -h, color,
63
+ +w, +h, color, 0
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
Binary file
Binary file
@@ -85,37 +85,55 @@ module Gosu
85
85
  end
86
86
  end
87
87
 
88
+ def self.button_down? id
89
+ $window.button_down? id
90
+ end
91
+
92
+ def self.mouse_x
93
+ $window.mouse_x
94
+ end
95
+
96
+ def self.mouse_y
97
+ $window.mouse_y
98
+ end
99
+
100
+ def self.draw_line *args
101
+ $window.draw_line *args
102
+ end
103
+
104
+ def self.draw_triangle *args
105
+ $window.draw_triangle *args
106
+ end
107
+
88
108
  def self.draw_quad *args
89
109
  $window.draw_quad *args
90
110
  end
91
111
 
92
- def self.clip_to *args
93
- $window.clip_to *args do
94
- yield
95
- end
112
+ def self.clip_to *args, &draw
113
+ $window.clip_to *args, &draw
96
114
  end
97
115
 
98
- def self.translate *args
99
- $window.translate *args do
100
- yield
101
- end
116
+ def self.translate *args, &draw
117
+ $window.translate *args, &draw
102
118
  end
103
119
 
104
- def self.scale *args
105
- $window.scale *args do
106
- yield
107
- end
120
+ def self.scale *args, &draw
121
+ $window.scale *args, &draw
108
122
  end
109
123
 
110
- def self.rotate *args
111
- $window.rotate *args do
112
- yield
113
- end
124
+ def self.rotate *args, &draw
125
+ $window.rotate *args, &draw
114
126
  end
115
127
 
116
- def self.transform *args
117
- $window.transform *args do
118
- yield
119
- end
128
+ def self.transform *args, &draw
129
+ $window.transform *args, &draw
130
+ end
131
+
132
+ def self.record width, height, &draw
133
+ $window.record width, height, &draw
134
+ end
135
+
136
+ def self.gl *args, &draw
137
+ $window.gl *args, &draw
120
138
  end
121
139
  end
@@ -10,8 +10,8 @@ class Gosu::Window
10
10
  lose_focus button_down button_up).each do |callback|
11
11
  define_method "protected_#{callback}" do |*args|
12
12
  begin
13
- # Turn into a boolean result for needs_cursor? etc while we are at it.
14
13
  # If there has been an exception, don't do anything as to not make matters worse.
14
+ # Conveniently turn the return value into a boolean result (for needs_cursor? etc).
15
15
  defined?(@_exception) ? false : !!send(callback, *args)
16
16
  rescue Exception => e
17
17
  # Exit the message loop naturally, then re-throw
@@ -21,6 +21,17 @@ class Gosu::Window
21
21
  end
22
22
  end
23
23
 
24
+ def protected_draw_2
25
+ protected_draw
26
+ $gosu_gl_blocks = nil
27
+ end
28
+
29
+ def gl(*args, &block)
30
+ $gosu_blocks ||= []
31
+ $gosu_blocks << block
32
+ unsafe_gl(*args, &block)
33
+ end
34
+
24
35
  alias show_internal show
25
36
  def show
26
37
  show_internal
@@ -1,28 +1,77 @@
1
- require 'gosu'
2
- require 'singleton'
1
+ require 'gosu/preview'
3
2
 
4
3
  module Gosu
4
+ module Zen
5
+
6
+ @@window_args = [800, 600, {}]
7
+ @@options = {}
8
+
9
+ def window width, height, options = nil
10
+ if $window.nil?
11
+ @@window_args[0] = width
12
+ @@window_args[1] = height
13
+ @@window_args[2].merge! options if options
14
+ else
15
+ raise "window size can only be set before the window is created"
16
+ end
17
+ end
18
+
19
+ def set what, value
20
+ if $window.nil?
21
+ @@options[what.to_sym] = value
22
+ else
23
+ $window.send "#{what}=", value
24
+ end
25
+ end
26
+
27
+ def button_down id = nil, &body
28
+ m = id ? "button_down_#{id}" : :button_down_other
29
+ ZenWindow.send :define_method, m, &body
30
+ end
31
+
32
+ def button_up id = nil, &body
33
+ m = id ? "button_up_#{id}" : :button_up_other
34
+ ZenWindow.send :define_method, m, &body
35
+ end
36
+
37
+ def update &body
38
+ ZenWindow.send :define_method, :update, &body
39
+ end
40
+
41
+ def draw &body
42
+ ZenWindow.send :define_method, :draw, &body
43
+ end
44
+
45
+ def run!
46
+ window = ZenWindow.new *@@window_args
47
+ @@options.each do |opt, value|
48
+ window.send "#{opt}=", value
49
+ end
50
+ window.show
51
+ end
52
+
53
+ def Zen.included mod
54
+ at_exit { run! unless $! }
55
+ end
56
+
57
+ end
58
+
5
59
  class ZenWindow < Window
6
- include Singleton
60
+ def button_down id
61
+ m = :"button_down_#{id}"
62
+ respond_to?(m) ? send(m) : button_down_other(id)
63
+ end
64
+
65
+ def button_up id
66
+ m = :"button_up_#{id}"
67
+ respond_to?(m) ? send(m) : button_up_other(id)
68
+ end
69
+
70
+ def button_down_other id
71
+ end
7
72
 
8
- def initialize
9
- super 800, 600, false
73
+ def button_up_other id
10
74
  end
75
+
11
76
  end
12
77
  end
13
-
14
- def set what, value
15
- Gosu::ZenWindow.instance.send "#{what}=", value
16
- end
17
-
18
- def update(&proc)
19
- Gosu::ZenWindow.send :define_method, :update, proc
20
- end
21
-
22
- # WIP - needs all other callbacks, even with arguments
23
-
24
- # WIP - needs to be compatible with gosu/preview.rb later
25
-
26
- at_exit do
27
- Gosu::ZenWindow.instance.show
28
- end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 81
4
+ hash: 85
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 41
10
- version: 0.7.41
9
+ - 43
10
+ version: 0.7.43
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - Julian Raschke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-17 00:00:00 Z
18
+ date: 2012-03-18 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: " 2D game development library.\n\n Gosu features easy to use and game-friendly interfaces to 2D graphics\n and text (accelerated by 3D hardware), sound samples and music as well as\n keyboard, mouse and gamepad/joystick input.\n\n Also includes demos for integration with RMagick, Chipmunk and OpenGL.\n"
@@ -68,6 +68,7 @@ files:
68
68
  - lib/gosu.rb
69
69
  - examples/ChipmunkIntegration.rb
70
70
  - examples/CptnRuby.rb
71
+ - examples/GosuZen.rb
71
72
  - examples/MoreChipmunkAndRMagick.rb
72
73
  - examples/OpenGLIntegration.rb
73
74
  - examples/RMagickIntegration.rb
@@ -131,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  requirements: []
132
133
 
133
134
  rubyforge_project:
134
- rubygems_version: 1.8.11
135
+ rubygems_version: 1.8.16
135
136
  signing_key:
136
137
  specification_version: 3
137
138
  summary: 2D game development library.