gosu 0.7.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING.txt +29 -0
- data/Gosu/Async.hpp +48 -0
- data/Gosu/Audio.hpp +145 -0
- data/Gosu/AutoLink.hpp +16 -0
- data/Gosu/Bitmap.hpp +85 -0
- data/Gosu/ButtonsMac.hpp +114 -0
- data/Gosu/ButtonsWin.hpp +111 -0
- data/Gosu/ButtonsX.hpp +115 -0
- data/Gosu/Color.hpp +172 -0
- data/Gosu/Directories.hpp +36 -0
- data/Gosu/Font.hpp +59 -0
- data/Gosu/Fwd.hpp +31 -0
- data/Gosu/Gosu.hpp +26 -0
- data/Gosu/Graphics.hpp +86 -0
- data/Gosu/GraphicsBase.hpp +45 -0
- data/Gosu/IO.hpp +255 -0
- data/Gosu/Image.hpp +148 -0
- data/Gosu/ImageData.hpp +45 -0
- data/Gosu/Input.hpp +116 -0
- data/Gosu/Math.hpp +95 -0
- data/Gosu/Platform.hpp +61 -0
- data/Gosu/RotFlip.hpp +116 -0
- data/Gosu/Sockets.hpp +129 -0
- data/Gosu/Text.hpp +47 -0
- data/Gosu/TextInput.hpp +57 -0
- data/Gosu/Timing.hpp +16 -0
- data/Gosu/Utility.hpp +24 -0
- data/Gosu/WinUtility.hpp +76 -0
- data/Gosu/Window.hpp +84 -0
- data/GosuImpl/Async.cpp +37 -0
- data/GosuImpl/AudioFmod.cpp +417 -0
- data/GosuImpl/AudioSDL.cpp +255 -0
- data/GosuImpl/DirectoriesMac.mm +38 -0
- data/GosuImpl/DirectoriesUnix.cpp +48 -0
- data/GosuImpl/DirectoriesWin.cpp +42 -0
- data/GosuImpl/FileUnix.cpp +100 -0
- data/GosuImpl/FileWin.cpp +83 -0
- data/GosuImpl/Graphics/Bitmap.cpp +116 -0
- data/GosuImpl/Graphics/BitmapBMP.cpp +232 -0
- data/GosuImpl/Graphics/BitmapColorKey.cpp +39 -0
- data/GosuImpl/Graphics/BitmapPNG.cpp +276 -0
- data/GosuImpl/Graphics/BitmapUtils.cpp +67 -0
- data/GosuImpl/Graphics/BlockAllocator.cpp +127 -0
- data/GosuImpl/Graphics/BlockAllocator.hpp +34 -0
- data/GosuImpl/Graphics/Color.cpp +126 -0
- data/GosuImpl/Graphics/Common.hpp +21 -0
- data/GosuImpl/Graphics/DrawOp.hpp +154 -0
- data/GosuImpl/Graphics/Font.cpp +110 -0
- data/GosuImpl/Graphics/Graphics.cpp +295 -0
- data/GosuImpl/Graphics/Image.cpp +159 -0
- data/GosuImpl/Graphics/LargeImageData.cpp +115 -0
- data/GosuImpl/Graphics/LargeImageData.hpp +37 -0
- data/GosuImpl/Graphics/RotFlip.cpp +184 -0
- data/GosuImpl/Graphics/TexChunk.cpp +77 -0
- data/GosuImpl/Graphics/TexChunk.hpp +40 -0
- data/GosuImpl/Graphics/Text.cpp +223 -0
- data/GosuImpl/Graphics/TextMac.cpp +242 -0
- data/GosuImpl/Graphics/TextPangoFT.cpp +186 -0
- data/GosuImpl/Graphics/TextWin.cpp +172 -0
- data/GosuImpl/Graphics/Texture.cpp +104 -0
- data/GosuImpl/Graphics/Texture.hpp +34 -0
- data/GosuImpl/IO.cpp +48 -0
- data/GosuImpl/InputMac.mm +677 -0
- data/GosuImpl/InputWin.cpp +444 -0
- data/GosuImpl/InputX.cpp +158 -0
- data/GosuImpl/MacUtility.hpp +48 -0
- data/GosuImpl/Math.cpp +49 -0
- data/GosuImpl/RubyGosu.swg +474 -0
- data/GosuImpl/RubyGosuStub.mm +17 -0
- data/GosuImpl/RubyGosu_DllMain.cxx +30 -0
- data/GosuImpl/RubyGosu_wrap.cxx +8521 -0
- data/GosuImpl/RubyGosu_wrap.h +31 -0
- data/GosuImpl/Sockets/CommSocket.cpp +304 -0
- data/GosuImpl/Sockets/ListenerSocket.cpp +60 -0
- data/GosuImpl/Sockets/MessageSocket.cpp +136 -0
- data/GosuImpl/Sockets/Socket.cpp +145 -0
- data/GosuImpl/Sockets/Sockets.hpp +66 -0
- data/GosuImpl/TextInputMac.mm +207 -0
- data/GosuImpl/TextInputWin.cpp +197 -0
- data/GosuImpl/TextInputX.cpp +201 -0
- data/GosuImpl/TextTTFWin.cpp +247 -0
- data/GosuImpl/TimingUnix.cpp +17 -0
- data/GosuImpl/TimingWin.cpp +28 -0
- data/GosuImpl/Utility.cpp +140 -0
- data/GosuImpl/WinMain.cpp +69 -0
- data/GosuImpl/WinUtility.cpp +137 -0
- data/GosuImpl/WindowMac.mm +466 -0
- data/GosuImpl/WindowWin.cpp +447 -0
- data/GosuImpl/WindowX.cpp +392 -0
- data/GosuImpl/X11vroot.h +118 -0
- data/README.txt +13 -0
- data/Rakefile +178 -0
- data/examples/ChipmunkIntegration.rb +275 -0
- data/examples/CptnRuby.rb +231 -0
- data/examples/MoreChipmunkAndRMagick.rb +155 -0
- data/examples/OpenGLIntegration.rb +232 -0
- data/examples/RMagickIntegration.rb +449 -0
- data/examples/TextInput.cpp +170 -0
- data/examples/TextInput.rb +139 -0
- data/examples/Tutorial.cpp +215 -0
- data/examples/Tutorial.rb +137 -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.png +0 -0
- data/examples/media/CptnRuby.png +0 -0
- data/examples/media/Cursor.png +0 -0
- data/examples/media/Earth.png +0 -0
- data/examples/media/Explosion.wav +0 -0
- data/examples/media/LargeStar.png +0 -0
- data/examples/media/Sky.jpg +0 -0
- data/examples/media/Smoke.png +0 -0
- data/examples/media/Soldier.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/linux/Makefile.in +98 -0
- data/linux/configure +5658 -0
- data/linux/configure.ac +126 -0
- data/linux/extconf.rb +11 -0
- data/mac/English.lproj/InfoPlist.strings +0 -0
- data/mac/Gosu-Info.plist +26 -0
- data/mac/Gosu.xcodeproj/project.pbxproj +1194 -0
- data/mac/RubyGosu Template-Info.plist +26 -0
- data/mac/libboost_thread_1_34_1_universal.a +0 -0
- data/mac/libboost_thread_d_1_34_1_universal.a +0 -0
- data/mac/libfmod_universal.a +0 -0
- data/mac/libpng_universal.a +0 -0
- data/mac/libz_universal.a +0 -0
- data/reference/Async_8hpp-source.html +70 -0
- data/reference/Audio_8hpp-source.html +114 -0
- data/reference/Audio_8hpp.html +50 -0
- data/reference/AutoLink_8hpp-source.html +38 -0
- data/reference/AutoLink_8hpp.html +34 -0
- data/reference/Bitmap_8hpp-source.html +85 -0
- data/reference/Bitmap_8hpp.html +58 -0
- data/reference/ButtonsMac_8hpp-source.html +133 -0
- data/reference/ButtonsWin_8hpp-source.html +133 -0
- data/reference/ButtonsX_8hpp-source.html +134 -0
- data/reference/Color_8hpp-source.html +169 -0
- data/reference/Color_8hpp.html +85 -0
- data/reference/Directories_8hpp-source.html +42 -0
- data/reference/Directories_8hpp.html +46 -0
- data/reference/Font_8hpp-source.html +65 -0
- data/reference/Font_8hpp.html +41 -0
- data/reference/Fwd_8hpp-source.html +52 -0
- data/reference/Fwd_8hpp.html +37 -0
- data/reference/Gosu_8hpp-source.html +48 -0
- data/reference/Gosu_8hpp.html +34 -0
- data/reference/GraphicsBase_8hpp-source.html +57 -0
- data/reference/GraphicsBase_8hpp.html +56 -0
- data/reference/Graphics_8hpp-source.html +96 -0
- data/reference/Graphics_8hpp.html +53 -0
- data/reference/IO_8hpp-source.html +255 -0
- data/reference/IO_8hpp.html +74 -0
- data/reference/ImageData_8hpp-source.html +62 -0
- data/reference/ImageData_8hpp.html +43 -0
- data/reference/Image_8hpp-source.html +126 -0
- data/reference/Image_8hpp.html +48 -0
- data/reference/Input_8hpp-source.html +118 -0
- data/reference/Input_8hpp.html +50 -0
- data/reference/Math_8hpp-source.html +92 -0
- data/reference/Math_8hpp.html +74 -0
- data/reference/Platform_8hpp-source.html +83 -0
- data/reference/Platform_8hpp.html +73 -0
- data/reference/RotFlip_8hpp-source.html +138 -0
- data/reference/RotFlip_8hpp.html +77 -0
- data/reference/Sockets_8hpp-source.html +130 -0
- data/reference/Sockets_8hpp.html +66 -0
- data/reference/TextInput_8hpp-source.html +64 -0
- data/reference/TextInput_8hpp.html +41 -0
- data/reference/Text_8hpp-source.html +51 -0
- data/reference/Text_8hpp.html +46 -0
- data/reference/Timing_8hpp-source.html +36 -0
- data/reference/Timing_8hpp.html +42 -0
- data/reference/Utility_8hpp-source.html +44 -0
- data/reference/Utility_8hpp.html +48 -0
- data/reference/WinUtility_8hpp-source.html +79 -0
- data/reference/WinUtility_8hpp.html +64 -0
- data/reference/Window_8hpp-source.html +91 -0
- data/reference/Window_8hpp.html +41 -0
- data/reference/annotated.html +51 -0
- data/reference/classGosu_1_1Audio-members.html +34 -0
- data/reference/classGosu_1_1Audio.html +46 -0
- data/reference/classGosu_1_1Bitmap-members.html +44 -0
- data/reference/classGosu_1_1Bitmap.html +263 -0
- data/reference/classGosu_1_1Buffer-members.html +44 -0
- data/reference/classGosu_1_1Buffer.html +78 -0
- data/reference/classGosu_1_1Buffer.png +0 -0
- data/reference/classGosu_1_1Button-members.html +36 -0
- data/reference/classGosu_1_1Button.html +143 -0
- data/reference/classGosu_1_1Color-members.html +56 -0
- data/reference/classGosu_1_1Color.html +387 -0
- data/reference/classGosu_1_1File-members.html +41 -0
- data/reference/classGosu_1_1File.html +69 -0
- data/reference/classGosu_1_1File.png +0 -0
- data/reference/classGosu_1_1Font-members.html +39 -0
- data/reference/classGosu_1_1Font.html +309 -0
- data/reference/classGosu_1_1Graphics-members.html +50 -0
- data/reference/classGosu_1_1Graphics.html +234 -0
- data/reference/classGosu_1_1Image-members.html +45 -0
- data/reference/classGosu_1_1Image.html +518 -0
- data/reference/classGosu_1_1ImageData-members.html +37 -0
- data/reference/classGosu_1_1ImageData.html +60 -0
- data/reference/classGosu_1_1Input-members.html +44 -0
- data/reference/classGosu_1_1Input.html +223 -0
- data/reference/classGosu_1_1MessageSocket-members.html +40 -0
- data/reference/classGosu_1_1MessageSocket.html +233 -0
- data/reference/classGosu_1_1Resource-members.html +39 -0
- data/reference/classGosu_1_1Resource.html +116 -0
- data/reference/classGosu_1_1Resource.png +0 -0
- data/reference/classGosu_1_1Sample-members.html +37 -0
- data/reference/classGosu_1_1Sample.html +200 -0
- data/reference/classGosu_1_1SampleInstance-members.html +38 -0
- data/reference/classGosu_1_1SampleInstance.html +169 -0
- data/reference/classGosu_1_1Song-members.html +43 -0
- data/reference/classGosu_1_1Song.html +260 -0
- data/reference/classGosu_1_1TextInput-members.html +38 -0
- data/reference/classGosu_1_1TextInput.html +121 -0
- data/reference/classGosu_1_1Window-members.html +50 -0
- data/reference/classGosu_1_1Window.html +271 -0
- data/reference/doxyfile +233 -0
- data/reference/doxygen.css +433 -0
- data/reference/doxygen.png +0 -0
- data/reference/files.html +54 -0
- data/reference/functions.html +236 -0
- data/reference/functions_enum.html +45 -0
- data/reference/functions_func.html +227 -0
- data/reference/functions_vars.html +47 -0
- data/reference/hierarchy.html +53 -0
- data/reference/index.html +26 -0
- data/reference/namespaceGosu.html +2890 -0
- data/reference/namespaceGosu_1_1Colors.html +70 -0
- data/reference/namespaceGosu_1_1Win.html +275 -0
- data/reference/namespacemembers.html +216 -0
- data/reference/namespacemembers_enum.html +52 -0
- data/reference/namespacemembers_eval.html +54 -0
- data/reference/namespacemembers_func.html +185 -0
- data/reference/namespacemembers_type.html +46 -0
- data/reference/namespacemembers_vars.html +46 -0
- data/reference/namespaces.html +35 -0
- data/reference/tab_b.gif +0 -0
- data/reference/tab_l.gif +0 -0
- data/reference/tab_r.gif +0 -0
- data/reference/tabs.css +102 -0
- data/windows/Gosu.sln +29 -0
- data/windows/Gosu.vcproj +553 -0
- data/windows/RubyGosu.vcproj +138 -0
- metadata +305 -0
data/GosuImpl/X11vroot.h
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
/*****************************************************************************/
|
2
|
+
/** Copyright 1991 by Andreas Stolcke **/
|
3
|
+
/** Copyright 1990 by Solbourne Computer Inc. **/
|
4
|
+
/** Longmont, Colorado **/
|
5
|
+
/** **/
|
6
|
+
/** All Rights Reserved **/
|
7
|
+
/** **/
|
8
|
+
/** Permission to use, copy, modify, and distribute this software and **/
|
9
|
+
/** its documentation for any purpose and without fee is hereby **/
|
10
|
+
/** granted, provided that the above copyright notice appear in all **/
|
11
|
+
/** copies and that both that copyright notice and this permis- **/
|
12
|
+
/** sion notice appear in supporting documentation, and that the **/
|
13
|
+
/** name of Solbourne not be used in advertising **/
|
14
|
+
/** in publicity pertaining to distribution of the software without **/
|
15
|
+
/** specific, written prior permission. **/
|
16
|
+
/** **/
|
17
|
+
/** ANDREAS STOLCKE AND SOLBOURNE COMPUTER INC. DISCLAIMS ALL WARRANTIES **/
|
18
|
+
/** WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF **/
|
19
|
+
/** MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ANDREAS STOLCKE **/
|
20
|
+
/** OR SOLBOURNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL **/
|
21
|
+
/** DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/
|
22
|
+
/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/
|
23
|
+
/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/
|
24
|
+
/** OR PERFORMANCE OF THIS SOFTWARE. **/
|
25
|
+
/*****************************************************************************/
|
26
|
+
/*
|
27
|
+
* vroot.h -- Virtual Root Window handling header file
|
28
|
+
*
|
29
|
+
* This header file redefines the X11 macros RootWindow and DefaultRootWindow,
|
30
|
+
* making them look for a virtual root window as provided by certain `virtual'
|
31
|
+
* window managers like swm and tvtwm. If none is found, the ordinary root
|
32
|
+
* window is returned, thus retaining backward compatibility with standard
|
33
|
+
* window managers.
|
34
|
+
* The function implementing the virtual root lookup remembers the result of
|
35
|
+
* its last invocation to avoid overhead in the case of repeated calls
|
36
|
+
* on the same display and screen arguments.
|
37
|
+
* The lookup code itself is taken from Tom LaStrange's ssetroot program.
|
38
|
+
*
|
39
|
+
* Most simple root window changing X programs can be converted to using
|
40
|
+
* virtual roots by just including
|
41
|
+
*
|
42
|
+
* #include <X11/vroot.h>
|
43
|
+
*
|
44
|
+
* after all the X11 header files. It has been tested on such popular
|
45
|
+
* X clients as xphoon, xfroot, xloadimage, and xaqua.
|
46
|
+
* It also works with the core clients xprop, xwininfo, xwd, and editres
|
47
|
+
* (and is necessary to get those clients working under tvtwm).
|
48
|
+
* It does NOT work with xsetroot; get the xsetroot replacement included in
|
49
|
+
* the tvtwm distribution instead.
|
50
|
+
*
|
51
|
+
* Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>, 9/7/90
|
52
|
+
* - replaced all NULL's with properly cast 0's, 5/6/91
|
53
|
+
* - free children list (suggested by Mark Martin <mmm@cetia.fr>), 5/16/91
|
54
|
+
* - include X11/Xlib.h and support RootWindowOfScreen, too 9/17/91
|
55
|
+
*/
|
56
|
+
|
57
|
+
#ifndef _VROOT_H_
|
58
|
+
#define _VROOT_H_
|
59
|
+
|
60
|
+
#include <X11/X.h>
|
61
|
+
#include <X11/Xatom.h>
|
62
|
+
#include <X11/Xlib.h>
|
63
|
+
|
64
|
+
static Window
|
65
|
+
VirtualRootWindowOfScreen(Screen* screen)
|
66
|
+
{
|
67
|
+
static Screen *save_screen = (Screen *)0;
|
68
|
+
static Window root = (Window)0;
|
69
|
+
|
70
|
+
if (screen != save_screen) {
|
71
|
+
Display *dpy = DisplayOfScreen(screen);
|
72
|
+
Atom __SWM_VROOT = None;
|
73
|
+
int i;
|
74
|
+
Window rootReturn, parentReturn, *children;
|
75
|
+
unsigned int numChildren;
|
76
|
+
|
77
|
+
root = RootWindowOfScreen(screen);
|
78
|
+
|
79
|
+
/* go look for a virtual root */
|
80
|
+
__SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
|
81
|
+
if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
|
82
|
+
&children, &numChildren)) {
|
83
|
+
for (i = 0; i < numChildren; i++) {
|
84
|
+
Atom actual_type;
|
85
|
+
int actual_format;
|
86
|
+
unsigned long nitems, bytesafter;
|
87
|
+
Window *newRoot = (Window *)0;
|
88
|
+
|
89
|
+
if (XGetWindowProperty(dpy, children[i],
|
90
|
+
__SWM_VROOT, 0, 1, False, XA_WINDOW,
|
91
|
+
&actual_type, &actual_format,
|
92
|
+
&nitems, &bytesafter,
|
93
|
+
(unsigned char **) &newRoot) == Success
|
94
|
+
&& newRoot) {
|
95
|
+
root = *newRoot;
|
96
|
+
break;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
if (children)
|
100
|
+
XFree((char *)children);
|
101
|
+
}
|
102
|
+
|
103
|
+
save_screen = screen;
|
104
|
+
}
|
105
|
+
|
106
|
+
return root;
|
107
|
+
}
|
108
|
+
|
109
|
+
#undef RootWindowOfScreen
|
110
|
+
#define RootWindowOfScreen(s) VirtualRootWindowOfScreen(s)
|
111
|
+
|
112
|
+
#undef RootWindow
|
113
|
+
#define RootWindow(dpy,screen) VirtualRootWindowOfScreen(ScreenOfDisplay(dpy,screen))
|
114
|
+
|
115
|
+
#undef DefaultRootWindow
|
116
|
+
#define DefaultRootWindow(dpy) VirtualRootWindowOfScreen(DefaultScreenOfDisplay(dpy))
|
117
|
+
|
118
|
+
#endif /* _VROOT_H_ */
|
data/README.txt
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 doing 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!
|
data/Rakefile
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'ftools'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
GOSU_VERSION = ENV['GOSU_RELEASE_VERSION']
|
5
|
+
throw "GOSU_RELEASE_VERSION must be set" if GOSU_VERSION.nil?
|
6
|
+
|
7
|
+
COMMON_FILES = FileList[
|
8
|
+
'COPYING.txt',
|
9
|
+
'README.txt',
|
10
|
+
]
|
11
|
+
|
12
|
+
COMMON_CPP_FILES = COMMON_FILES + FileList[
|
13
|
+
'examples/*.cpp',
|
14
|
+
'examples/media/*',
|
15
|
+
'reference/**/*',
|
16
|
+
]
|
17
|
+
|
18
|
+
COMMON_RUBY_FILES = COMMON_FILES + FileList[
|
19
|
+
'examples/*.rb',
|
20
|
+
'examples/media/*',
|
21
|
+
]
|
22
|
+
|
23
|
+
SOURCE_FILES = COMMON_CPP_FILES + COMMON_RUBY_FILES + FileList[
|
24
|
+
'Rakefile',
|
25
|
+
'Gosu/**/*', 'GosuImpl/**/*',
|
26
|
+
'linux/configure', 'linux/configure.ac', 'linux/Makefile.in',
|
27
|
+
'mac/Gosu.xcodeproj/**/*', 'mac/*.a', 'mac/English.lproj/**/*',
|
28
|
+
'mac/Gosu-Info.plist', 'mac/RubyGosu Template-Info.plist',
|
29
|
+
'windows/*.*',
|
30
|
+
]
|
31
|
+
SOURCE_FILES.uniq!
|
32
|
+
|
33
|
+
# Sets everything except 'platform' and 'files'.
|
34
|
+
def apply_gemspec_defaults s
|
35
|
+
#### Basic information.
|
36
|
+
s.name = 'gosu'
|
37
|
+
s.version = GOSU_VERSION
|
38
|
+
s.summary = '2D game development library.'
|
39
|
+
s.description = <<EOS
|
40
|
+
2D game development library.
|
41
|
+
|
42
|
+
Gosu features easy to use and game-friendly interfaces to 2D graphics
|
43
|
+
and text (accelerated by 3D hardware), sound samples and music as well as
|
44
|
+
keyboard, mouse and gamepad/joystick input.
|
45
|
+
|
46
|
+
Also includes demos for integration with RMagick, Chipmunk and Ruby-OpenGL.
|
47
|
+
EOS
|
48
|
+
s.authors = ['Julian Raschke', 'Jan Luecker']
|
49
|
+
s.date = Time.now.strftime '%Y-%m-%d'
|
50
|
+
s.email = 'julian@raschke.de'
|
51
|
+
s.homepage = 'http://code.google.com/p/gosu/'
|
52
|
+
s.require_paths = ['lib']
|
53
|
+
s.required_ruby_version = Gem::Requirement.new('>= 1.8.2')
|
54
|
+
s.summary = '2D game development library.'
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Build C++ reference with doxygen"
|
58
|
+
task :cpp_docs do
|
59
|
+
sh "cd reference && doxygen"
|
60
|
+
end
|
61
|
+
|
62
|
+
Rake.application.in_namespace :mac do
|
63
|
+
desc "Build Gosu.framework"
|
64
|
+
task :cpp => :cpp_docs do
|
65
|
+
sh "cd mac && xcodebuild -project Gosu.xcodeproj -target Gosu -configuration Release"
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Build lib/gosu.bundle and RubyGosu Deployment Template.app"
|
69
|
+
task :ruby do
|
70
|
+
sh "cd mac && xcodebuild -project Gosu.xcodeproj -target 'RubyGosu Core' -configuration Release"
|
71
|
+
sh "cd mac && xcodebuild -project Gosu.xcodeproj -target 'RubyGosu Deployment Template' -configuration Release"
|
72
|
+
end
|
73
|
+
|
74
|
+
MAC_ARCHIVE_FILENAME = "public/gosu-mac-#{GOSU_VERSION}.tar.gz"
|
75
|
+
|
76
|
+
desc "Build the archive #{MAC_ARCHIVE_FILENAME}"
|
77
|
+
task :archive => [:cpp, :ruby] do
|
78
|
+
files = COMMON_CPP_FILES + COMMON_RUBY_FILES + ['lib/gosu.bundle'] +
|
79
|
+
FileList['Gosu.framework/**/*', 'RubyGosu Deployment Template.app/**/*']
|
80
|
+
sh "tar -czf #{MAC_ARCHIVE_FILENAME} #{files.map { |filename| "'#{filename}'" }.join(' ')}"
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "Releases the archive #{MAC_ARCHIVE_FILENAME} on GoogleCode"
|
84
|
+
task :release => :archive do
|
85
|
+
sh "./googlecode_upload.py --summary=\"Gosu #{GOSU_VERSION}, compiled for Mac OS X (C++ & Ruby)\"" +
|
86
|
+
" --project=gosu --user=julianraschke --labels=\"Featured,Type-Archive,OpSys-OSX\" #{MAC_ARCHIVE_FILENAME}"
|
87
|
+
end
|
88
|
+
|
89
|
+
task :gem => :ruby
|
90
|
+
|
91
|
+
MAC_SPEC = Gem::Specification.new do |s|
|
92
|
+
apply_gemspec_defaults s
|
93
|
+
s.platform = 'universal-darwin'
|
94
|
+
s.files = COMMON_RUBY_FILES + ['lib/gosu.bundle']
|
95
|
+
end
|
96
|
+
Rake::GemPackageTask.new(MAC_SPEC) { |t| t.package_dir = 'public/mac_gem' }
|
97
|
+
end
|
98
|
+
|
99
|
+
Rake.application.in_namespace :win do
|
100
|
+
WINDOWS_CPP_ARCHIVE_FILENAME = "public/gosu-windows-cpp-#{GOSU_VERSION}.zip"
|
101
|
+
|
102
|
+
desc "Build the archive #{WINDOWS_CPP_ARCHIVE_FILENAME}"
|
103
|
+
task :cpp_archive do #=> [:cpp] do
|
104
|
+
files = COMMON_CPP_FILES + ['lib/Gosu.lib', 'lib/GosuDebug.lib', 'lib/fmod.dll']
|
105
|
+
sh "zip #{WINDOWS_CPP_ARCHIVE_FILENAME} #{files.map { |filename| "'#{filename}'" }.join(' ')}"
|
106
|
+
end
|
107
|
+
|
108
|
+
desc "Releases the archive #{WINDOWS_CPP_ARCHIVE_FILENAME} on GoogleCode"
|
109
|
+
task :cpp_release => :cpp_archive do
|
110
|
+
sh "./googlecode_upload.py --summary=\"Gosu #{GOSU_VERSION}, compiled for 32-bit Windows (C++)\"" +
|
111
|
+
" --project=gosu --user=julianraschke --labels=\"Featured,Type-Archive,OpSys-Windows\" #{WINDOWS_CPP_ARCHIVE_FILENAME}"
|
112
|
+
end
|
113
|
+
|
114
|
+
WINDOWS_RUBY_ARCHIVE_FILENAME = "public/gosu-windows-ruby-#{GOSU_VERSION}.zip"
|
115
|
+
|
116
|
+
desc "Build the archive #{WINDOWS_RUBY_ARCHIVE_FILENAME}"
|
117
|
+
task :ruby_archive do #=> [:ruby] do
|
118
|
+
files = COMMON_RUBY_FILES + ['lib/gosu.so', 'lib/fmod.dll']
|
119
|
+
sh "zip #{WINDOWS_RUBY_ARCHIVE_FILENAME} #{files.map { |filename| "'#{filename}'" }.join(' ')}"
|
120
|
+
end
|
121
|
+
|
122
|
+
desc "Releases the archive #{WINDOWS_RUBY_ARCHIVE_FILENAME} on GoogleCode"
|
123
|
+
task :ruby_release => :ruby_archive do
|
124
|
+
sh "./googlecode_upload.py --summary=\"Gosu #{GOSU_VERSION}, compiled for 32-bit Windows (Ruby)\"" +
|
125
|
+
" --project=gosu --user=julianraschke --labels=\"Featured,Type-Archive,OpSys-Windows\" #{WINDOWS_RUBY_ARCHIVE_FILENAME}"
|
126
|
+
end
|
127
|
+
|
128
|
+
desc "Release both #{WINDOWS_CPP_ARCHIVE_FILENAME} and #{WINDOWS_RUBY_ARCHIVE_FILENAME}"
|
129
|
+
task :release => [:cpp_release, :ruby_release]
|
130
|
+
|
131
|
+
WINDOWS_SPEC = Gem::Specification.new do |s|
|
132
|
+
apply_gemspec_defaults s
|
133
|
+
s.platform = 'x86-mswin32-60'
|
134
|
+
s.files = COMMON_RUBY_FILES + ['lib/gosu.so', 'lib/fmod.dll']
|
135
|
+
end
|
136
|
+
Rake::GemPackageTask.new(WINDOWS_SPEC) { |t| t.package_dir = 'public/windows_gem' }
|
137
|
+
end
|
138
|
+
|
139
|
+
Rake.application.in_namespace :linux do
|
140
|
+
LINUX_ARCHIVE_FILENAME = "public/gosu-source-#{GOSU_VERSION}.tar.gz"
|
141
|
+
|
142
|
+
desc "Build the archive #{LINUX_ARCHIVE_FILENAME}"
|
143
|
+
task :archive => [:cpp_docs] do
|
144
|
+
files = SOURCE_FILES
|
145
|
+
sh "cd .. && tar -czf gosu/#{LINUX_ARCHIVE_FILENAME} #{files.map { |filename| "'gosu/#{filename}'" }.join(' ')}"
|
146
|
+
end
|
147
|
+
|
148
|
+
desc "Releases the archive #{LINUX_ARCHIVE_FILENAME} on GoogleCode"
|
149
|
+
task :release => :archive do
|
150
|
+
sh "./googlecode_upload.py --summary=\"Gosu #{GOSU_VERSION} source package (to compile on Linux)\"" +
|
151
|
+
" --project=gosu --user=julianraschke --labels=\"Featured,Type-Archive,OpSys-All\" #{LINUX_ARCHIVE_FILENAME}"
|
152
|
+
end
|
153
|
+
|
154
|
+
LINUX_SPEC = Gem::Specification.new do |s|
|
155
|
+
apply_gemspec_defaults s
|
156
|
+
s.platform = 'ruby'
|
157
|
+
s.files = SOURCE_FILES + [ 'linux/extconf.rb' ]
|
158
|
+
s.extensions = [ 'linux/extconf.rb' ]
|
159
|
+
s.require_path = 'lib'
|
160
|
+
s.requirements = ['g++',
|
161
|
+
'pkg-config',
|
162
|
+
'libgl',
|
163
|
+
'X11 includes and libraries',
|
164
|
+
'pangoft2',
|
165
|
+
'fmod or SDL_mixer',
|
166
|
+
|
167
|
+
"(Packages for Debian/Ubuntu:\n" +
|
168
|
+
' g++ pkg-config ruby-dev xorg-dev' +
|
169
|
+
' libsdl-mixer1.2-dev libgl1-mesa-dev' +
|
170
|
+
' libpango1.0-dev' +
|
171
|
+
"\n)"]
|
172
|
+
end
|
173
|
+
|
174
|
+
Rake::GemPackageTask.new(LINUX_SPEC) { |t| t.package_dir = 'public/linux_gem' }
|
175
|
+
end
|
176
|
+
|
177
|
+
# TODO? Gem upload to RubyForge: http://nubyonrails.com/articles/tutorial-publishing-rubygems-with-hoe
|
178
|
+
|
@@ -0,0 +1,275 @@
|
|
1
|
+
## File: ChipmunkIntegration.rb
|
2
|
+
## Author: Dirk Johnson
|
3
|
+
## Version: 1.0.0
|
4
|
+
## Date: 2007-10-05
|
5
|
+
## License: Same as for Gosu (MIT)
|
6
|
+
## Comments: Based on the Gosu Ruby Tutorial, but incorporating the Chipmunk Physics Engine
|
7
|
+
## See http://code.google.com/p/gosu/wiki/RubyChipmunkIntegration for the accompanying text.
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'gosu'
|
11
|
+
require 'chipmunk'
|
12
|
+
|
13
|
+
SCREEN_WIDTH = 640
|
14
|
+
SCREEN_HEIGHT = 480
|
15
|
+
|
16
|
+
# The number of steps to process every Gosu update
|
17
|
+
# The Player ship can get going so fast as to "move through" a
|
18
|
+
# star without triggering a collision; an increased number of
|
19
|
+
# Chipmunk step calls per update will effectively avoid this issue
|
20
|
+
SUBSTEPS = 6
|
21
|
+
|
22
|
+
# Convenience method for converting from radians to a Vec2 vector.
|
23
|
+
class Numeric
|
24
|
+
def radians_to_vec2
|
25
|
+
CP::Vec2.new(Math::cos(self), Math::sin(self))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Layering of sprites
|
30
|
+
module ZOrder
|
31
|
+
Background, Stars, Player, UI = *0..3
|
32
|
+
end
|
33
|
+
|
34
|
+
# This game will have one Player in the form of a ship
|
35
|
+
class Player
|
36
|
+
attr_reader :shape
|
37
|
+
|
38
|
+
def initialize(window, shape)
|
39
|
+
@image = Gosu::Image.new(window, "media/Starfighter.bmp", false)
|
40
|
+
@shape = shape
|
41
|
+
@shape.body.p = CP::Vec2.new(0.0, 0.0) # position
|
42
|
+
@shape.body.v = CP::Vec2.new(0.0, 0.0) # velocity
|
43
|
+
|
44
|
+
# Keep in mind that down the screen is positive y, which means that PI/2 radians,
|
45
|
+
# which you might consider the top in the traditional Trig unit circle sense is actually
|
46
|
+
# the bottom; thus 3PI/2 is the top
|
47
|
+
@shape.body.a = (3*Math::PI/2.0) # angle in radians; faces towards top of screen
|
48
|
+
end
|
49
|
+
|
50
|
+
# Directly set the position of our Player
|
51
|
+
def warp(vect)
|
52
|
+
@shape.body.p = vect
|
53
|
+
end
|
54
|
+
|
55
|
+
# Apply negative Torque; Chipmunk will do the rest
|
56
|
+
# SUBSTEPS is used as a divisor to keep turning rate constant
|
57
|
+
# even if the number of steps per update are adjusted
|
58
|
+
def turn_left
|
59
|
+
@shape.body.t -= 400.0/SUBSTEPS
|
60
|
+
end
|
61
|
+
|
62
|
+
# Apply positive Torque; Chipmunk will do the rest
|
63
|
+
# SUBSTEPS is used as a divisor to keep turning rate constant
|
64
|
+
# even if the number of steps per update are adjusted
|
65
|
+
def turn_right
|
66
|
+
@shape.body.t += 400.0/SUBSTEPS
|
67
|
+
end
|
68
|
+
|
69
|
+
# Apply forward force; Chipmunk will do the rest
|
70
|
+
# SUBSTEPS is used as a divisor to keep acceleration rate constant
|
71
|
+
# even if the number of steps per update are adjusted
|
72
|
+
# Here we must convert the angle (facing) of the body into
|
73
|
+
# forward momentum by creating a vector in the direction of the facing
|
74
|
+
# and with a magnitude representing the force we want to apply
|
75
|
+
def accelerate
|
76
|
+
@shape.body.apply_force((@shape.body.a.radians_to_vec2 * (3000.0/SUBSTEPS)), CP::Vec2.new(0.0, 0.0))
|
77
|
+
end
|
78
|
+
|
79
|
+
# Apply even more forward force
|
80
|
+
# See accelerate for more details
|
81
|
+
def boost
|
82
|
+
@shape.body.apply_force((@shape.body.a.radians_to_vec2 * (3000.0)), CP::Vec2.new(0.0, 0.0))
|
83
|
+
end
|
84
|
+
|
85
|
+
# Apply reverse force
|
86
|
+
# See accelerate for more details
|
87
|
+
def reverse
|
88
|
+
@shape.body.apply_force(-(@shape.body.a.radians_to_vec2 * (1000.0/SUBSTEPS)), CP::Vec2.new(0.0, 0.0))
|
89
|
+
end
|
90
|
+
|
91
|
+
# Wrap to the other side of the screen when we fly off the edge
|
92
|
+
def validate_position
|
93
|
+
l_position = CP::Vec2.new(@shape.body.p.x % SCREEN_WIDTH, @shape.body.p.y % SCREEN_HEIGHT)
|
94
|
+
@shape.body.p = l_position
|
95
|
+
end
|
96
|
+
|
97
|
+
def draw
|
98
|
+
@image.draw_rot(@shape.body.p.x, @shape.body.p.y, ZOrder::Player, @shape.body.a.radians_to_gosu)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# See how simple our Star is?
|
103
|
+
# Of course... it just sits around and looks good...
|
104
|
+
class Star
|
105
|
+
attr_reader :shape
|
106
|
+
|
107
|
+
def initialize(animation, shape)
|
108
|
+
@animation = animation
|
109
|
+
@color = Gosu::Color.new(0xff000000)
|
110
|
+
@color.red = rand(255 - 40) + 40
|
111
|
+
@color.green = rand(255 - 40) + 40
|
112
|
+
@color.blue = rand(255 - 40) + 40
|
113
|
+
@shape = shape
|
114
|
+
@shape.body.p = CP::Vec2.new(rand * SCREEN_WIDTH, rand * SCREEN_HEIGHT) # position
|
115
|
+
@shape.body.v = CP::Vec2.new(0.0, 0.0) # velocity
|
116
|
+
@shape.body.a = (3*Math::PI/2.0) # angle in radians; faces towards top of screen
|
117
|
+
end
|
118
|
+
|
119
|
+
def draw
|
120
|
+
img = @animation[Gosu::milliseconds / 100 % @animation.size];
|
121
|
+
img.draw(@shape.body.p.x - img.width / 2.0, @shape.body.p.y - img.height / 2.0, ZOrder::Stars, 1, 1, @color, :additive)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# The Gosu::Window is always the "environment" of our game
|
126
|
+
# It also provides the pulse of our game
|
127
|
+
class GameWindow < Gosu::Window
|
128
|
+
def initialize
|
129
|
+
super(SCREEN_WIDTH, SCREEN_HEIGHT, false, 16)
|
130
|
+
self.caption = "Gosu & Chipmunk Integration Demo"
|
131
|
+
@background_image = Gosu::Image.new(self, "media/Space.png", true)
|
132
|
+
|
133
|
+
# Put the beep here, as it is the environment now that determines collision
|
134
|
+
@beep = Gosu::Sample.new(self, "media/Beep.wav")
|
135
|
+
|
136
|
+
# Put the score here, as it is the environment that tracks this now
|
137
|
+
@score = 0
|
138
|
+
@font = Gosu::Font.new(self, Gosu::default_font_name, 20)
|
139
|
+
|
140
|
+
# Time increment over which to apply a physics "step" ("delta t")
|
141
|
+
@dt = (1.0/60.0)
|
142
|
+
|
143
|
+
# Create our Space and set its damping
|
144
|
+
# A damping of 0.8 causes the ship bleed off its force and torque over time
|
145
|
+
# This is not realistic behavior in a vacuum of space, but it gives the game
|
146
|
+
# the feel I'd like in this situation
|
147
|
+
@space = CP::Space.new
|
148
|
+
@space.damping = 0.8
|
149
|
+
|
150
|
+
# Create the Body for the Player
|
151
|
+
body = CP::Body.new(10.0, 150.0)
|
152
|
+
|
153
|
+
# In order to create a shape, we must first define it
|
154
|
+
# Chipmunk defines 3 types of Shapes: Segments, Circles and Polys
|
155
|
+
# We'll use s simple, 4 sided Poly for our Player (ship)
|
156
|
+
# You need to define the vectors so that the "top" of the Shape is towards 0 radians (the right)
|
157
|
+
shape_array = [CP::Vec2.new(-25.0, -25.0), CP::Vec2.new(-25.0, 25.0), CP::Vec2.new(25.0, 1.0), CP::Vec2.new(25.0, -1.0)]
|
158
|
+
shape = CP::Shape::Poly.new(body, shape_array, CP::Vec2.new(0,0))
|
159
|
+
|
160
|
+
# The collision_type of a shape allows us to set up special collision behavior
|
161
|
+
# based on these types. The actual value for the collision_type is arbitrary
|
162
|
+
# and, as long as it is consistent, will work for us; of course, it helps to have it make sense
|
163
|
+
shape.collision_type = :ship
|
164
|
+
|
165
|
+
@space.add_body(body)
|
166
|
+
@space.add_shape(shape)
|
167
|
+
|
168
|
+
@player = Player.new(self, shape)
|
169
|
+
@player.warp(CP::Vec2.new(320, 240)) # move to the center of the window
|
170
|
+
|
171
|
+
@star_anim = Gosu::Image::load_tiles(self, "media/Star.png", 25, 25, false)
|
172
|
+
@stars = Array.new
|
173
|
+
|
174
|
+
# Here we define what is supposed to happen when a Player (ship) collides with a Star
|
175
|
+
# I create a @remove_shapes array because we cannot remove either Shapes or Bodies
|
176
|
+
# from Space within a collision closure, rather, we have to wait till the closure
|
177
|
+
# is through executing, then we can remove the Shapes and Bodies
|
178
|
+
# In this case, the Shapes and the Bodies they own are removed in the Gosu::Window.update phase
|
179
|
+
# by iterating over the @remove_shapes array
|
180
|
+
# Also note that both Shapes involved in the collision are passed into the closure
|
181
|
+
# in the same order that their collision_types are defined in the add_collision_func call
|
182
|
+
@remove_shapes = []
|
183
|
+
@space.add_collision_func(:ship, :star) do |ship_shape, star_shape|
|
184
|
+
@score += 10
|
185
|
+
@beep.play
|
186
|
+
@remove_shapes << star_shape
|
187
|
+
end
|
188
|
+
|
189
|
+
# Here we tell Space that we don't want one star bumping into another
|
190
|
+
# The reason we need to do this is because when the Player hits a Star,
|
191
|
+
# the Star will travel until it is removed in the update cycle below
|
192
|
+
# which means it may collide and therefore push other Stars
|
193
|
+
# To see the effect, remove this line and play the game, every once in a while
|
194
|
+
# you'll see a Star moving
|
195
|
+
@space.add_collision_func(:star, :star, &nil)
|
196
|
+
end
|
197
|
+
|
198
|
+
def update
|
199
|
+
# Step the physics environment SUBSTEPS times each update
|
200
|
+
SUBSTEPS.times do
|
201
|
+
# This iterator makes an assumption of one Shape per Star making it safe to remove
|
202
|
+
# each Shape's Body as it comes up
|
203
|
+
# If our Stars had multiple Shapes, as would be required if we were to meticulously
|
204
|
+
# define their true boundaries, we couldn't do this as we would remove the Body
|
205
|
+
# multiple times
|
206
|
+
# We would probably solve this by creating a separate @remove_bodies array to remove the Bodies
|
207
|
+
# of the Stars that were gathered by the Player
|
208
|
+
@remove_shapes.each do |shape|
|
209
|
+
@stars.delete_if { |star| star.shape == shape }
|
210
|
+
@space.remove_body(shape.body)
|
211
|
+
@space.remove_shape(shape)
|
212
|
+
end
|
213
|
+
@remove_shapes.clear # clear out the shapes for next pass
|
214
|
+
|
215
|
+
# When a force or torque is set on a Body, it is cumulative
|
216
|
+
# This means that the force you applied last SUBSTEP will compound with the
|
217
|
+
# force applied this SUBSTEP; which is probably not the behavior you want
|
218
|
+
# We reset the forces on the Player each SUBSTEP for this reason
|
219
|
+
@player.shape.body.reset_forces
|
220
|
+
|
221
|
+
# Wrap around the screen to the other side
|
222
|
+
@player.validate_position
|
223
|
+
|
224
|
+
# Check keyboard
|
225
|
+
if button_down? Gosu::Button::KbLeft
|
226
|
+
@player.turn_left
|
227
|
+
end
|
228
|
+
if button_down? Gosu::Button::KbRight
|
229
|
+
@player.turn_right
|
230
|
+
end
|
231
|
+
|
232
|
+
if button_down? Gosu::Button::KbUp
|
233
|
+
if ( (button_down? Gosu::Button::KbRightShift) || (button_down? Gosu::Button::KbLeftShift) )
|
234
|
+
@player.boost
|
235
|
+
else
|
236
|
+
@player.accelerate
|
237
|
+
end
|
238
|
+
elsif button_down? Gosu::Button::KbDown
|
239
|
+
@player.reverse
|
240
|
+
end
|
241
|
+
|
242
|
+
# Perform the step over @dt period of time
|
243
|
+
# For best performance @dt should remain consistent for the game
|
244
|
+
@space.step(@dt)
|
245
|
+
end
|
246
|
+
|
247
|
+
# Each update (not SUBSTEP) we see if we need to add more Stars
|
248
|
+
if rand(100) < 4 and @stars.size < 25 then
|
249
|
+
body = CP::Body.new(0.0001, 0.0001)
|
250
|
+
shape = CP::Shape::Circle.new(body, 25/2, CP::Vec2.new(0.0, 0.0))
|
251
|
+
shape.collision_type = :star
|
252
|
+
|
253
|
+
@space.add_body(body)
|
254
|
+
@space.add_shape(shape)
|
255
|
+
|
256
|
+
@stars.push(Star.new(@star_anim, shape))
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def draw
|
261
|
+
@background_image.draw(0, 0, ZOrder::Background)
|
262
|
+
@player.draw
|
263
|
+
@stars.each { |star| star.draw }
|
264
|
+
@font.draw("Score: #{@score}", 10, 10, ZOrder::UI, 1.0, 1.0, 0xffffff00)
|
265
|
+
end
|
266
|
+
|
267
|
+
def button_down(id)
|
268
|
+
if id == Gosu::Button::KbEscape
|
269
|
+
close
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
window = GameWindow.new
|
275
|
+
window.show
|