raylib-bindings 0.5.8pre1-x64-mingw → 0.6.0-x64-mingw
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +403 -399
- data/LICENSE.txt +0 -0
- data/README.md +176 -176
- data/examples/template.rb +143 -143
- data/lib/config.rb +103 -103
- data/lib/libraylib.dll +0 -0
- data/lib/physac.dll +0 -0
- data/lib/physac.rb +322 -322
- data/lib/raygui.dll +0 -0
- data/lib/raygui_helper.rb +127 -127
- data/lib/raygui_main.rb +890 -890
- data/lib/raylib.rb +62 -62
- data/lib/raylib_helper.rb +400 -400
- data/lib/raylib_main.rb +5088 -5088
- data/lib/raymath.rb +845 -845
- data/lib/rcamera.rb +117 -117
- data/lib/rlgl.rb +1311 -1311
- metadata +5 -5
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,176 +1,176 @@
|
|
1
|
-
<!-- -*- mode:markdown; coding:utf-8; -*- -->
|
2
|
-
|
3
|
-
# Yet another raylib wrapper for Ruby #
|
4
|
-
|
5
|
-
* Created : 2021-10-17
|
6
|
-
* Last modified : 2023-11-
|
7
|
-
|
8
|
-
Provides Ruby bindings for raylib-related libraries including:
|
9
|
-
|
10
|
-
* [raylib](https://github.com/raysan5/raylib)
|
11
|
-
* raylib
|
12
|
-
* raymath
|
13
|
-
* rlgl
|
14
|
-
* [raygui](https://github.com/raysan5/raygui)
|
15
|
-
* [Physac](https://github.com/raysan5/physac)
|
16
|
-
|
17
|
-
<img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/bitmap_font_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/game_of_life_simple_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/lissajous_curve_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/procedural_texture_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/reversi_board_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/utf8_font_rb.png" width="125">
|
18
|
-
|
19
|
-
## Features ##
|
20
|
-
|
21
|
-
* Generated semi-automatically
|
22
|
-
* Based on Ruby/FFI ( https://github.com/ffi/ffi )
|
23
|
-
* Pre-built binaries are inside:
|
24
|
-
* Windows (x86_64)
|
25
|
-
* macOS (x86_64, ARM64)
|
26
|
-
* Linux (x86_64 WSL, ARM64 Chromebook)
|
27
|
-
|
28
|
-
## Quick Start ##
|
29
|
-
|
30
|
-
```
|
31
|
-
D:\> gem install raylib-bindings
|
32
|
-
Fetching raylib-bindings-...
|
33
|
-
...
|
34
|
-
1 gem installed
|
35
|
-
|
36
|
-
D:\> ruby -r raylib -e 'Raylib.template'
|
37
|
-
[Info] Raylib.template : C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/raylib-bindings-0.0.11/examples/template.rb => d://template.rb
|
38
|
-
[Info] Raylib.template : Done
|
39
|
-
|
40
|
-
D:\> ruby template.rb
|
41
|
-
```
|
42
|
-
↓
|
43
|
-
|
44
|
-
<img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/template_screenshot.png" width="400">
|
45
|
-
|
46
|
-
## Prerequisites ##
|
47
|
-
|
48
|
-
* Ruby interpreter
|
49
|
-
* Tested on:
|
50
|
-
* [macOS] https://rvm.io
|
51
|
-
* ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22]
|
52
|
-
* [Windows] https://rubyinstaller.org/downloads/ Ruby+Devkit
|
53
|
-
* ruby 3.2.0 (2022-12-25 revision a528908271) [x64-mingw-ucrt]
|
54
|
-
* [Linux/x86_64 WSL] https://github.com/rvm/ubuntu_rvm
|
55
|
-
* ruby 3.2.0preview1 (2022-04-03 master f801386f0c) [x86_64-linux]
|
56
|
-
* [Linux/ARM64 Chromebook] https://github.com/rvm/ubuntu_rvm
|
57
|
-
* ruby 3.2.0 (2022-12-25 revision a528908271) [aarch64-linux]
|
58
|
-
|
59
|
-
* If you need to build DLLs/shared libralies for your own runtime envrioenment (Linux, etc.):
|
60
|
-
* CMake https://cmake.org/download/
|
61
|
-
* C Compiler
|
62
|
-
* Tested compilers:
|
63
|
-
* [macOS] clang
|
64
|
-
|
65
|
-
$ clang --version
|
66
|
-
Apple clang version 14.0.0 (clang-1400.0.29.202)
|
67
|
-
Target: arm64-apple-darwin22.2.0
|
68
|
-
Thread model: posix
|
69
|
-
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
70
|
-
|
71
|
-
* [Windows] gcc
|
72
|
-
|
73
|
-
gcc (Rev7, Built by MSYS2 project) 12.2.0
|
74
|
-
|
75
|
-
* [Linux] gcc, clang
|
76
|
-
|
77
|
-
(x86_64) Ubuntu clang version 14.0.0-1ubuntu1
|
78
|
-
(arm64) aarch64-linux-gnu-g++ ( https://packages.ubuntu.com/focal/g++-aarch64-linux-gnu )
|
79
|
-
|
80
|
-
<details>
|
81
|
-
<summary>Older versions</summary>
|
82
|
-
|
83
|
-
* Ruby interpreter
|
84
|
-
* Tested on:
|
85
|
-
* [macOS]
|
86
|
-
* ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin21]
|
87
|
-
* ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
|
88
|
-
* ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin20]
|
89
|
-
* ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
|
90
|
-
* [Windows] https://rubyinstaller.org/downloads/ Ruby+Devkit
|
91
|
-
* ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
|
92
|
-
* ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x64-mingw-ucrt]
|
93
|
-
* ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x64-mingw32]
|
94
|
-
|
95
|
-
* Compiler
|
96
|
-
* Tested on:
|
97
|
-
* [macOS] clang
|
98
|
-
|
99
|
-
$ clang --version
|
100
|
-
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
|
101
|
-
Target: arm64-apple-darwin21.5.0
|
102
|
-
Thread model: posix
|
103
|
-
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
104
|
-
|
105
|
-
$ clang --version
|
106
|
-
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
|
107
|
-
Target: arm64-apple-darwin21.5.0
|
108
|
-
Thread model: posix
|
109
|
-
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
110
|
-
|
111
|
-
Apple clang version 13.0.0 (clang-1300.0.29.3)
|
112
|
-
Target: arm64-apple-darwin20.6.0
|
113
|
-
Thread model: posix
|
114
|
-
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
115
|
-
|
116
|
-
* [Windows] gcc
|
117
|
-
|
118
|
-
gcc (Rev9, Built by MSYS2 project) 11.2.0
|
119
|
-
gcc (Rev10, Built by MSYS2 project) 11.2.0
|
120
|
-
|
121
|
-
</details>
|
122
|
-
|
123
|
-
## Projects ##
|
124
|
-
|
125
|
-
See the projects below to learn how to use this library:
|
126
|
-
|
127
|
-
* Whac-a-Mole! : Ruby raylib bindings demo
|
128
|
-
* <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings-whacamole/main/doc/screenshot_00.png" width="300"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings-whacamole/main/doc/screenshot_01.png" width="300">
|
129
|
-
* <https://github.com/vaiorabbit/raylib-bindings-whacamole>
|
130
|
-
|
131
|
-
* 1D dot eater : Ruby raylib bindings demo
|
132
|
-
* <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings-pacone/main/doc/screenshot_00.png" width="600">
|
133
|
-
* <https://github.com/vaiorabbit/raylib-bindings-pacone>
|
134
|
-
|
135
|
-
## Limitation ##
|
136
|
-
|
137
|
-
* `SetTraceLogCallback` and `TraceLogCallback` are unusable since Ruby-FFI does not support `:varargs` parameter in callbacks (`Proc`, etc.)
|
138
|
-
* Ref.: https://ffi.github.io/ruby-ffi-archive/messages/20130214-%5Bruby-ffi%5D%20Re_%20Callback%20Function%20with%20varargs-345.html
|
139
|
-
|
140
|
-
## License ##
|
141
|
-
|
142
|
-
Shared libraries in `lib` directory are built on top of these products and are available under the terms of these licenses:
|
143
|
-
|
144
|
-
* `libraylib.dylib`, `libraylib.dll`, `libraylib.aarch64.so`, `libraylib.x86_64.so`
|
145
|
-
* raylib ( https://github.com/raysan5/raylib )
|
146
|
-
* zlib License https://github.com/raysan5/raylib/blob/master/LICENSE
|
147
|
-
* `raygui.dylib`, `raygui.dll`, `raygui.aarch64.so`, `raygui.x86_64.so`
|
148
|
-
* raygui ( https://github.com/raysan5/raygui )
|
149
|
-
* zlib License https://github.com/raysan5/raygui/blob/master/LICENSE
|
150
|
-
* `physac.dylib`, `physac.dll`, `physac.aarch64.so` `physac.x86_64.so`
|
151
|
-
* Physac ( https://github.com/raysan5/physac )
|
152
|
-
* LICENSE: zlib/libpng https://github.com/raysan5/physac/blob/4a8e17f263fb8e1150b3fbafc96f880c7d7a4833/src/physac.h#L51-L68
|
153
|
-
|
154
|
-
All ruby codes here are available under the terms of the zlib/libpng License ( http://opensource.org/licenses/Zlib ).
|
155
|
-
|
156
|
-
Ruby-raylib : Yet another raylib wrapper for Ruby
|
157
|
-
Copyright (c) 2021-2023 vaiorabbit <http://twitter.com/vaiorabbit>
|
158
|
-
|
159
|
-
This software is provided 'as-is', without any express or implied
|
160
|
-
warranty. In no event will the authors be held liable for any damages
|
161
|
-
arising from the use of this software.
|
162
|
-
|
163
|
-
Permission is granted to anyone to use this software for any purpose,
|
164
|
-
including commercial applications, and to alter it and redistribute it
|
165
|
-
freely, subject to the following restrictions:
|
166
|
-
|
167
|
-
1. The origin of this software must not be misrepresented; you must not
|
168
|
-
claim that you wrote the original software. If you use this software
|
169
|
-
in a product, an acknowledgment in the product documentation would be
|
170
|
-
appreciated but is not required.
|
171
|
-
|
172
|
-
2. Altered source versions must be plainly marked as such, and must not be
|
173
|
-
misrepresented as being the original software.
|
174
|
-
|
175
|
-
3. This notice may not be removed or altered from any source
|
176
|
-
distribution.
|
1
|
+
<!-- -*- mode:markdown; coding:utf-8; -*- -->
|
2
|
+
|
3
|
+
# Yet another raylib wrapper for Ruby #
|
4
|
+
|
5
|
+
* Created : 2021-10-17
|
6
|
+
* Last modified : 2023-11-18
|
7
|
+
|
8
|
+
Provides Ruby bindings for raylib-related libraries including:
|
9
|
+
|
10
|
+
* [raylib](https://github.com/raysan5/raylib)
|
11
|
+
* raylib
|
12
|
+
* raymath
|
13
|
+
* rlgl
|
14
|
+
* [raygui](https://github.com/raysan5/raygui)
|
15
|
+
* [Physac](https://github.com/raysan5/physac)
|
16
|
+
|
17
|
+
<img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/bitmap_font_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/game_of_life_simple_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/lissajous_curve_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/procedural_texture_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/reversi_board_rb.png" width="125"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/utf8_font_rb.png" width="125">
|
18
|
+
|
19
|
+
## Features ##
|
20
|
+
|
21
|
+
* Generated semi-automatically
|
22
|
+
* Based on Ruby/FFI ( https://github.com/ffi/ffi )
|
23
|
+
* Pre-built binaries are inside:
|
24
|
+
* Windows (x86_64)
|
25
|
+
* macOS (x86_64, ARM64)
|
26
|
+
* Linux (x86_64 WSL, ARM64 Chromebook)
|
27
|
+
|
28
|
+
## Quick Start ##
|
29
|
+
|
30
|
+
```
|
31
|
+
D:\> gem install raylib-bindings
|
32
|
+
Fetching raylib-bindings-...
|
33
|
+
...
|
34
|
+
1 gem installed
|
35
|
+
|
36
|
+
D:\> ruby -r raylib -e 'Raylib.template'
|
37
|
+
[Info] Raylib.template : C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/raylib-bindings-0.0.11/examples/template.rb => d://template.rb
|
38
|
+
[Info] Raylib.template : Done
|
39
|
+
|
40
|
+
D:\> ruby template.rb
|
41
|
+
```
|
42
|
+
↓
|
43
|
+
|
44
|
+
<img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings/main/doc/template_screenshot.png" width="400">
|
45
|
+
|
46
|
+
## Prerequisites ##
|
47
|
+
|
48
|
+
* Ruby interpreter
|
49
|
+
* Tested on:
|
50
|
+
* [macOS] https://rvm.io
|
51
|
+
* ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22]
|
52
|
+
* [Windows] https://rubyinstaller.org/downloads/ Ruby+Devkit
|
53
|
+
* ruby 3.2.0 (2022-12-25 revision a528908271) [x64-mingw-ucrt]
|
54
|
+
* [Linux/x86_64 WSL] https://github.com/rvm/ubuntu_rvm
|
55
|
+
* ruby 3.2.0preview1 (2022-04-03 master f801386f0c) [x86_64-linux]
|
56
|
+
* [Linux/ARM64 Chromebook] https://github.com/rvm/ubuntu_rvm
|
57
|
+
* ruby 3.2.0 (2022-12-25 revision a528908271) [aarch64-linux]
|
58
|
+
|
59
|
+
* If you need to build DLLs/shared libralies for your own runtime envrioenment (Linux, etc.):
|
60
|
+
* CMake https://cmake.org/download/
|
61
|
+
* C Compiler
|
62
|
+
* Tested compilers:
|
63
|
+
* [macOS] clang
|
64
|
+
|
65
|
+
$ clang --version
|
66
|
+
Apple clang version 14.0.0 (clang-1400.0.29.202)
|
67
|
+
Target: arm64-apple-darwin22.2.0
|
68
|
+
Thread model: posix
|
69
|
+
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
70
|
+
|
71
|
+
* [Windows] gcc
|
72
|
+
|
73
|
+
gcc (Rev7, Built by MSYS2 project) 12.2.0
|
74
|
+
|
75
|
+
* [Linux] gcc, clang
|
76
|
+
|
77
|
+
(x86_64) Ubuntu clang version 14.0.0-1ubuntu1
|
78
|
+
(arm64) aarch64-linux-gnu-g++ ( https://packages.ubuntu.com/focal/g++-aarch64-linux-gnu )
|
79
|
+
|
80
|
+
<details>
|
81
|
+
<summary>Older versions</summary>
|
82
|
+
|
83
|
+
* Ruby interpreter
|
84
|
+
* Tested on:
|
85
|
+
* [macOS]
|
86
|
+
* ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin21]
|
87
|
+
* ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
|
88
|
+
* ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin20]
|
89
|
+
* ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
|
90
|
+
* [Windows] https://rubyinstaller.org/downloads/ Ruby+Devkit
|
91
|
+
* ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
|
92
|
+
* ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x64-mingw-ucrt]
|
93
|
+
* ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x64-mingw32]
|
94
|
+
|
95
|
+
* Compiler
|
96
|
+
* Tested on:
|
97
|
+
* [macOS] clang
|
98
|
+
|
99
|
+
$ clang --version
|
100
|
+
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
|
101
|
+
Target: arm64-apple-darwin21.5.0
|
102
|
+
Thread model: posix
|
103
|
+
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
104
|
+
|
105
|
+
$ clang --version
|
106
|
+
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
|
107
|
+
Target: arm64-apple-darwin21.5.0
|
108
|
+
Thread model: posix
|
109
|
+
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
110
|
+
|
111
|
+
Apple clang version 13.0.0 (clang-1300.0.29.3)
|
112
|
+
Target: arm64-apple-darwin20.6.0
|
113
|
+
Thread model: posix
|
114
|
+
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
115
|
+
|
116
|
+
* [Windows] gcc
|
117
|
+
|
118
|
+
gcc (Rev9, Built by MSYS2 project) 11.2.0
|
119
|
+
gcc (Rev10, Built by MSYS2 project) 11.2.0
|
120
|
+
|
121
|
+
</details>
|
122
|
+
|
123
|
+
## Projects ##
|
124
|
+
|
125
|
+
See the projects below to learn how to use this library:
|
126
|
+
|
127
|
+
* Whac-a-Mole! : Ruby raylib bindings demo
|
128
|
+
* <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings-whacamole/main/doc/screenshot_00.png" width="300"> <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings-whacamole/main/doc/screenshot_01.png" width="300">
|
129
|
+
* <https://github.com/vaiorabbit/raylib-bindings-whacamole>
|
130
|
+
|
131
|
+
* 1D dot eater : Ruby raylib bindings demo
|
132
|
+
* <img src="https://raw.githubusercontent.com/vaiorabbit/raylib-bindings-pacone/main/doc/screenshot_00.png" width="600">
|
133
|
+
* <https://github.com/vaiorabbit/raylib-bindings-pacone>
|
134
|
+
|
135
|
+
## Limitation ##
|
136
|
+
|
137
|
+
* `SetTraceLogCallback` and `TraceLogCallback` are unusable since Ruby-FFI does not support `:varargs` parameter in callbacks (`Proc`, etc.)
|
138
|
+
* Ref.: https://ffi.github.io/ruby-ffi-archive/messages/20130214-%5Bruby-ffi%5D%20Re_%20Callback%20Function%20with%20varargs-345.html
|
139
|
+
|
140
|
+
## License ##
|
141
|
+
|
142
|
+
Shared libraries in `lib` directory are built on top of these products and are available under the terms of these licenses:
|
143
|
+
|
144
|
+
* `libraylib.dylib`, `libraylib.dll`, `libraylib.aarch64.so`, `libraylib.x86_64.so`
|
145
|
+
* raylib ( https://github.com/raysan5/raylib )
|
146
|
+
* zlib License https://github.com/raysan5/raylib/blob/master/LICENSE
|
147
|
+
* `raygui.dylib`, `raygui.dll`, `raygui.aarch64.so`, `raygui.x86_64.so`
|
148
|
+
* raygui ( https://github.com/raysan5/raygui )
|
149
|
+
* zlib License https://github.com/raysan5/raygui/blob/master/LICENSE
|
150
|
+
* `physac.dylib`, `physac.dll`, `physac.aarch64.so` `physac.x86_64.so`
|
151
|
+
* Physac ( https://github.com/raysan5/physac )
|
152
|
+
* LICENSE: zlib/libpng https://github.com/raysan5/physac/blob/4a8e17f263fb8e1150b3fbafc96f880c7d7a4833/src/physac.h#L51-L68
|
153
|
+
|
154
|
+
All ruby codes here are available under the terms of the zlib/libpng License ( http://opensource.org/licenses/Zlib ).
|
155
|
+
|
156
|
+
Ruby-raylib : Yet another raylib wrapper for Ruby
|
157
|
+
Copyright (c) 2021-2023 vaiorabbit <http://twitter.com/vaiorabbit>
|
158
|
+
|
159
|
+
This software is provided 'as-is', without any express or implied
|
160
|
+
warranty. In no event will the authors be held liable for any damages
|
161
|
+
arising from the use of this software.
|
162
|
+
|
163
|
+
Permission is granted to anyone to use this software for any purpose,
|
164
|
+
including commercial applications, and to alter it and redistribute it
|
165
|
+
freely, subject to the following restrictions:
|
166
|
+
|
167
|
+
1. The origin of this software must not be misrepresented; you must not
|
168
|
+
claim that you wrote the original software. If you use this software
|
169
|
+
in a product, an acknowledgment in the product documentation would be
|
170
|
+
appreciated but is not required.
|
171
|
+
|
172
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
173
|
+
misrepresented as being the original software.
|
174
|
+
|
175
|
+
3. This notice may not be removed or altered from any source
|
176
|
+
distribution.
|
data/examples/template.rb
CHANGED
@@ -1,143 +1,143 @@
|
|
1
|
-
# Yet another raylib wrapper for Ruby
|
2
|
-
#
|
3
|
-
# * https://github.com/vaiorabbit/raylib-bindings
|
4
|
-
#
|
5
|
-
# Demonstrates several key features including:
|
6
|
-
# * Core : window management, camera, etc.
|
7
|
-
# * Gameplay : fetching player input, collision handling, etc.
|
8
|
-
# * Rendering : drawing shapes, texts, etc.
|
9
|
-
#
|
10
|
-
# To get more information, see:
|
11
|
-
# * https://www.raylib.com/cheatsheet/cheatsheet.html for API reference
|
12
|
-
# * https://github.com/vaiorabbit/raylib-bindings/tree/main/examples for more actual codes written in Ruby
|
13
|
-
|
14
|
-
require 'raylib'
|
15
|
-
|
16
|
-
shared_lib_path = Gem::Specification.find_by_name('raylib-bindings').full_gem_path + '/lib/'
|
17
|
-
|
18
|
-
case RUBY_PLATFORM
|
19
|
-
when /mswin|msys|mingw|cygwin/
|
20
|
-
Raylib.load_lib(shared_lib_path + 'libraylib.dll', raygui_libpath: shared_lib_path + 'raygui.dll', physac_libpath: shared_lib_path + 'physac.dll')
|
21
|
-
when /darwin/
|
22
|
-
Raylib.load_lib(shared_lib_path + 'libraylib.dylib', raygui_libpath: shared_lib_path + 'raygui.dylib', physac_libpath: shared_lib_path + 'physac.dylib')
|
23
|
-
when /linux/
|
24
|
-
arch = RUBY_PLATFORM.split('-')[0]
|
25
|
-
Raylib.load_lib(shared_lib_path + "libraylib.#{arch}.so", raygui_libpath: shared_lib_path + "raygui.#{arch}.so", physac_libpath: shared_lib_path + "physac.#{arch}.so")
|
26
|
-
else
|
27
|
-
raise RuntimeError, "Unknown OS: #{RUBY_PLATFORM}"
|
28
|
-
end
|
29
|
-
|
30
|
-
include Raylib
|
31
|
-
|
32
|
-
if __FILE__ == $PROGRAM_NAME
|
33
|
-
screen_width = 1280
|
34
|
-
screen_height = 720
|
35
|
-
InitWindow(screen_width, screen_height, "Yet Another Ruby-raylib bindings")
|
36
|
-
SetTargetFPS(60)
|
37
|
-
|
38
|
-
ruby_red = Color.from_u8(155, 17, 30, 255)
|
39
|
-
|
40
|
-
# Camera
|
41
|
-
camera = Camera.new
|
42
|
-
reset_camera = lambda {
|
43
|
-
camera.position.set(0.0, 10.0, 10.0)
|
44
|
-
camera.target.set(0.0, 0.0, 0.0)
|
45
|
-
camera.up.set(0.0, 1.0, 0.0)
|
46
|
-
camera.fovy = 45.0
|
47
|
-
camera.projection = CAMERA_PERSPECTIVE
|
48
|
-
}
|
49
|
-
reset_camera.call
|
50
|
-
camera_mode = CAMERA_CUSTOM
|
51
|
-
auto_rotate = false
|
52
|
-
|
53
|
-
# Player (red cube) settings
|
54
|
-
player_pos = Vector3.create(0.0, 0.0, 0.0)
|
55
|
-
player_size = Vector3.create(2.0, 2.0, 2.0)
|
56
|
-
speed = 0.25
|
57
|
-
|
58
|
-
# Obstacle settings
|
59
|
-
obstacle_cube_pos = Vector3.create(-4.0, 1.0, 0.0)
|
60
|
-
obstacle_cube_size = Vector3.create(2.0, 2.0, 2.0)
|
61
|
-
obstacle_sphere_pos = Vector3.create(4.0, 0.0, 0.0)
|
62
|
-
obstacle_sphere_size = 1.5
|
63
|
-
|
64
|
-
until WindowShouldClose()
|
65
|
-
### Update phase
|
66
|
-
|
67
|
-
# Reset camera settings
|
68
|
-
if IsKeyPressed(KEY_F1)
|
69
|
-
auto_rotate = !auto_rotate
|
70
|
-
reset_camera.call
|
71
|
-
camera_mode = auto_rotate ? CAMERA_ORBITAL : CAMERA_CUSTOM
|
72
|
-
end
|
73
|
-
UpdateCamera(camera.pointer, camera_mode) if auto_rotate
|
74
|
-
|
75
|
-
# Calculate move direction
|
76
|
-
move = Vector3.create(0, 0, 0)
|
77
|
-
move.x += speed if IsKeyDown(KEY_RIGHT)
|
78
|
-
move.x -= speed if IsKeyDown(KEY_LEFT)
|
79
|
-
move.z += speed if IsKeyDown(KEY_DOWN)
|
80
|
-
move.z -= speed if IsKeyDown(KEY_UP)
|
81
|
-
|
82
|
-
to_camera = Vector3Normalize(Vector3.create(camera.position.x, 0, camera.position.z))
|
83
|
-
rotate_y = QuaternionFromVector3ToVector3(Vector3.create(0, 0, 1), to_camera)
|
84
|
-
move = Vector3RotateByQuaternion(move, rotate_y)
|
85
|
-
|
86
|
-
player_pos = Vector3Add(player_pos, move)
|
87
|
-
player_screen_pos = GetWorldToScreen(Vector3.create(player_pos.x, player_pos.y + 2.5, player_pos.z), camera)
|
88
|
-
|
89
|
-
# Check collision status
|
90
|
-
collision = false
|
91
|
-
|
92
|
-
player_bbox = BoundingBox.new
|
93
|
-
.with_min(player_pos.x - player_size.x/2, player_pos.y - player_size.y/2, player_pos.z - player_size.z/2)
|
94
|
-
.with_max(player_pos.x + player_size.x/2, player_pos.y + player_size.y/2, player_pos.z + player_size.z/2)
|
95
|
-
|
96
|
-
obstacle_cube_bbox = BoundingBox.new
|
97
|
-
.with_min(obstacle_cube_pos.x - obstacle_cube_size.x/2, obstacle_cube_pos.y - obstacle_cube_size.y/2, obstacle_cube_pos.z - obstacle_cube_size.z/2)
|
98
|
-
.with_max(obstacle_cube_pos.x + obstacle_cube_size.x/2, obstacle_cube_pos.y + obstacle_cube_size.y/2, obstacle_cube_pos.z + obstacle_cube_size.z/2)
|
99
|
-
|
100
|
-
# Check collisions player vs obstacle_cube
|
101
|
-
collision = true if CheckCollisionBoxes(player_bbox, obstacle_cube_bbox)
|
102
|
-
|
103
|
-
# Check collisions player vs obstacle_sphere
|
104
|
-
collision = true if CheckCollisionBoxSphere(player_bbox, obstacle_sphere_pos, obstacle_sphere_size)
|
105
|
-
|
106
|
-
### Rendering phase
|
107
|
-
|
108
|
-
BeginDrawing()
|
109
|
-
|
110
|
-
ClearBackground(RAYWHITE)
|
111
|
-
|
112
|
-
## 3D scene
|
113
|
-
BeginMode3D(camera)
|
114
|
-
# Red cube
|
115
|
-
DrawCube(player_pos, 2.0, 2.0, 2.0, collision ? Fade(ruby_red, 0.25) : ruby_red)
|
116
|
-
DrawCubeWires(player_pos, 2.0, 2.0, 2.0, MAROON)
|
117
|
-
# Obstacle cube
|
118
|
-
DrawCube(obstacle_cube_pos, obstacle_cube_size.x, obstacle_cube_size.y, obstacle_cube_size.z, GRAY)
|
119
|
-
DrawCubeWires(obstacle_cube_pos, obstacle_cube_size.x, obstacle_cube_size.y, obstacle_cube_size.z, DARKGRAY)
|
120
|
-
# Obstacle sphere
|
121
|
-
DrawSphere(obstacle_sphere_pos, obstacle_sphere_size, GRAY)
|
122
|
-
DrawSphereWires(obstacle_sphere_pos, obstacle_sphere_size, 16, 16, DARKGRAY)
|
123
|
-
# Floor
|
124
|
-
DrawGrid(10, 1)
|
125
|
-
EndMode3D()
|
126
|
-
|
127
|
-
## HUD
|
128
|
-
# Text over the red cube
|
129
|
-
DrawText("Player HP: 100 / 100", player_screen_pos.x - MeasureText("Player HP: 100/100", 20)/2, player_screen_pos.y, 20, BLACK)
|
130
|
-
# Help message
|
131
|
-
DrawRectangle(10, screen_height - 100, 300, 80, Fade(MAROON, 0.25))
|
132
|
-
DrawRectangleLines(10, screen_height - 100, 300, 80, ruby_red)
|
133
|
-
DrawText("Arrow keys : move red cube", 20, screen_height - 90, 20, BLACK)
|
134
|
-
DrawText("F1 : camera rotation", 20, screen_height - 70, 20, BLACK)
|
135
|
-
DrawText("ESC : exit", 20, screen_height - 50, 20, BLACK)
|
136
|
-
# FPS
|
137
|
-
DrawFPS(screen_width - 100, 16)
|
138
|
-
|
139
|
-
EndDrawing()
|
140
|
-
end
|
141
|
-
|
142
|
-
CloseWindow()
|
143
|
-
end
|
1
|
+
# Yet another raylib wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/raylib-bindings
|
4
|
+
#
|
5
|
+
# Demonstrates several key features including:
|
6
|
+
# * Core : window management, camera, etc.
|
7
|
+
# * Gameplay : fetching player input, collision handling, etc.
|
8
|
+
# * Rendering : drawing shapes, texts, etc.
|
9
|
+
#
|
10
|
+
# To get more information, see:
|
11
|
+
# * https://www.raylib.com/cheatsheet/cheatsheet.html for API reference
|
12
|
+
# * https://github.com/vaiorabbit/raylib-bindings/tree/main/examples for more actual codes written in Ruby
|
13
|
+
|
14
|
+
require 'raylib'
|
15
|
+
|
16
|
+
shared_lib_path = Gem::Specification.find_by_name('raylib-bindings').full_gem_path + '/lib/'
|
17
|
+
|
18
|
+
case RUBY_PLATFORM
|
19
|
+
when /mswin|msys|mingw|cygwin/
|
20
|
+
Raylib.load_lib(shared_lib_path + 'libraylib.dll', raygui_libpath: shared_lib_path + 'raygui.dll', physac_libpath: shared_lib_path + 'physac.dll')
|
21
|
+
when /darwin/
|
22
|
+
Raylib.load_lib(shared_lib_path + 'libraylib.dylib', raygui_libpath: shared_lib_path + 'raygui.dylib', physac_libpath: shared_lib_path + 'physac.dylib')
|
23
|
+
when /linux/
|
24
|
+
arch = RUBY_PLATFORM.split('-')[0]
|
25
|
+
Raylib.load_lib(shared_lib_path + "libraylib.#{arch}.so", raygui_libpath: shared_lib_path + "raygui.#{arch}.so", physac_libpath: shared_lib_path + "physac.#{arch}.so")
|
26
|
+
else
|
27
|
+
raise RuntimeError, "Unknown OS: #{RUBY_PLATFORM}"
|
28
|
+
end
|
29
|
+
|
30
|
+
include Raylib
|
31
|
+
|
32
|
+
if __FILE__ == $PROGRAM_NAME
|
33
|
+
screen_width = 1280
|
34
|
+
screen_height = 720
|
35
|
+
InitWindow(screen_width, screen_height, "Yet Another Ruby-raylib bindings")
|
36
|
+
SetTargetFPS(60)
|
37
|
+
|
38
|
+
ruby_red = Color.from_u8(155, 17, 30, 255)
|
39
|
+
|
40
|
+
# Camera
|
41
|
+
camera = Camera.new
|
42
|
+
reset_camera = lambda {
|
43
|
+
camera.position.set(0.0, 10.0, 10.0)
|
44
|
+
camera.target.set(0.0, 0.0, 0.0)
|
45
|
+
camera.up.set(0.0, 1.0, 0.0)
|
46
|
+
camera.fovy = 45.0
|
47
|
+
camera.projection = CAMERA_PERSPECTIVE
|
48
|
+
}
|
49
|
+
reset_camera.call
|
50
|
+
camera_mode = CAMERA_CUSTOM
|
51
|
+
auto_rotate = false
|
52
|
+
|
53
|
+
# Player (red cube) settings
|
54
|
+
player_pos = Vector3.create(0.0, 0.0, 0.0)
|
55
|
+
player_size = Vector3.create(2.0, 2.0, 2.0)
|
56
|
+
speed = 0.25
|
57
|
+
|
58
|
+
# Obstacle settings
|
59
|
+
obstacle_cube_pos = Vector3.create(-4.0, 1.0, 0.0)
|
60
|
+
obstacle_cube_size = Vector3.create(2.0, 2.0, 2.0)
|
61
|
+
obstacle_sphere_pos = Vector3.create(4.0, 0.0, 0.0)
|
62
|
+
obstacle_sphere_size = 1.5
|
63
|
+
|
64
|
+
until WindowShouldClose()
|
65
|
+
### Update phase
|
66
|
+
|
67
|
+
# Reset camera settings
|
68
|
+
if IsKeyPressed(KEY_F1)
|
69
|
+
auto_rotate = !auto_rotate
|
70
|
+
reset_camera.call
|
71
|
+
camera_mode = auto_rotate ? CAMERA_ORBITAL : CAMERA_CUSTOM
|
72
|
+
end
|
73
|
+
UpdateCamera(camera.pointer, camera_mode) if auto_rotate
|
74
|
+
|
75
|
+
# Calculate move direction
|
76
|
+
move = Vector3.create(0, 0, 0)
|
77
|
+
move.x += speed if IsKeyDown(KEY_RIGHT)
|
78
|
+
move.x -= speed if IsKeyDown(KEY_LEFT)
|
79
|
+
move.z += speed if IsKeyDown(KEY_DOWN)
|
80
|
+
move.z -= speed if IsKeyDown(KEY_UP)
|
81
|
+
|
82
|
+
to_camera = Vector3Normalize(Vector3.create(camera.position.x, 0, camera.position.z))
|
83
|
+
rotate_y = QuaternionFromVector3ToVector3(Vector3.create(0, 0, 1), to_camera)
|
84
|
+
move = Vector3RotateByQuaternion(move, rotate_y)
|
85
|
+
|
86
|
+
player_pos = Vector3Add(player_pos, move)
|
87
|
+
player_screen_pos = GetWorldToScreen(Vector3.create(player_pos.x, player_pos.y + 2.5, player_pos.z), camera)
|
88
|
+
|
89
|
+
# Check collision status
|
90
|
+
collision = false
|
91
|
+
|
92
|
+
player_bbox = BoundingBox.new
|
93
|
+
.with_min(player_pos.x - player_size.x/2, player_pos.y - player_size.y/2, player_pos.z - player_size.z/2)
|
94
|
+
.with_max(player_pos.x + player_size.x/2, player_pos.y + player_size.y/2, player_pos.z + player_size.z/2)
|
95
|
+
|
96
|
+
obstacle_cube_bbox = BoundingBox.new
|
97
|
+
.with_min(obstacle_cube_pos.x - obstacle_cube_size.x/2, obstacle_cube_pos.y - obstacle_cube_size.y/2, obstacle_cube_pos.z - obstacle_cube_size.z/2)
|
98
|
+
.with_max(obstacle_cube_pos.x + obstacle_cube_size.x/2, obstacle_cube_pos.y + obstacle_cube_size.y/2, obstacle_cube_pos.z + obstacle_cube_size.z/2)
|
99
|
+
|
100
|
+
# Check collisions player vs obstacle_cube
|
101
|
+
collision = true if CheckCollisionBoxes(player_bbox, obstacle_cube_bbox)
|
102
|
+
|
103
|
+
# Check collisions player vs obstacle_sphere
|
104
|
+
collision = true if CheckCollisionBoxSphere(player_bbox, obstacle_sphere_pos, obstacle_sphere_size)
|
105
|
+
|
106
|
+
### Rendering phase
|
107
|
+
|
108
|
+
BeginDrawing()
|
109
|
+
|
110
|
+
ClearBackground(RAYWHITE)
|
111
|
+
|
112
|
+
## 3D scene
|
113
|
+
BeginMode3D(camera)
|
114
|
+
# Red cube
|
115
|
+
DrawCube(player_pos, 2.0, 2.0, 2.0, collision ? Fade(ruby_red, 0.25) : ruby_red)
|
116
|
+
DrawCubeWires(player_pos, 2.0, 2.0, 2.0, MAROON)
|
117
|
+
# Obstacle cube
|
118
|
+
DrawCube(obstacle_cube_pos, obstacle_cube_size.x, obstacle_cube_size.y, obstacle_cube_size.z, GRAY)
|
119
|
+
DrawCubeWires(obstacle_cube_pos, obstacle_cube_size.x, obstacle_cube_size.y, obstacle_cube_size.z, DARKGRAY)
|
120
|
+
# Obstacle sphere
|
121
|
+
DrawSphere(obstacle_sphere_pos, obstacle_sphere_size, GRAY)
|
122
|
+
DrawSphereWires(obstacle_sphere_pos, obstacle_sphere_size, 16, 16, DARKGRAY)
|
123
|
+
# Floor
|
124
|
+
DrawGrid(10, 1)
|
125
|
+
EndMode3D()
|
126
|
+
|
127
|
+
## HUD
|
128
|
+
# Text over the red cube
|
129
|
+
DrawText("Player HP: 100 / 100", player_screen_pos.x - MeasureText("Player HP: 100/100", 20)/2, player_screen_pos.y, 20, BLACK)
|
130
|
+
# Help message
|
131
|
+
DrawRectangle(10, screen_height - 100, 300, 80, Fade(MAROON, 0.25))
|
132
|
+
DrawRectangleLines(10, screen_height - 100, 300, 80, ruby_red)
|
133
|
+
DrawText("Arrow keys : move red cube", 20, screen_height - 90, 20, BLACK)
|
134
|
+
DrawText("F1 : camera rotation", 20, screen_height - 70, 20, BLACK)
|
135
|
+
DrawText("ESC : exit", 20, screen_height - 50, 20, BLACK)
|
136
|
+
# FPS
|
137
|
+
DrawFPS(screen_width - 100, 16)
|
138
|
+
|
139
|
+
EndDrawing()
|
140
|
+
end
|
141
|
+
|
142
|
+
CloseWindow()
|
143
|
+
end
|