gosu 0.7.9-x86-mswin32-60

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,137 @@
1
+ begin
2
+ # In case you use Gosu via RubyGems.
3
+ require 'rubygems'
4
+ rescue LoadError
5
+ # In case you don't.
6
+ end
7
+
8
+ require 'gosu'
9
+
10
+ module ZOrder
11
+ Background, Stars, Player, UI = *0..3
12
+ end
13
+
14
+ class Player
15
+ attr_reader :score
16
+
17
+ def initialize(window)
18
+ @image = Gosu::Image.new(window, "media/Starfighter.bmp", false)
19
+ @beep = Gosu::Sample.new(window, "media/Beep.wav")
20
+ @x = @y = @vel_x = @vel_y = @angle = 0.0
21
+ @score = 0
22
+ end
23
+
24
+ def warp(x, y)
25
+ @x, @y = x, y
26
+ end
27
+
28
+ def turn_left
29
+ @angle -= 4.5
30
+ end
31
+
32
+ def turn_right
33
+ @angle += 4.5
34
+ end
35
+
36
+ def accelerate
37
+ @vel_x += Gosu::offset_x(@angle, 0.5)
38
+ @vel_y += Gosu::offset_y(@angle, 0.5)
39
+ end
40
+
41
+ def move
42
+ @x += @vel_x
43
+ @y += @vel_y
44
+ @x %= 640
45
+ @y %= 480
46
+
47
+ @vel_x *= 0.95
48
+ @vel_y *= 0.95
49
+ end
50
+
51
+ def draw
52
+ @image.draw_rot(@x, @y, ZOrder::Player, @angle)
53
+ end
54
+
55
+ def collect_stars(stars)
56
+ stars.reject! do |star|
57
+ if Gosu::distance(@x, @y, star.x, star.y) < 35 then
58
+ @score += 10
59
+ @beep.play
60
+ true
61
+ else
62
+ false
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ class Star
69
+ attr_reader :x, :y
70
+
71
+ def initialize(animation)
72
+ @animation = animation
73
+ @color = Gosu::Color.new(0xff000000)
74
+ @color.red = rand(255 - 40) + 40
75
+ @color.green = rand(255 - 40) + 40
76
+ @color.blue = rand(255 - 40) + 40
77
+ @x = rand * 640
78
+ @y = rand * 480
79
+ end
80
+
81
+ def draw
82
+ img = @animation[Gosu::milliseconds / 100 % @animation.size]
83
+ img.draw(@x - img.width / 2.0, @y - img.height / 2.0,
84
+ ZOrder::Stars, 1, 1, @color, :additive)
85
+ end
86
+ end
87
+
88
+ class GameWindow < Gosu::Window
89
+ def initialize
90
+ super(640, 480, false)
91
+ self.caption = "Gosu Tutorial Game"
92
+
93
+ @background_image = Gosu::Image.new(self, "media/Space.png", true)
94
+
95
+ @player = Player.new(self)
96
+ @player.warp(320, 240)
97
+
98
+ @star_anim = Gosu::Image::load_tiles(self, "media/Star.png", 25, 25, false)
99
+ @stars = Array.new
100
+
101
+ @font = Gosu::Font.new(self, Gosu::default_font_name, 20)
102
+ end
103
+
104
+ def update
105
+ if button_down? Gosu::Button::KbLeft or button_down? Gosu::Button::GpLeft then
106
+ @player.turn_left
107
+ end
108
+ if button_down? Gosu::Button::KbRight or button_down? Gosu::Button::GpRight then
109
+ @player.turn_right
110
+ end
111
+ if button_down? Gosu::Button::KbUp or button_down? Gosu::Button::GpButton0 then
112
+ @player.accelerate
113
+ end
114
+ @player.move
115
+ @player.collect_stars(@stars)
116
+
117
+ if rand(100) < 4 and @stars.size < 25 then
118
+ @stars.push(Star.new(@star_anim))
119
+ end
120
+ end
121
+
122
+ def draw
123
+ @background_image.draw(0, 0, ZOrder::Background)
124
+ @player.draw
125
+ @stars.each { |star| star.draw }
126
+ @font.draw("Score: #{@player.score}", 10, 10, ZOrder::UI, 1.0, 1.0, 0xffffff00)
127
+ end
128
+
129
+ def button_down(id)
130
+ if id == Gosu::Button::KbEscape then
131
+ close
132
+ end
133
+ end
134
+ end
135
+
136
+ window = GameWindow.new
137
+ window.show
Binary file
@@ -0,0 +1,25 @@
1
+ #....................................................#
2
+ #....................................................#
3
+ #.............xx......x.x............................#
4
+ #............x..x....................................#
5
+ #x....x...x..x.......#####..xxx....................x.#
6
+ #.x.........................xxx.........##.........x.#
7
+ #...............""..........###...##..........##.....#
8
+ #..##..###..##..##...................................#
9
+ #........................................xx........###
10
+ #.............................###....................#
11
+ ##....##.............................................#
12
+ #....................##....##......##....##....##....#
13
+ #.................................................x..#
14
+ #...x....##....##.......x...x.....................x..#
15
+ #.....x...............x...x...x...................x..#
16
+ #......x...##.....##.................................#
17
+ #.......x.........................................#..#
18
+ #...........##........#...#...#..#.......x...........#
19
+ #...#................................................#
20
+ #....."""".................x.......#..#####...###....#
21
+ #x....#......................##......................#
22
+ #"""""#.....#.....x..................#...............#
23
+ ##xxxx......#........................................#
24
+ ##xxxx...#####............."...""""".................#
25
+ ######"""#############################################
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gosu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.9
5
+ platform: x86-mswin32-60
6
+ authors:
7
+ - Julian Raschke
8
+ - Jan Luecker
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-04-13 00:00:00 +02:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: 2D game development library. The library features easy to use and game-friendly interfaces to 2D graphics and text (accelerated by 3D hardware), sound samples and music as well as keyboard, mouse and gamepad/joystick input. Includes demos for integration with RMagick, Chipmunk and Ruby-OpenGL.
18
+ email: julian@raschke.de
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - lib/gosu.so
27
+ - README
28
+ - LICENSE
29
+ - examples/ChipmunkIntegration.rb
30
+ - examples/CptnRuby.rb
31
+ - examples/MoreChipmunkAndRMagick.rb
32
+ - examples/OpenGLIntegration.rb
33
+ - examples/RMagickIntegration.rb
34
+ - examples/Tutorial.rb
35
+ - examples/media/Beep.wav
36
+ - examples/media/CptnRuby Gem.png
37
+ - examples/media/CptnRuby Map.txt
38
+ - examples/media/CptnRuby Tileset.png
39
+ - examples/media/CptnRuby.png
40
+ - examples/media/Earth.png
41
+ - examples/media/Explosion.wav
42
+ - examples/media/LargeStar.png
43
+ - examples/media/Sky.jpg
44
+ - examples/media/Smoke.png
45
+ - examples/media/Soldier.png
46
+ - examples/media/Space.png
47
+ - examples/media/Star.png
48
+ - examples/media/Starfighter.bmp
49
+ has_rdoc: false
50
+ homepage: http://code.google.com/p/gosu/
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.8.1
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.1.1
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: 2D game development library.
75
+ test_files: []
76
+