gosu 0.7.3-universal-darwin8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +23 -0
- data/README +13 -0
- data/examples/Tutorial.rb +130 -0
- data/examples/media/Beep.wav +0 -0
- data/examples/media/CptnRuby Gem.png +0 -0
- data/examples/media/CptnRuby Map.txt +25 -0
- data/examples/media/CptnRuby Tileset.bmp +0 -0
- data/examples/media/CptnRuby.png +0 -0
- data/examples/media/Space.png +0 -0
- data/examples/media/Star.png +0 -0
- data/examples/media/Starfighter.bmp +0 -0
- data/lib/gosu.bundle +0 -0
- metadata +54 -0
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (C) 2004-2007 Julian Raschke, Jan Lücker and all contributors.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
copy of this software and associated documentation files (the "Software"),
|
5
|
+
to deal in the Software without restriction, including without limitation
|
6
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
7
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
8
|
+
Software is furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
19
|
+
DEALINGS IN THE SOFTWARE.
|
20
|
+
|
21
|
+
Julian Raschke julian@raschke.de
|
22
|
+
Jan Lücker jan.luecker@gmx.de
|
23
|
+
http://code.google.com/p/gosu/
|
data/README
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Moin moin, dear Gosu user!
|
2
|
+
|
3
|
+
* The latest documentation on how to install/set up Gosu can be found on:
|
4
|
+
http://code.google.com/p/gosu/wiki/DocsOverview
|
5
|
+
|
6
|
+
* Try completing to the tutorial there if you don't know how to start out!
|
7
|
+
|
8
|
+
* If you have any questions or feedback,
|
9
|
+
leave a comment on one of Gosu's wiki page,
|
10
|
+
mail me at julian@raschke.de,
|
11
|
+
or try your luck in #gosu on irc.freenode.org.
|
12
|
+
|
13
|
+
We hope you'll enjoy using Gosu!
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'gosu'
|
2
|
+
|
3
|
+
module ZOrder
|
4
|
+
Background, Stars, Player, UI = *0..3
|
5
|
+
end
|
6
|
+
|
7
|
+
class Player
|
8
|
+
attr_reader :score
|
9
|
+
|
10
|
+
def initialize(window)
|
11
|
+
@image = Gosu::Image.new(window, "media/Starfighter.bmp", false)
|
12
|
+
@beep = Gosu::Sample.new(window, "media/Beep.wav")
|
13
|
+
@x = @y = @vel_x = @vel_y = @angle = 0.0
|
14
|
+
@score = 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def warp(x, y)
|
18
|
+
@x, @y = x, y
|
19
|
+
end
|
20
|
+
|
21
|
+
def turn_left
|
22
|
+
@angle -= 4.5
|
23
|
+
end
|
24
|
+
|
25
|
+
def turn_right
|
26
|
+
@angle += 4.5
|
27
|
+
end
|
28
|
+
|
29
|
+
def accelerate
|
30
|
+
@vel_x += Gosu::offset_x(@angle, 0.5)
|
31
|
+
@vel_y += Gosu::offset_y(@angle, 0.5)
|
32
|
+
end
|
33
|
+
|
34
|
+
def move
|
35
|
+
@x += @vel_x
|
36
|
+
@y += @vel_y
|
37
|
+
@x %= 640
|
38
|
+
@y %= 480
|
39
|
+
|
40
|
+
@vel_x *= 0.95
|
41
|
+
@vel_y *= 0.95
|
42
|
+
end
|
43
|
+
|
44
|
+
def draw
|
45
|
+
@image.draw_rot(@x, @y, ZOrder::Player, @angle)
|
46
|
+
end
|
47
|
+
|
48
|
+
def collect_stars(stars)
|
49
|
+
stars.reject! do |star|
|
50
|
+
if Gosu::distance(@x, @y, star.x, star.y) < 35 then
|
51
|
+
@score += 10
|
52
|
+
@beep.play
|
53
|
+
true
|
54
|
+
else
|
55
|
+
false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Star
|
62
|
+
attr_reader :x, :y
|
63
|
+
|
64
|
+
def initialize(animation)
|
65
|
+
@animation = animation
|
66
|
+
@color = Gosu::Color.new(0xff000000)
|
67
|
+
@color.red = rand(255 - 40) + 40
|
68
|
+
@color.green = rand(255 - 40) + 40
|
69
|
+
@color.blue = rand(255 - 40) + 40
|
70
|
+
@x = rand * 640
|
71
|
+
@y = rand * 480
|
72
|
+
end
|
73
|
+
|
74
|
+
def draw
|
75
|
+
img = @animation[Gosu::milliseconds / 100 % @animation.size];
|
76
|
+
img.draw(@x - img.width / 2.0, @y - img.height / 2.0,
|
77
|
+
ZOrder::Stars, 1, 1, @color, :additive)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class GameWindow < Gosu::Window
|
82
|
+
def initialize
|
83
|
+
super(640, 480, false, 20)
|
84
|
+
self.caption = "Gosu Tutorial Game"
|
85
|
+
|
86
|
+
@background_image = Gosu::Image.new(self, "media/Space.png", true)
|
87
|
+
|
88
|
+
@player = Player.new(self)
|
89
|
+
@player.warp(320, 240)
|
90
|
+
|
91
|
+
@star_anim = Gosu::Image::load_tiles(self, "media/Star.png", 25, 25, false)
|
92
|
+
@stars = Array.new
|
93
|
+
|
94
|
+
@font = Gosu::Font.new(self, Gosu::default_font_name, 20)
|
95
|
+
end
|
96
|
+
|
97
|
+
def update
|
98
|
+
if button_down? Gosu::Button::KbLeft or button_down? Gosu::Button::GpLeft then
|
99
|
+
@player.turn_left
|
100
|
+
end
|
101
|
+
if button_down? Gosu::Button::KbRight or button_down? Gosu::Button::GpRight then
|
102
|
+
@player.turn_right
|
103
|
+
end
|
104
|
+
if button_down? Gosu::Button::KbUp or button_down? Gosu::Button::GpButton0 then
|
105
|
+
@player.accelerate
|
106
|
+
end
|
107
|
+
@player.move
|
108
|
+
@player.collect_stars(@stars)
|
109
|
+
|
110
|
+
if rand(100) < 4 and @stars.size < 25 then
|
111
|
+
@stars.push(Star.new(@star_anim))
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def draw
|
116
|
+
@background_image.draw(0, 0, ZOrder::Background)
|
117
|
+
@player.draw
|
118
|
+
@stars.each { |star| star.draw }
|
119
|
+
@font.draw("Score: #{@player.score}", 10, 10, ZOrder::UI, 1.0, 1.0, 0xffffff00)
|
120
|
+
end
|
121
|
+
|
122
|
+
def button_down(id)
|
123
|
+
if id == Gosu::Button::KbEscape
|
124
|
+
close
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
window = GameWindow.new
|
130
|
+
window.show
|
Binary file
|
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
|
data/lib/gosu.bundle
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: gosu
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.7.3
|
7
|
+
date: 2007-08-10 00:00:00 +02:00
|
8
|
+
summary: 2D game development library.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: julian@raschke.de
|
12
|
+
homepage: http://code.google.com/p/gosu/
|
13
|
+
rubyforge_project:
|
14
|
+
description: "2D game development library. The library features easy to use and game-friendly
|
15
|
+
interfaces to 2D graphics and text (accelerated by 3D hardware), sound samples
|
16
|
+
and music as well as keyboard, mouse and gamepad/joystick input."
|
17
|
+
autorequire:
|
18
|
+
default_executable:
|
19
|
+
bindir: bin
|
20
|
+
has_rdoc: false
|
21
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
22
|
+
requirements:
|
23
|
+
-
|
24
|
+
- ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.1
|
27
|
+
version:
|
28
|
+
platform: universal-darwin8.0
|
29
|
+
signing_key:
|
30
|
+
cert_chain:
|
31
|
+
post_install_message:
|
32
|
+
authors:
|
33
|
+
- Julian Raschke
|
34
|
+
- Jan Luecker
|
35
|
+
files:
|
36
|
+
- examples/media/Beep.wav
|
37
|
+
- examples/media/CptnRuby Gem.png
|
38
|
+
- examples/media/CptnRuby Map.txt
|
39
|
+
- examples/media/CptnRuby Tileset.bmp
|
40
|
+
- examples/media/CptnRuby.png
|
41
|
+
- examples/media/Space.png
|
42
|
+
- examples/media/Star.png
|
43
|
+
- examples/media/Starfighter.bmp
|
44
|
+
- examples/Tutorial.rb
|
45
|
+
- lib/gosu.bundle
|
46
|
+
- README
|
47
|
+
- LICENSE
|
48
|
+
test_files: []
|
49
|
+
rdoc_options: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
requirements: []
|
54
|
+
dependencies: []
|