raylib-bindings 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +300 -254
- data/LICENSE.txt +0 -0
- data/README.md +176 -154
- data/examples/template.rb +149 -148
- data/lib/config.rb +98 -98
- data/lib/libraylib.aarch64.so +0 -0
- data/lib/libraylib.dll +0 -0
- data/lib/libraylib.dylib +0 -0
- data/lib/libraylib.x86_64.so +0 -0
- data/lib/physac.aarch64.so +0 -0
- data/lib/physac.dll +0 -0
- data/lib/physac.dylib +0 -0
- data/lib/physac.rb +304 -222
- data/lib/physac.x86_64.so +0 -0
- data/lib/raygui.aarch64.so +0 -0
- data/lib/raygui.dll +0 -0
- data/lib/raygui.dylib +0 -0
- data/lib/raygui.rb +801 -790
- data/lib/raygui.x86_64.so +0 -0
- data/lib/raylib.rb +59 -59
- data/lib/raylib_helper.rb +311 -419
- data/lib/raylib_main.rb +4283 -3921
- data/lib/raymath.rb +719 -709
- data/lib/rlgl.rb +1141 -1100
- metadata +9 -3
data/lib/physac.rb
CHANGED
@@ -1,222 +1,304 @@
|
|
1
|
-
# Yet another raylib wrapper for Ruby
|
2
|
-
#
|
3
|
-
# * https://github.com/vaiorabbit/raylib-bindings
|
4
|
-
#
|
5
|
-
# [NOTICE] Autogenerated. Do not edit.
|
6
|
-
|
7
|
-
require 'ffi'
|
8
|
-
|
9
|
-
module Raylib
|
10
|
-
extend FFI::Library
|
11
|
-
|
12
|
-
# Define/Macro
|
13
|
-
|
14
|
-
PHYSAC_MAX_BODIES = 64
|
15
|
-
PHYSAC_MAX_MANIFOLDS = 4096
|
16
|
-
PHYSAC_MAX_VERTICES = 24
|
17
|
-
PHYSAC_DEFAULT_CIRCLE_VERTICES = 24 # Default number of vertices for circle shapes
|
18
|
-
PHYSAC_COLLISION_ITERATIONS = 100
|
19
|
-
PHYSAC_PENETRATION_ALLOWANCE = 0.05
|
20
|
-
PHYSAC_PENETRATION_CORRECTION = 0.4
|
21
|
-
PHYSAC_PI = 3.14159265358979323846
|
22
|
-
|
23
|
-
# Enum
|
24
|
-
|
25
|
-
# enum PhysicsShapeType
|
26
|
-
PHYSICS_CIRCLE = 0
|
27
|
-
PHYSICS_POLYGON = 1
|
28
|
-
|
29
|
-
|
30
|
-
# Typedef
|
31
|
-
|
32
|
-
typedef :int, :PhysicsShapeType
|
33
|
-
typedef :pointer, :PhysicsBody
|
34
|
-
typedef :pointer, :PhysicsManifold
|
35
|
-
|
36
|
-
# Struct
|
37
|
-
|
38
|
-
# Matrix2x2 type (used for polygon shape rotation matrix)
|
39
|
-
class Matrix2x2 < FFI::Struct
|
40
|
-
layout(
|
41
|
-
:m00, :float,
|
42
|
-
:m01, :float,
|
43
|
-
:m10, :float,
|
44
|
-
:m11, :float,
|
45
|
-
)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
class
|
57
|
-
layout(
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
|
62
|
-
|
63
|
-
)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
)
|
88
|
-
end
|
89
|
-
|
90
|
-
class
|
91
|
-
layout(
|
92
|
-
:id, :uint,
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:
|
98
|
-
:
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
#
|
163
|
-
#
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
#
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
#
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
#
|
202
|
-
# @return [
|
203
|
-
[:
|
204
|
-
|
205
|
-
#
|
206
|
-
# @
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
#
|
211
|
-
# @
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
1
|
+
# Yet another raylib wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/raylib-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] Autogenerated. Do not edit.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module Raylib
|
10
|
+
extend FFI::Library
|
11
|
+
|
12
|
+
# Define/Macro
|
13
|
+
|
14
|
+
PHYSAC_MAX_BODIES = 64 # Maximum number of physic bodies supported
|
15
|
+
PHYSAC_MAX_MANIFOLDS = 4096 # Maximum number of physic bodies interactions (64x64)
|
16
|
+
PHYSAC_MAX_VERTICES = 24 # Maximum number of vertex for polygons shapes
|
17
|
+
PHYSAC_DEFAULT_CIRCLE_VERTICES = 24 # Default number of vertices for circle shapes
|
18
|
+
PHYSAC_COLLISION_ITERATIONS = 100
|
19
|
+
PHYSAC_PENETRATION_ALLOWANCE = 0.05
|
20
|
+
PHYSAC_PENETRATION_CORRECTION = 0.4
|
21
|
+
PHYSAC_PI = 3.14159265358979323846
|
22
|
+
|
23
|
+
# Enum
|
24
|
+
|
25
|
+
# enum PhysicsShapeType
|
26
|
+
PHYSICS_CIRCLE = 0
|
27
|
+
PHYSICS_POLYGON = 1
|
28
|
+
|
29
|
+
|
30
|
+
# Typedef
|
31
|
+
|
32
|
+
typedef :int, :PhysicsShapeType
|
33
|
+
typedef :pointer, :PhysicsBody
|
34
|
+
typedef :pointer, :PhysicsManifold
|
35
|
+
|
36
|
+
# Struct
|
37
|
+
|
38
|
+
# Matrix2x2 type (used for polygon shape rotation matrix)
|
39
|
+
class Matrix2x2 < FFI::Struct
|
40
|
+
layout(
|
41
|
+
:m00, :float,
|
42
|
+
:m01, :float,
|
43
|
+
:m10, :float,
|
44
|
+
:m11, :float,
|
45
|
+
)
|
46
|
+
def m00 = self[:m00]
|
47
|
+
def m00=(v) self[:m00] = v end
|
48
|
+
def m01 = self[:m01]
|
49
|
+
def m01=(v) self[:m01] = v end
|
50
|
+
def m10 = self[:m10]
|
51
|
+
def m10=(v) self[:m10] = v end
|
52
|
+
def m11 = self[:m11]
|
53
|
+
def m11=(v) self[:m11] = v end
|
54
|
+
end
|
55
|
+
|
56
|
+
class PhysicsVertexData < FFI::Struct
|
57
|
+
layout(
|
58
|
+
:vertexCount, :uint, # Vertex count (positions and normals)
|
59
|
+
:positions, [Vector2, 24], # Vertex positions vectors
|
60
|
+
:normals, [Vector2, 24], # Vertex normals vectors
|
61
|
+
)
|
62
|
+
def vertexCount = self[:vertexCount]
|
63
|
+
def vertexCount=(v) self[:vertexCount] = v end
|
64
|
+
def positions = self[:positions]
|
65
|
+
def positions=(v) self[:positions] = v end
|
66
|
+
def normals = self[:normals]
|
67
|
+
def normals=(v) self[:normals] = v end
|
68
|
+
end
|
69
|
+
|
70
|
+
class PhysicsShape < FFI::Struct
|
71
|
+
layout(
|
72
|
+
:type, :int, # Shape type (circle or polygon)
|
73
|
+
:body, :pointer, # Shape physics body data pointer
|
74
|
+
:vertexData, PhysicsVertexData, # Shape vertices data (used for polygon shapes)
|
75
|
+
:radius, :float, # Shape radius (used for circle shapes)
|
76
|
+
:transform, Matrix2x2, # Vertices transform matrix 2x2
|
77
|
+
)
|
78
|
+
def type = self[:type]
|
79
|
+
def type=(v) self[:type] = v end
|
80
|
+
def body = self[:body]
|
81
|
+
def body=(v) self[:body] = v end
|
82
|
+
def vertexData = self[:vertexData]
|
83
|
+
def vertexData=(v) self[:vertexData] = v end
|
84
|
+
def radius = self[:radius]
|
85
|
+
def radius=(v) self[:radius] = v end
|
86
|
+
def transform = self[:transform]
|
87
|
+
def transform=(v) self[:transform] = v end
|
88
|
+
end
|
89
|
+
|
90
|
+
class PhysicsBodyData < FFI::Struct
|
91
|
+
layout(
|
92
|
+
:id, :uint, # Unique identifier
|
93
|
+
:enabled, :bool, # Enabled dynamics state (collisions are calculated anyway)
|
94
|
+
:position, Vector2, # Physics body shape pivot
|
95
|
+
:velocity, Vector2, # Current linear velocity applied to position
|
96
|
+
:force, Vector2, # Current linear force (reset to 0 every step)
|
97
|
+
:angularVelocity, :float, # Current angular velocity applied to orient
|
98
|
+
:torque, :float, # Current angular force (reset to 0 every step)
|
99
|
+
:orient, :float, # Rotation in radians
|
100
|
+
:inertia, :float, # Moment of inertia
|
101
|
+
:inverseInertia, :float, # Inverse value of inertia
|
102
|
+
:mass, :float, # Physics body mass
|
103
|
+
:inverseMass, :float, # Inverse value of mass
|
104
|
+
:staticFriction, :float, # Friction when the body has not movement (0 to 1)
|
105
|
+
:dynamicFriction, :float, # Friction when the body has movement (0 to 1)
|
106
|
+
:restitution, :float, # Restitution coefficient of the body (0 to 1)
|
107
|
+
:useGravity, :bool, # Apply gravity force to dynamics
|
108
|
+
:isGrounded, :bool, # Physics grounded on other body state
|
109
|
+
:freezeOrient, :bool, # Physics rotation constraint
|
110
|
+
:shape, PhysicsShape, # Physics body shape information (type, radius, vertices, transform)
|
111
|
+
)
|
112
|
+
def id = self[:id]
|
113
|
+
def id=(v) self[:id] = v end
|
114
|
+
def enabled = self[:enabled]
|
115
|
+
def enabled=(v) self[:enabled] = v end
|
116
|
+
def position = self[:position]
|
117
|
+
def position=(v) self[:position] = v end
|
118
|
+
def velocity = self[:velocity]
|
119
|
+
def velocity=(v) self[:velocity] = v end
|
120
|
+
def force = self[:force]
|
121
|
+
def force=(v) self[:force] = v end
|
122
|
+
def angularVelocity = self[:angularVelocity]
|
123
|
+
def angularVelocity=(v) self[:angularVelocity] = v end
|
124
|
+
def torque = self[:torque]
|
125
|
+
def torque=(v) self[:torque] = v end
|
126
|
+
def orient = self[:orient]
|
127
|
+
def orient=(v) self[:orient] = v end
|
128
|
+
def inertia = self[:inertia]
|
129
|
+
def inertia=(v) self[:inertia] = v end
|
130
|
+
def inverseInertia = self[:inverseInertia]
|
131
|
+
def inverseInertia=(v) self[:inverseInertia] = v end
|
132
|
+
def mass = self[:mass]
|
133
|
+
def mass=(v) self[:mass] = v end
|
134
|
+
def inverseMass = self[:inverseMass]
|
135
|
+
def inverseMass=(v) self[:inverseMass] = v end
|
136
|
+
def staticFriction = self[:staticFriction]
|
137
|
+
def staticFriction=(v) self[:staticFriction] = v end
|
138
|
+
def dynamicFriction = self[:dynamicFriction]
|
139
|
+
def dynamicFriction=(v) self[:dynamicFriction] = v end
|
140
|
+
def restitution = self[:restitution]
|
141
|
+
def restitution=(v) self[:restitution] = v end
|
142
|
+
def useGravity = self[:useGravity]
|
143
|
+
def useGravity=(v) self[:useGravity] = v end
|
144
|
+
def isGrounded = self[:isGrounded]
|
145
|
+
def isGrounded=(v) self[:isGrounded] = v end
|
146
|
+
def freezeOrient = self[:freezeOrient]
|
147
|
+
def freezeOrient=(v) self[:freezeOrient] = v end
|
148
|
+
def shape = self[:shape]
|
149
|
+
def shape=(v) self[:shape] = v end
|
150
|
+
end
|
151
|
+
|
152
|
+
class PhysicsManifoldData < FFI::Struct
|
153
|
+
layout(
|
154
|
+
:id, :uint, # Unique identifier
|
155
|
+
:bodyA, :pointer, # Manifold first physics body reference
|
156
|
+
:bodyB, :pointer, # Manifold second physics body reference
|
157
|
+
:penetration, :float, # Depth of penetration from collision
|
158
|
+
:normal, Vector2, # Normal direction vector from 'a' to 'b'
|
159
|
+
:contacts, [Vector2, 2], # Points of contact during collision
|
160
|
+
:contactsCount, :uint, # Current collision number of contacts
|
161
|
+
:restitution, :float, # Mixed restitution during collision
|
162
|
+
:dynamicFriction, :float, # Mixed dynamic friction during collision
|
163
|
+
:staticFriction, :float, # Mixed static friction during collision
|
164
|
+
)
|
165
|
+
def id = self[:id]
|
166
|
+
def id=(v) self[:id] = v end
|
167
|
+
def bodyA = self[:bodyA]
|
168
|
+
def bodyA=(v) self[:bodyA] = v end
|
169
|
+
def bodyB = self[:bodyB]
|
170
|
+
def bodyB=(v) self[:bodyB] = v end
|
171
|
+
def penetration = self[:penetration]
|
172
|
+
def penetration=(v) self[:penetration] = v end
|
173
|
+
def normal = self[:normal]
|
174
|
+
def normal=(v) self[:normal] = v end
|
175
|
+
def contacts = self[:contacts]
|
176
|
+
def contacts=(v) self[:contacts] = v end
|
177
|
+
def contactsCount = self[:contactsCount]
|
178
|
+
def contactsCount=(v) self[:contactsCount] = v end
|
179
|
+
def restitution = self[:restitution]
|
180
|
+
def restitution=(v) self[:restitution] = v end
|
181
|
+
def dynamicFriction = self[:dynamicFriction]
|
182
|
+
def dynamicFriction=(v) self[:dynamicFriction] = v end
|
183
|
+
def staticFriction = self[:staticFriction]
|
184
|
+
def staticFriction=(v) self[:staticFriction] = v end
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
# Function
|
189
|
+
|
190
|
+
def self.setup_physac_symbols
|
191
|
+
entries = [
|
192
|
+
|
193
|
+
# InitPhysics : Initializes physics system
|
194
|
+
# @return [void]
|
195
|
+
[:InitPhysics, :InitPhysics, [], :void],
|
196
|
+
|
197
|
+
# UpdatePhysics : Update physics system
|
198
|
+
# @return [void]
|
199
|
+
[:UpdatePhysics, :UpdatePhysics, [], :void],
|
200
|
+
|
201
|
+
# ResetPhysics : Reset physics system (global variables)
|
202
|
+
# @return [void]
|
203
|
+
[:ResetPhysics, :ResetPhysics, [], :void],
|
204
|
+
|
205
|
+
# ClosePhysics : Close physics system and unload used memory
|
206
|
+
# @return [void]
|
207
|
+
[:ClosePhysics, :ClosePhysics, [], :void],
|
208
|
+
|
209
|
+
# SetPhysicsTimeStep : Sets physics fixed time step in milliseconds. 1.666666 by default
|
210
|
+
# @param delta [double]
|
211
|
+
# @return [void]
|
212
|
+
[:SetPhysicsTimeStep, :SetPhysicsTimeStep, [:double], :void],
|
213
|
+
|
214
|
+
# SetPhysicsGravity : Sets physics global gravity force
|
215
|
+
# @param x [float]
|
216
|
+
# @param y [float]
|
217
|
+
# @return [void]
|
218
|
+
[:SetPhysicsGravity, :SetPhysicsGravity, [:float, :float], :void],
|
219
|
+
|
220
|
+
# CreatePhysicsBodyCircle : Creates a new circle physics body with generic parameters
|
221
|
+
# @param pos [Vector2]
|
222
|
+
# @param radius [float]
|
223
|
+
# @param density [float]
|
224
|
+
# @return [PhysicsBody]
|
225
|
+
[:CreatePhysicsBodyCircle, :CreatePhysicsBodyCircle, [Vector2.by_value, :float, :float], :pointer],
|
226
|
+
|
227
|
+
# CreatePhysicsBodyRectangle : Creates a new rectangle physics body with generic parameters
|
228
|
+
# @param pos [Vector2]
|
229
|
+
# @param width [float]
|
230
|
+
# @param height [float]
|
231
|
+
# @param density [float]
|
232
|
+
# @return [PhysicsBody]
|
233
|
+
[:CreatePhysicsBodyRectangle, :CreatePhysicsBodyRectangle, [Vector2.by_value, :float, :float, :float], :pointer],
|
234
|
+
|
235
|
+
# CreatePhysicsBodyPolygon : Creates a new polygon physics body with generic parameters
|
236
|
+
# @param pos [Vector2]
|
237
|
+
# @param radius [float]
|
238
|
+
# @param sides [int]
|
239
|
+
# @param density [float]
|
240
|
+
# @return [PhysicsBody]
|
241
|
+
[:CreatePhysicsBodyPolygon, :CreatePhysicsBodyPolygon, [Vector2.by_value, :float, :int, :float], :pointer],
|
242
|
+
|
243
|
+
# DestroyPhysicsBody : Destroy a physics body
|
244
|
+
# @param body [PhysicsBody]
|
245
|
+
# @return [void]
|
246
|
+
[:DestroyPhysicsBody, :DestroyPhysicsBody, [:pointer], :void],
|
247
|
+
|
248
|
+
# PhysicsAddForce : Adds a force to a physics body
|
249
|
+
# @param body [PhysicsBody]
|
250
|
+
# @param force [Vector2]
|
251
|
+
# @return [void]
|
252
|
+
[:PhysicsAddForce, :PhysicsAddForce, [:pointer, Vector2.by_value], :void],
|
253
|
+
|
254
|
+
# PhysicsAddTorque : Adds an angular force to a physics body
|
255
|
+
# @param body [PhysicsBody]
|
256
|
+
# @param amount [float]
|
257
|
+
# @return [void]
|
258
|
+
[:PhysicsAddTorque, :PhysicsAddTorque, [:pointer, :float], :void],
|
259
|
+
|
260
|
+
# PhysicsShatter : Shatters a polygon shape physics body to little physics bodies with explosion force
|
261
|
+
# @param body [PhysicsBody]
|
262
|
+
# @param position [Vector2]
|
263
|
+
# @param force [float]
|
264
|
+
# @return [void]
|
265
|
+
[:PhysicsShatter, :PhysicsShatter, [:pointer, Vector2.by_value, :float], :void],
|
266
|
+
|
267
|
+
# SetPhysicsBodyRotation : Sets physics body shape transform based on radians parameter
|
268
|
+
# @param body [PhysicsBody]
|
269
|
+
# @param radians [float]
|
270
|
+
# @return [void]
|
271
|
+
[:SetPhysicsBodyRotation, :SetPhysicsBodyRotation, [:pointer, :float], :void],
|
272
|
+
|
273
|
+
# GetPhysicsBody : Returns a physics body of the bodies pool at a specific index
|
274
|
+
# @param index [int]
|
275
|
+
# @return [PhysicsBody]
|
276
|
+
[:GetPhysicsBody, :GetPhysicsBody, [:int], :pointer],
|
277
|
+
|
278
|
+
# GetPhysicsBodiesCount : Returns the current amount of created physics bodies
|
279
|
+
# @return [int]
|
280
|
+
[:GetPhysicsBodiesCount, :GetPhysicsBodiesCount, [], :int],
|
281
|
+
|
282
|
+
# GetPhysicsShapeType : Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
|
283
|
+
# @param index [int]
|
284
|
+
# @return [int]
|
285
|
+
[:GetPhysicsShapeType, :GetPhysicsShapeType, [:int], :int],
|
286
|
+
|
287
|
+
# GetPhysicsShapeVerticesCount : Returns the amount of vertices of a physics body shape
|
288
|
+
# @param index [int]
|
289
|
+
# @return [int]
|
290
|
+
[:GetPhysicsShapeVerticesCount, :GetPhysicsShapeVerticesCount, [:int], :int],
|
291
|
+
|
292
|
+
# GetPhysicsShapeVertex : Returns transformed position of a body shape (body position + vertex transformed position)
|
293
|
+
# @param body [PhysicsBody]
|
294
|
+
# @param vertex [int]
|
295
|
+
# @return [Vector2]
|
296
|
+
[:GetPhysicsShapeVertex, :GetPhysicsShapeVertex, [:pointer, :int], Vector2.by_value],
|
297
|
+
]
|
298
|
+
entries.each do |entry|
|
299
|
+
attach_function entry[0], entry[1], entry[2], entry[3]
|
300
|
+
rescue FFI::NotFoundError => e
|
301
|
+
warn "[Warning] Failed to import #{entry[0]} (#{e})."
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
Binary file
|
Binary file
|
data/lib/raygui.dll
CHANGED
Binary file
|
data/lib/raygui.dylib
CHANGED
Binary file
|