rubygame 2.2.0-i586-linux
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.
- data/CREDITS +60 -0
- data/LICENSE +504 -0
- data/NEWS +201 -0
- data/README +139 -0
- data/ROADMAP +43 -0
- data/Rakefile +409 -0
- data/doc/extended_readme.rdoc +49 -0
- data/doc/getting_started.rdoc +47 -0
- data/doc/macosx_install.rdoc +70 -0
- data/doc/windows_install.rdoc +123 -0
- data/ext/rubygame/MANIFEST +25 -0
- data/ext/rubygame/rubygame_core.so +0 -0
- data/ext/rubygame/rubygame_event.c +644 -0
- data/ext/rubygame/rubygame_event.h +48 -0
- data/ext/rubygame/rubygame_event.o +0 -0
- data/ext/rubygame/rubygame_gfx.c +942 -0
- data/ext/rubygame/rubygame_gfx.h +101 -0
- data/ext/rubygame/rubygame_gfx.o +0 -0
- data/ext/rubygame/rubygame_gfx.so +0 -0
- data/ext/rubygame/rubygame_gl.c +154 -0
- data/ext/rubygame/rubygame_gl.h +32 -0
- data/ext/rubygame/rubygame_gl.o +0 -0
- data/ext/rubygame/rubygame_image.c +108 -0
- data/ext/rubygame/rubygame_image.h +41 -0
- data/ext/rubygame/rubygame_image.o +0 -0
- data/ext/rubygame/rubygame_image.so +0 -0
- data/ext/rubygame/rubygame_joystick.c +247 -0
- data/ext/rubygame/rubygame_joystick.h +41 -0
- data/ext/rubygame/rubygame_joystick.o +0 -0
- data/ext/rubygame/rubygame_main.c +155 -0
- data/ext/rubygame/rubygame_main.h +33 -0
- data/ext/rubygame/rubygame_main.o +0 -0
- data/ext/rubygame/rubygame_mixer.c +764 -0
- data/ext/rubygame/rubygame_mixer.h +62 -0
- data/ext/rubygame/rubygame_mixer.o +0 -0
- data/ext/rubygame/rubygame_mixer.so +0 -0
- data/ext/rubygame/rubygame_screen.c +448 -0
- data/ext/rubygame/rubygame_screen.h +43 -0
- data/ext/rubygame/rubygame_screen.o +0 -0
- data/ext/rubygame/rubygame_shared.c +209 -0
- data/ext/rubygame/rubygame_shared.h +60 -0
- data/ext/rubygame/rubygame_shared.o +0 -0
- data/ext/rubygame/rubygame_surface.c +1147 -0
- data/ext/rubygame/rubygame_surface.h +62 -0
- data/ext/rubygame/rubygame_surface.o +0 -0
- data/ext/rubygame/rubygame_time.c +183 -0
- data/ext/rubygame/rubygame_time.h +32 -0
- data/ext/rubygame/rubygame_time.o +0 -0
- data/ext/rubygame/rubygame_ttf.c +599 -0
- data/ext/rubygame/rubygame_ttf.h +69 -0
- data/ext/rubygame/rubygame_ttf.o +0 -0
- data/ext/rubygame/rubygame_ttf.so +0 -0
- data/lib/rubygame/MANIFEST +12 -0
- data/lib/rubygame/clock.rb +128 -0
- data/lib/rubygame/color/models/base.rb +106 -0
- data/lib/rubygame/color/models/hsl.rb +153 -0
- data/lib/rubygame/color/models/hsv.rb +149 -0
- data/lib/rubygame/color/models/rgb.rb +78 -0
- data/lib/rubygame/color/palettes/css.rb +49 -0
- data/lib/rubygame/color/palettes/palette.rb +100 -0
- data/lib/rubygame/color/palettes/x11.rb +177 -0
- data/lib/rubygame/color.rb +79 -0
- data/lib/rubygame/constants.rb +238 -0
- data/lib/rubygame/event.rb +313 -0
- data/lib/rubygame/ftor.rb +370 -0
- data/lib/rubygame/hotspot.rb +265 -0
- data/lib/rubygame/keyconstants.rb +237 -0
- data/lib/rubygame/mediabag.rb +94 -0
- data/lib/rubygame/queue.rb +288 -0
- data/lib/rubygame/rect.rb +612 -0
- data/lib/rubygame/sfont.rb +223 -0
- data/lib/rubygame/sprite.rb +511 -0
- data/lib/rubygame.rb +41 -0
- data/samples/FreeSans.ttf +0 -0
- data/samples/GPL.txt +340 -0
- data/samples/README +40 -0
- data/samples/chimp.bmp +0 -0
- data/samples/chimp.rb +313 -0
- data/samples/demo_gl.rb +151 -0
- data/samples/demo_gl_tex.rb +197 -0
- data/samples/demo_music.rb +75 -0
- data/samples/demo_rubygame.rb +284 -0
- data/samples/demo_sfont.rb +52 -0
- data/samples/demo_ttf.rb +193 -0
- data/samples/demo_utf8.rb +53 -0
- data/samples/fist.bmp +0 -0
- data/samples/load_and_blit.rb +22 -0
- data/samples/panda.png +0 -0
- data/samples/punch.wav +0 -0
- data/samples/ruby.png +0 -0
- data/samples/song.ogg +0 -0
- data/samples/term16.png +0 -0
- data/samples/whiff.wav +0 -0
- metadata +152 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
/*
|
2
|
+
* rubygame -- ruby library to make game programming fun.
|
3
|
+
* Copyright (C) 2004-2007 John Croisant
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
16
|
+
* License along with this library; if not, write to the Free Software
|
17
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
|
21
|
+
|
22
|
+
#ifndef _RUBYGAME_SURFACE_H
|
23
|
+
#define _RUBYGAME_SURFACE_H
|
24
|
+
|
25
|
+
extern void Rubygame_Init_Surface();
|
26
|
+
|
27
|
+
extern VALUE rbgm_surface_new(int, VALUE*, VALUE);
|
28
|
+
|
29
|
+
extern VALUE rbgm_surface_get_w(VALUE);
|
30
|
+
extern VALUE rbgm_surface_get_h(VALUE);
|
31
|
+
extern VALUE rbgm_surface_get_size(VALUE);
|
32
|
+
|
33
|
+
extern VALUE rbgm_surface_get_depth(VALUE);
|
34
|
+
extern VALUE rbgm_surface_get_flags(VALUE);
|
35
|
+
extern VALUE rbgm_surface_get_masks(VALUE);
|
36
|
+
|
37
|
+
extern VALUE rbgm_surface_get_alpha(VALUE);
|
38
|
+
extern VALUE rbgm_surface_set_alpha(int, VALUE*, VALUE);
|
39
|
+
|
40
|
+
extern VALUE rbgm_surface_get_colorkey(VALUE);
|
41
|
+
extern VALUE rbgm_surface_set_colorkey(int, VALUE*, VALUE);
|
42
|
+
|
43
|
+
extern VALUE rbgm_surface_blit(int, VALUE*, VALUE);
|
44
|
+
|
45
|
+
extern VALUE rbgm_surface_fill(int, VALUE*, VALUE);
|
46
|
+
|
47
|
+
extern VALUE rbgm_surface_getat(int, VALUE*, VALUE);
|
48
|
+
|
49
|
+
extern VALUE rbgm_surface_pixels(VALUE);
|
50
|
+
|
51
|
+
extern VALUE rbgm_surface_get_cliprect(VALUE);
|
52
|
+
extern VALUE rbgm_surface_set_cliprect(VALUE, VALUE);
|
53
|
+
|
54
|
+
extern VALUE rbgm_surface_convert(int, VALUE*, VALUE);
|
55
|
+
extern VALUE rbgm_surface_displayformat(VALUE);
|
56
|
+
extern VALUE rbgm_surface_displayformatalpha(VALUE);
|
57
|
+
|
58
|
+
extern VALUE rbgm_image_savebmp(VALUE, VALUE);
|
59
|
+
|
60
|
+
extern VALUE rbgm_transform_flip(VALUE, VALUE, VALUE);
|
61
|
+
|
62
|
+
#endif
|
Binary file
|
@@ -0,0 +1,183 @@
|
|
1
|
+
/*
|
2
|
+
* Functions for getting the time since initialization and delaying execution
|
3
|
+
* for a specified amounts of time.
|
4
|
+
*
|
5
|
+
* --
|
6
|
+
*
|
7
|
+
* Rubygame -- Ruby code and bindings to SDL to facilitate game creation
|
8
|
+
* Copyright (C) 2004-2007 John Croisant
|
9
|
+
*
|
10
|
+
* This library is free software; you can redistribute it and/or
|
11
|
+
* modify it under the terms of the GNU Lesser General Public
|
12
|
+
* License as published by the Free Software Foundation; either
|
13
|
+
* version 2.1 of the License, or (at your option) any later version.
|
14
|
+
*
|
15
|
+
* This library is distributed in the hope that it will be useful,
|
16
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18
|
+
* Lesser General Public License for more details.
|
19
|
+
*
|
20
|
+
* You should have received a copy of the GNU Lesser General Public
|
21
|
+
* License along with this library; if not, write to the Free Software
|
22
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
+
*
|
24
|
+
* ++
|
25
|
+
*/
|
26
|
+
|
27
|
+
#include "rubygame_shared.h"
|
28
|
+
#include "rubygame_time.h"
|
29
|
+
|
30
|
+
void Rubygame_Init_Time();
|
31
|
+
|
32
|
+
VALUE cClock;
|
33
|
+
|
34
|
+
VALUE rbgm_time_wait(VALUE, VALUE);
|
35
|
+
VALUE rbgm_time_delay(int, VALUE*, VALUE);
|
36
|
+
VALUE rbgm_time_getticks(VALUE);
|
37
|
+
|
38
|
+
|
39
|
+
/* NOTICE: if you change this value "officially", don't forget to update the
|
40
|
+
* documentation for rbgm_time_delay!!
|
41
|
+
*/
|
42
|
+
#define WORST_CLOCK_ACCURACY 12
|
43
|
+
|
44
|
+
|
45
|
+
/*
|
46
|
+
* call-seq:
|
47
|
+
* wait( time ) -> Integer
|
48
|
+
*
|
49
|
+
* time:: how many milliseconds to wait.
|
50
|
+
*
|
51
|
+
* Wait approximately the given time (the accuracy depends upon processor
|
52
|
+
* scheduling, but 10ms is common). Returns the actual delay time, in
|
53
|
+
* milliseconds. This method is less CPU-intensive than #delay, but is
|
54
|
+
* slightly less accurate.
|
55
|
+
*
|
56
|
+
* The Rubygame timer system will be initialized when you call this function,
|
57
|
+
* if it has not been already.
|
58
|
+
*
|
59
|
+
*/
|
60
|
+
VALUE rbgm_time_wait(VALUE module, VALUE milliseconds)
|
61
|
+
{
|
62
|
+
Uint32 start, delay;
|
63
|
+
|
64
|
+
if(!SDL_WasInit(SDL_INIT_TIMER))
|
65
|
+
if(SDL_InitSubSystem(SDL_INIT_TIMER))
|
66
|
+
rb_raise(eSDLError,"Could not initialize timer system: %s",\
|
67
|
+
SDL_GetError());
|
68
|
+
|
69
|
+
delay = NUM2UINT(milliseconds);
|
70
|
+
start = SDL_GetTicks();
|
71
|
+
SDL_Delay(delay);
|
72
|
+
return INT2NUM(SDL_GetTicks() - start);
|
73
|
+
}
|
74
|
+
|
75
|
+
/*--
|
76
|
+
* From pygame code, with a few modifications:
|
77
|
+
* - takes 'accuracy' argument
|
78
|
+
* - ruby syntax for raising exceptions
|
79
|
+
*++
|
80
|
+
*/
|
81
|
+
static int accurate_delay(int ticks,int accuracy)
|
82
|
+
{
|
83
|
+
int funcstart, delay;
|
84
|
+
if(ticks <= 0)
|
85
|
+
return 0;
|
86
|
+
|
87
|
+
if(!SDL_WasInit(SDL_INIT_TIMER))
|
88
|
+
{
|
89
|
+
if(SDL_InitSubSystem(SDL_INIT_TIMER))
|
90
|
+
{
|
91
|
+
rb_raise(eSDLError,"Could not initialize timer system: %s",\
|
92
|
+
SDL_GetError());
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
funcstart = SDL_GetTicks();
|
97
|
+
if(ticks >= accuracy)
|
98
|
+
{
|
99
|
+
delay = (ticks - 2) - (ticks % accuracy);
|
100
|
+
if(delay >= accuracy)
|
101
|
+
{
|
102
|
+
SDL_Delay(delay);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
do{
|
106
|
+
delay = ticks - (SDL_GetTicks() - funcstart);
|
107
|
+
}while(delay > 0);
|
108
|
+
|
109
|
+
return SDL_GetTicks() - funcstart;
|
110
|
+
}
|
111
|
+
|
112
|
+
/*
|
113
|
+
* call-seq:
|
114
|
+
* delay( time, gran=12 ) -> Integer
|
115
|
+
*
|
116
|
+
* time:: how many milliseconds to delay.
|
117
|
+
* gran:: the granularity (in milliseconds) to assume for the system. A
|
118
|
+
* smaller value should use less CPU time, but if it's lower than the
|
119
|
+
* actual system granularity, this function might wait too long. The
|
120
|
+
* default, 12 ms, has a fairly low risk of over-waiting for many
|
121
|
+
* systems.
|
122
|
+
|
123
|
+
* Use the CPU to more accurately wait for the given period. Returns the
|
124
|
+
* actual delay time, in milliseconds. This function is more accurate than
|
125
|
+
* #wait, but is also somewhat more CPU-intensive.
|
126
|
+
*
|
127
|
+
* The Rubygame timer system will be initialized when you call this function,
|
128
|
+
* if it has not been already.
|
129
|
+
*
|
130
|
+
*/
|
131
|
+
VALUE rbgm_time_delay(int argc, VALUE *argv, VALUE module)
|
132
|
+
{
|
133
|
+
int ticks, goal, accuracy;
|
134
|
+
VALUE vtime, vgran;
|
135
|
+
|
136
|
+
rb_scan_args(argc,argv,"11", &vtime, &vgran);
|
137
|
+
|
138
|
+
goal = NUM2INT(vtime);
|
139
|
+
if(goal < 0)
|
140
|
+
goal = 0;
|
141
|
+
|
142
|
+
if( RTEST(vgran) )
|
143
|
+
accuracy = NUM2INT(vgran);
|
144
|
+
else
|
145
|
+
accuracy = WORST_CLOCK_ACCURACY;
|
146
|
+
|
147
|
+
ticks = accurate_delay(goal,accuracy);
|
148
|
+
|
149
|
+
return INT2NUM(ticks);
|
150
|
+
}
|
151
|
+
|
152
|
+
/*
|
153
|
+
* call-seq:
|
154
|
+
* runtime -> Integer
|
155
|
+
*
|
156
|
+
* Return the number of milliseconds since the Rubygame timer system
|
157
|
+
* was initialized.
|
158
|
+
*
|
159
|
+
* The Rubygame timer system will be initialized when you call this function,
|
160
|
+
* if it has not been already.
|
161
|
+
*/
|
162
|
+
VALUE rbgm_time_getticks( VALUE module )
|
163
|
+
{
|
164
|
+
if(!SDL_WasInit(SDL_INIT_TIMER))
|
165
|
+
if(SDL_InitSubSystem(SDL_INIT_TIMER))
|
166
|
+
rb_raise(eSDLError,"Could not initialize timer system: %s",\
|
167
|
+
SDL_GetError());
|
168
|
+
return INT2NUM(SDL_GetTicks());
|
169
|
+
}
|
170
|
+
|
171
|
+
void Rubygame_Init_Time()
|
172
|
+
{
|
173
|
+
#if 0
|
174
|
+
mRubygame = rb_define_module("Rubygame");
|
175
|
+
#endif
|
176
|
+
|
177
|
+
/* Clock class */
|
178
|
+
cClock = rb_define_class_under(mRubygame,"Clock",rb_cObject);
|
179
|
+
/* Clock class methods */
|
180
|
+
rb_define_singleton_method(cClock,"wait",rbgm_time_wait,1);
|
181
|
+
rb_define_singleton_method(cClock,"delay",rbgm_time_delay,-1);
|
182
|
+
rb_define_singleton_method(cClock,"runtime",rbgm_time_getticks,0);
|
183
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
* Rubygame -- Ruby code and bindings to SDL to facilitate game creation
|
3
|
+
* Copyright (C) 2004-2007 John Croisant
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
16
|
+
* License along with this library; if not, write to the Free Software
|
17
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
|
21
|
+
#ifndef _RUBYGAME_TIME_H
|
22
|
+
#define _RUBYGAME_TIME_H
|
23
|
+
|
24
|
+
extern void Rubygame_Init_Time();
|
25
|
+
|
26
|
+
extern VALUE cClock;
|
27
|
+
|
28
|
+
extern VALUE rbgm_time_wait(VALUE, VALUE);
|
29
|
+
extern VALUE rbgm_time_delay(int, VALUE*, VALUE);
|
30
|
+
extern VALUE rbgm_time_getticks(VALUE);
|
31
|
+
|
32
|
+
#endif
|
Binary file
|