ruby2d 0.9.4 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/include/SDL2/SDL.h +4 -1
- data/assets/include/SDL2/SDL_assert.h +3 -1
- data/assets/include/SDL2/SDL_atomic.h +1 -1
- data/assets/include/SDL2/SDL_audio.h +1 -1
- data/assets/include/SDL2/SDL_bits.h +1 -1
- data/assets/include/SDL2/SDL_blendmode.h +4 -1
- data/assets/include/SDL2/SDL_clipboard.h +1 -1
- data/assets/include/SDL2/SDL_config.h +1 -1
- data/assets/include/SDL2/SDL_config_android.h +7 -3
- data/assets/include/SDL2/SDL_config_iphoneos.h +16 -10
- data/assets/include/SDL2/SDL_config_macosx.h +40 -14
- data/assets/include/SDL2/SDL_config_minimal.h +1 -1
- data/assets/include/SDL2/SDL_config_os2.h +26 -8
- data/assets/include/SDL2/SDL_config_pandora.h +4 -2
- data/assets/include/SDL2/SDL_config_psp.h +2 -1
- data/assets/include/SDL2/SDL_config_windows.h +40 -9
- data/assets/include/SDL2/SDL_config_winrt.h +5 -2
- data/assets/include/SDL2/SDL_config_wiz.h +5 -2
- data/assets/include/SDL2/SDL_copying.h +1 -1
- data/assets/include/SDL2/SDL_cpuinfo.h +32 -3
- data/assets/include/SDL2/SDL_egl.h +4 -1
- data/assets/include/SDL2/SDL_endian.h +6 -3
- data/assets/include/SDL2/SDL_error.h +38 -2
- data/assets/include/SDL2/SDL_events.h +64 -28
- data/assets/include/SDL2/SDL_filesystem.h +1 -1
- data/assets/include/SDL2/SDL_gamecontroller.h +160 -9
- data/assets/include/SDL2/SDL_gesture.h +1 -1
- data/assets/include/SDL2/SDL_haptic.h +10 -1
- data/assets/include/SDL2/SDL_hints.h +316 -4
- data/assets/include/SDL2/SDL_joystick.h +115 -24
- data/assets/include/SDL2/SDL_keyboard.h +1 -1
- data/assets/include/SDL2/SDL_keycode.h +11 -9
- data/assets/include/SDL2/SDL_loadso.h +1 -1
- data/assets/include/SDL2/SDL_locale.h +101 -0
- data/assets/include/SDL2/SDL_log.h +3 -3
- data/assets/include/SDL2/SDL_main.h +1 -1
- data/assets/include/SDL2/SDL_messagebox.h +6 -4
- data/assets/include/SDL2/SDL_metal.h +117 -0
- data/assets/include/SDL2/SDL_misc.h +75 -0
- data/assets/include/SDL2/SDL_mouse.h +1 -1
- data/assets/include/SDL2/SDL_mutex.h +1 -1
- data/assets/include/SDL2/SDL_name.h +1 -1
- data/assets/include/SDL2/SDL_opengl.h +1 -1
- data/assets/include/SDL2/SDL_opengl_glext.h +3 -0
- data/assets/include/SDL2/SDL_opengles.h +1 -1
- data/assets/include/SDL2/SDL_opengles2.h +1 -1
- data/assets/include/SDL2/SDL_pixels.h +25 -16
- data/assets/include/SDL2/SDL_platform.h +1 -1
- data/assets/include/SDL2/SDL_power.h +1 -1
- data/assets/include/SDL2/SDL_quit.h +1 -1
- data/assets/include/SDL2/SDL_rect.h +1 -1
- data/assets/include/SDL2/SDL_render.h +63 -3
- data/assets/include/SDL2/SDL_revision.h +2 -2
- data/assets/include/SDL2/SDL_rwops.h +2 -10
- data/assets/include/SDL2/SDL_scancode.h +1 -1
- data/assets/include/SDL2/SDL_sensor.h +25 -9
- data/assets/include/SDL2/SDL_shape.h +1 -1
- data/assets/include/SDL2/SDL_stdinc.h +44 -4
- data/assets/include/SDL2/SDL_surface.h +11 -2
- data/assets/include/SDL2/SDL_system.h +50 -4
- data/assets/include/SDL2/SDL_syswm.h +29 -2
- data/assets/include/SDL2/SDL_test.h +1 -1
- data/assets/include/SDL2/SDL_test_assert.h +1 -1
- data/assets/include/SDL2/SDL_test_common.h +14 -1
- data/assets/include/SDL2/SDL_test_compare.h +1 -1
- data/assets/include/SDL2/SDL_test_crc32.h +1 -1
- data/assets/include/SDL2/SDL_test_font.h +1 -1
- data/assets/include/SDL2/SDL_test_fuzzer.h +1 -1
- data/assets/include/SDL2/SDL_test_harness.h +1 -1
- data/assets/include/SDL2/SDL_test_images.h +1 -1
- data/assets/include/SDL2/SDL_test_log.h +1 -1
- data/assets/include/SDL2/SDL_test_md5.h +1 -1
- data/assets/include/SDL2/SDL_test_memory.h +1 -1
- data/assets/include/SDL2/SDL_test_random.h +1 -1
- data/assets/include/SDL2/SDL_thread.h +34 -11
- data/assets/include/SDL2/SDL_timer.h +1 -1
- data/assets/include/SDL2/SDL_touch.h +1 -1
- data/assets/include/SDL2/SDL_types.h +1 -1
- data/assets/include/SDL2/SDL_version.h +2 -2
- data/assets/include/SDL2/SDL_video.h +11 -5
- data/assets/include/SDL2/SDL_vulkan.h +6 -8
- data/assets/include/SDL2/begin_code.h +5 -9
- data/assets/include/SDL2/close_code.h +1 -1
- data/assets/macos/lib/libFLAC.a +0 -0
- data/assets/macos/lib/libSDL2.a +0 -0
- data/assets/macos/lib/libSDL2_image.a +0 -0
- data/assets/macos/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/lib/libfreetype.a +0 -0
- data/assets/macos/lib/libjpeg.a +0 -0
- data/assets/macos/lib/libmodplug.a +0 -0
- data/assets/macos/lib/libmpg123.a +0 -0
- data/assets/macos/lib/libogg.a +0 -0
- data/assets/macos/lib/libpng16.a +0 -0
- data/assets/macos/lib/libtiff.a +0 -0
- data/assets/macos/lib/libvorbis.a +0 -0
- data/assets/macos/lib/libvorbisfile.a +0 -0
- data/assets/macos/lib/libwebp.a +0 -0
- data/assets/mingw/bin/SDL2.dll +0 -0
- data/assets/mingw/lib/libSDL2.a +0 -0
- data/assets/mingw/lib/libSDL2.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_test.a +0 -0
- data/assets/mingw/lib/libSDL2main.a +0 -0
- data/bin/ruby2d +1 -0
- data/{assets/linux/simple2d/src/simple2d.c → ext/ruby2d/common.c} +32 -32
- data/{assets/linux/simple2d/src → ext/ruby2d}/controllers.c +17 -17
- data/ext/ruby2d/extconf.rb +37 -59
- data/ext/ruby2d/font.c +35 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/gl.c +66 -98
- data/ext/ruby2d/gl2.c +86 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/gl3.c +69 -112
- data/{assets/linux/simple2d/src → ext/ruby2d}/gles.c +22 -81
- data/ext/ruby2d/image.c +58 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/input.c +8 -8
- data/{assets/linux/simple2d/src → ext/ruby2d}/music.c +30 -17
- data/ext/ruby2d/ruby2d.c +449 -439
- data/ext/ruby2d/ruby2d.h +652 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/shapes.c +18 -18
- data/{assets/linux/simple2d/src → ext/ruby2d}/sound.c +39 -14
- data/ext/ruby2d/text.c +22 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/window.c +63 -63
- data/lib/ruby2d/circle.rb +21 -3
- data/lib/ruby2d/cli/build.rb +4 -7
- data/lib/ruby2d/dsl.rb +16 -9
- data/lib/ruby2d/entity.rb +17 -0
- data/lib/ruby2d/font.rb +23 -3
- data/lib/ruby2d/image.rb +35 -7
- data/lib/ruby2d/line.rb +23 -1
- data/lib/ruby2d/music.rb +5 -0
- data/lib/ruby2d/pixel.rb +17 -0
- data/lib/ruby2d/quad.rb +21 -1
- data/lib/ruby2d/rectangle.rb +12 -3
- data/lib/ruby2d/renderable.rb +4 -20
- data/lib/ruby2d/sound.rb +30 -0
- data/lib/ruby2d/sprite.rb +57 -75
- data/lib/ruby2d/square.rb +10 -1
- data/lib/ruby2d/text.rb +55 -12
- data/lib/ruby2d/texture.rb +28 -0
- data/lib/ruby2d/tileset.rb +87 -0
- data/lib/ruby2d/triangle.rb +19 -1
- data/lib/ruby2d/version.rb +1 -1
- data/lib/ruby2d/vertices.rb +84 -0
- data/lib/ruby2d/window.rb +259 -22
- data/lib/ruby2d.rb +6 -1
- metadata +30 -26
- data/assets/include/simple2d.h +0 -757
- data/assets/linux/simple2d/Makefile +0 -260
- data/assets/linux/simple2d/bin/simple2d.sh +0 -1318
- data/assets/linux/simple2d/include/simple2d.h +0 -757
- data/assets/linux/simple2d/src/gl2.c +0 -146
- data/assets/linux/simple2d/src/image.c +0 -138
- data/assets/linux/simple2d/src/sprite.c +0 -147
- data/assets/linux/simple2d/src/text.c +0 -129
- data/assets/macos/lib/libsimple2d.a +0 -0
- data/assets/mingw/lib/libsimple2d.a +0 -0
@@ -1,31 +1,31 @@
|
|
1
1
|
// music.c
|
2
2
|
|
3
|
-
#include "
|
3
|
+
#include "ruby2d.h"
|
4
4
|
|
5
5
|
|
6
6
|
/*
|
7
7
|
* Create the music
|
8
8
|
*/
|
9
|
-
|
10
|
-
|
9
|
+
R2D_Music *R2D_CreateMusic(const char *path) {
|
10
|
+
R2D_Init();
|
11
11
|
|
12
12
|
// Check if music file exists
|
13
|
-
if (!
|
14
|
-
|
13
|
+
if (!R2D_FileExists(path)) {
|
14
|
+
R2D_Error("R2D_CreateMusic", "Music file `%s` not found", path);
|
15
15
|
return NULL;
|
16
16
|
}
|
17
17
|
|
18
18
|
// Allocate the music structure
|
19
|
-
|
19
|
+
R2D_Music *mus = (R2D_Music *) malloc(sizeof(R2D_Music));
|
20
20
|
if (!mus) {
|
21
|
-
|
21
|
+
R2D_Error("R2D_CreateMusic", "Out of memory!");
|
22
22
|
return NULL;
|
23
23
|
}
|
24
24
|
|
25
25
|
// Load the music data from file
|
26
26
|
mus->data = Mix_LoadMUS(path);
|
27
27
|
if (!mus->data) {
|
28
|
-
|
28
|
+
R2D_Error("Mix_LoadMUS", Mix_GetError());
|
29
29
|
free(mus);
|
30
30
|
return NULL;
|
31
31
|
}
|
@@ -33,6 +33,11 @@ S2D_Music *S2D_CreateMusic(const char *path) {
|
|
33
33
|
// Initialize values
|
34
34
|
mus->path = path;
|
35
35
|
|
36
|
+
// Calculate the length of music by creating a temporary R2D_Sound object
|
37
|
+
R2D_Sound *snd = R2D_CreateSound(path);
|
38
|
+
mus->length = R2D_GetSoundLength(snd);
|
39
|
+
R2D_FreeSound(snd);
|
40
|
+
|
36
41
|
return mus;
|
37
42
|
}
|
38
43
|
|
@@ -40,7 +45,7 @@ S2D_Music *S2D_CreateMusic(const char *path) {
|
|
40
45
|
/*
|
41
46
|
* Play the music
|
42
47
|
*/
|
43
|
-
void
|
48
|
+
void R2D_PlayMusic(R2D_Music *mus, bool loop) {
|
44
49
|
if (!mus) return;
|
45
50
|
|
46
51
|
// If looping, set to -1 times; else 0
|
@@ -49,7 +54,7 @@ void S2D_PlayMusic(S2D_Music *mus, bool loop) {
|
|
49
54
|
// times: 0 == once, -1 == forever
|
50
55
|
if (Mix_PlayMusic(mus->data, times) == -1) {
|
51
56
|
// No music for you
|
52
|
-
|
57
|
+
R2D_Error("R2D_PlayMusic", Mix_GetError());
|
53
58
|
}
|
54
59
|
}
|
55
60
|
|
@@ -57,7 +62,7 @@ void S2D_PlayMusic(S2D_Music *mus, bool loop) {
|
|
57
62
|
/*
|
58
63
|
* Pause the playing music
|
59
64
|
*/
|
60
|
-
void
|
65
|
+
void R2D_PauseMusic() {
|
61
66
|
Mix_PauseMusic();
|
62
67
|
}
|
63
68
|
|
@@ -65,7 +70,7 @@ void S2D_PauseMusic() {
|
|
65
70
|
/*
|
66
71
|
* Resume the current music
|
67
72
|
*/
|
68
|
-
void
|
73
|
+
void R2D_ResumeMusic() {
|
69
74
|
Mix_ResumeMusic();
|
70
75
|
}
|
71
76
|
|
@@ -73,7 +78,7 @@ void S2D_ResumeMusic() {
|
|
73
78
|
/*
|
74
79
|
* Stop the playing music; interrupts fader effects
|
75
80
|
*/
|
76
|
-
void
|
81
|
+
void R2D_StopMusic() {
|
77
82
|
Mix_HaltMusic();
|
78
83
|
}
|
79
84
|
|
@@ -81,7 +86,7 @@ void S2D_StopMusic() {
|
|
81
86
|
/*
|
82
87
|
* Get the music volume
|
83
88
|
*/
|
84
|
-
int
|
89
|
+
int R2D_GetMusicVolume() {
|
85
90
|
// Get music volume as percentage of maximum mix volume
|
86
91
|
return ceil(Mix_VolumeMusic(-1) * (100.0 / MIX_MAX_VOLUME));
|
87
92
|
}
|
@@ -90,7 +95,7 @@ int S2D_GetMusicVolume() {
|
|
90
95
|
/*
|
91
96
|
* Set the music volume a given percentage
|
92
97
|
*/
|
93
|
-
void
|
98
|
+
void R2D_SetMusicVolume(int volume) {
|
94
99
|
// Set volume to be a percentage of the maximum mix volume
|
95
100
|
Mix_VolumeMusic((volume / 100.0) * MIX_MAX_VOLUME);
|
96
101
|
}
|
@@ -99,15 +104,23 @@ void S2D_SetMusicVolume(int volume) {
|
|
99
104
|
/*
|
100
105
|
* Fade out the playing music
|
101
106
|
*/
|
102
|
-
void
|
107
|
+
void R2D_FadeOutMusic(int ms) {
|
103
108
|
Mix_FadeOutMusic(ms);
|
104
109
|
}
|
105
110
|
|
106
111
|
|
112
|
+
/*
|
113
|
+
* Get the length of the music in seconds
|
114
|
+
*/
|
115
|
+
int R2D_GetMusicLength(R2D_Music *mus) {
|
116
|
+
return mus->length;
|
117
|
+
}
|
118
|
+
|
119
|
+
|
107
120
|
/*
|
108
121
|
* Free the music
|
109
122
|
*/
|
110
|
-
void
|
123
|
+
void R2D_FreeMusic(R2D_Music *mus) {
|
111
124
|
if (!mus) return;
|
112
125
|
Mix_FreeMusic(mus->data);
|
113
126
|
free(mus);
|