raylib-bindings 0.5.8pre1-x86_64-darwin

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.
@@ -0,0 +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
data/lib/config.rb ADDED
@@ -0,0 +1,103 @@
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
+ SUPPORT_MODULE_RSHAPES = 1
15
+ SUPPORT_MODULE_RTEXTURES = 1
16
+ SUPPORT_MODULE_RTEXT = 1 # WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures
17
+ SUPPORT_MODULE_RMODELS = 1
18
+ SUPPORT_MODULE_RAUDIO = 1
19
+ SUPPORT_CAMERA_SYSTEM = 1
20
+ SUPPORT_GESTURES_SYSTEM = 1
21
+ SUPPORT_RPRAND_GENERATOR = 1
22
+ SUPPORT_MOUSE_GESTURES = 1
23
+ SUPPORT_SSH_KEYBOARD_RPI = 1
24
+ SUPPORT_WINMM_HIGHRES_TIMER = 1
25
+ SUPPORT_PARTIALBUSY_WAIT_LOOP = 1
26
+ SUPPORT_SCREEN_CAPTURE = 1
27
+ SUPPORT_GIF_RECORDING = 1
28
+ SUPPORT_COMPRESSION_API = 1
29
+ SUPPORT_AUTOMATION_EVENTS = 1
30
+ MAX_FILEPATH_CAPACITY = 8192 # Maximum file paths capacity
31
+ MAX_FILEPATH_LENGTH = 4096 # Maximum length for filepaths (Linux PATH_MAX default value)
32
+ MAX_KEYBOARD_KEYS = 512 # Maximum number of keyboard keys supported
33
+ MAX_MOUSE_BUTTONS = 8 # Maximum number of mouse buttons supported
34
+ MAX_GAMEPADS = 4 # Maximum number of gamepads supported
35
+ MAX_GAMEPAD_AXIS = 8 # Maximum number of axis supported (per gamepad)
36
+ MAX_GAMEPAD_BUTTONS = 32 # Maximum number of buttons supported (per gamepad)
37
+ MAX_TOUCH_POINTS = 8 # Maximum number of touch points supported
38
+ MAX_KEY_PRESSED_QUEUE = 16 # Maximum number of keys in the key input queue
39
+ MAX_CHAR_PRESSED_QUEUE = 16 # Maximum number of characters in the char input queue
40
+ MAX_DECOMPRESSION_SIZE = 64 # Max size allocated for decompression in MB
41
+ MAX_AUTOMATION_EVENTS = 16384 # Maximum number of automation events to record
42
+ RL_DEFAULT_BATCH_BUFFERS = 1 # Default number of batch buffers (multi-buffering)
43
+ RL_DEFAULT_BATCH_DRAWCALLS = 256 # Default number of batch draw calls (by state changes: mode, texture)
44
+ RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS = 4 # Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
45
+ RL_MAX_MATRIX_STACK_SIZE = 32 # Maximum size of internal Matrix stack
46
+ RL_MAX_SHADER_LOCATIONS = 32 # Maximum number of shader locations supported
47
+ RL_CULL_DISTANCE_NEAR = 0.01 # Default projection matrix near cull distance
48
+ RL_CULL_DISTANCE_FAR = 1000.0 # Default projection matrix far cull distance
49
+ RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION = "vertexPosition" # Bound by default to shader location: 0
50
+ RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD = "vertexTexCoord" # Bound by default to shader location: 1
51
+ RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL = "vertexNormal" # Bound by default to shader location: 2
52
+ RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR = "vertexColor" # Bound by default to shader location: 3
53
+ RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT = "vertexTangent" # Bound by default to shader location: 4
54
+ RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 = "vertexTexCoord2" # Bound by default to shader location: 5
55
+ RL_DEFAULT_SHADER_UNIFORM_NAME_MVP = "mvp" # model-view-projection matrix
56
+ RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW = "matView" # view matrix
57
+ RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION = "matProjection" # projection matrix
58
+ RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL = "matModel" # model matrix
59
+ RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL = "matNormal" # normal matrix (transpose(inverse(matModelView))
60
+ RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR = "colDiffuse" # color diffuse (base tint color, multiplied by texture color)
61
+ RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 = "texture0" # texture0 (texture slot active 0)
62
+ RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 = "texture1" # texture1 (texture slot active 1)
63
+ RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 = "texture2" # texture2 (texture slot active 2)
64
+ SUPPORT_QUADS_DRAW_MODE = 1
65
+ SPLINE_SEGMENT_DIVISIONS = 24 # Spline segments subdivisions
66
+ SUPPORT_FILEFORMAT_PNG = 1
67
+ SUPPORT_FILEFORMAT_GIF = 1
68
+ SUPPORT_FILEFORMAT_QOI = 1
69
+ SUPPORT_FILEFORMAT_DDS = 1
70
+ SUPPORT_IMAGE_EXPORT = 1
71
+ SUPPORT_IMAGE_GENERATION = 1
72
+ SUPPORT_IMAGE_MANIPULATION = 1
73
+ SUPPORT_DEFAULT_FONT = 1
74
+ SUPPORT_FILEFORMAT_FNT = 1
75
+ SUPPORT_FILEFORMAT_TTF = 1
76
+ SUPPORT_TEXT_MANIPULATION = 1
77
+ SUPPORT_FONT_ATLAS_WHITE_REC = 1
78
+ MAX_TEXT_BUFFER_LENGTH = 1024 # Size of internal static buffers used on some functions:
79
+ MAX_TEXTSPLIT_COUNT = 128 # Maximum number of substrings to split: TextSplit()
80
+ SUPPORT_FILEFORMAT_OBJ = 1
81
+ SUPPORT_FILEFORMAT_MTL = 1
82
+ SUPPORT_FILEFORMAT_IQM = 1
83
+ SUPPORT_FILEFORMAT_GLTF = 1
84
+ SUPPORT_FILEFORMAT_VOX = 1
85
+ SUPPORT_FILEFORMAT_M3D = 1
86
+ SUPPORT_MESH_GENERATION = 1
87
+ MAX_MATERIAL_MAPS = 12 # Maximum number of shader maps supported
88
+ MAX_MESH_VERTEX_BUFFERS = 7 # Maximum vertex buffers (VBO) per mesh
89
+ SUPPORT_FILEFORMAT_WAV = 1
90
+ SUPPORT_FILEFORMAT_OGG = 1
91
+ SUPPORT_FILEFORMAT_MP3 = 1
92
+ SUPPORT_FILEFORMAT_QOA = 1
93
+ SUPPORT_FILEFORMAT_XM = 1
94
+ SUPPORT_FILEFORMAT_MOD = 1
95
+ AUDIO_DEVICE_FORMAT = "ma_format_f32" # Device output format (miniaudio: float-32bit)
96
+ AUDIO_DEVICE_CHANNELS = 2 # Device output channels: stereo
97
+ AUDIO_DEVICE_SAMPLE_RATE = 0 # Device sample rate (device default)
98
+ MAX_AUDIO_BUFFER_POOL_CHANNELS = 16 # Maximum number of audio pool channels
99
+ SUPPORT_STANDARD_FILEIO = 1
100
+ SUPPORT_TRACELOG = 1
101
+ MAX_TRACELOG_MSG_LENGTH = 256 # Max length of one trace-log message
102
+
103
+ end
Binary file
data/lib/physac.rb ADDED
@@ -0,0 +1,322 @@
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
+
22
+ # Enum
23
+
24
+ # enum PhysicsShapeType
25
+ PHYSICS_CIRCLE = 0
26
+ PHYSICS_POLYGON = 1
27
+
28
+
29
+ # Typedef
30
+
31
+ typedef :int, :PhysicsShapeType
32
+ typedef :pointer, :PhysicsBody
33
+ typedef :pointer, :PhysicsManifold
34
+
35
+ # Struct
36
+
37
+ # Matrix2x2 type (used for polygon shape rotation matrix)
38
+ class Matrix2x2 < FFI::Struct
39
+ layout(
40
+ :m00, :float,
41
+ :m01, :float,
42
+ :m10, :float,
43
+ :m11, :float,
44
+ )
45
+ def m00 = self[:m00]
46
+ def m00=(v) self[:m00] = v end
47
+ def m01 = self[:m01]
48
+ def m01=(v) self[:m01] = v end
49
+ def m10 = self[:m10]
50
+ def m10=(v) self[:m10] = v end
51
+ def m11 = self[:m11]
52
+ def m11=(v) self[:m11] = v end
53
+ end
54
+
55
+ class PhysicsVertexData < FFI::Struct
56
+ layout(
57
+ :vertexCount, :uint, # Vertex count (positions and normals)
58
+ :positions, [Vector2, 24], # Vertex positions vectors
59
+ :normals, [Vector2, 24], # Vertex normals vectors
60
+ )
61
+ def vertexCount = self[:vertexCount]
62
+ def vertexCount=(v) self[:vertexCount] = v end
63
+ def positions = self[:positions]
64
+ def positions=(v) self[:positions] = v end
65
+ def normals = self[:normals]
66
+ def normals=(v) self[:normals] = v end
67
+ end
68
+
69
+ class PhysicsShape < FFI::Struct
70
+ layout(
71
+ :type, :int, # Shape type (circle or polygon)
72
+ :body, :pointer, # Shape physics body data pointer
73
+ :vertexData, PhysicsVertexData, # Shape vertices data (used for polygon shapes)
74
+ :radius, :float, # Shape radius (used for circle shapes)
75
+ :transform, Matrix2x2, # Vertices transform matrix 2x2
76
+ )
77
+ def type = self[:type]
78
+ def type=(v) self[:type] = v end
79
+ def body = self[:body]
80
+ def body=(v) self[:body] = v end
81
+ def vertexData = self[:vertexData]
82
+ def vertexData=(v) self[:vertexData] = v end
83
+ def radius = self[:radius]
84
+ def radius=(v) self[:radius] = v end
85
+ def transform = self[:transform]
86
+ def transform=(v) self[:transform] = v end
87
+ end
88
+
89
+ class PhysicsBodyData < FFI::Struct
90
+ layout(
91
+ :id, :uint, # Unique identifier
92
+ :enabled, :bool, # Enabled dynamics state (collisions are calculated anyway)
93
+ :position, Vector2, # Physics body shape pivot
94
+ :velocity, Vector2, # Current linear velocity applied to position
95
+ :force, Vector2, # Current linear force (reset to 0 every step)
96
+ :angularVelocity, :float, # Current angular velocity applied to orient
97
+ :torque, :float, # Current angular force (reset to 0 every step)
98
+ :orient, :float, # Rotation in radians
99
+ :inertia, :float, # Moment of inertia
100
+ :inverseInertia, :float, # Inverse value of inertia
101
+ :mass, :float, # Physics body mass
102
+ :inverseMass, :float, # Inverse value of mass
103
+ :staticFriction, :float, # Friction when the body has not movement (0 to 1)
104
+ :dynamicFriction, :float, # Friction when the body has movement (0 to 1)
105
+ :restitution, :float, # Restitution coefficient of the body (0 to 1)
106
+ :useGravity, :bool, # Apply gravity force to dynamics
107
+ :isGrounded, :bool, # Physics grounded on other body state
108
+ :freezeOrient, :bool, # Physics rotation constraint
109
+ :shape, PhysicsShape, # Physics body shape information (type, radius, vertices, transform)
110
+ )
111
+ def id = self[:id]
112
+ def id=(v) self[:id] = v end
113
+ def enabled = self[:enabled]
114
+ def enabled=(v) self[:enabled] = v end
115
+ def position = self[:position]
116
+ def position=(v) self[:position] = v end
117
+ def velocity = self[:velocity]
118
+ def velocity=(v) self[:velocity] = v end
119
+ def force = self[:force]
120
+ def force=(v) self[:force] = v end
121
+ def angularVelocity = self[:angularVelocity]
122
+ def angularVelocity=(v) self[:angularVelocity] = v end
123
+ def torque = self[:torque]
124
+ def torque=(v) self[:torque] = v end
125
+ def orient = self[:orient]
126
+ def orient=(v) self[:orient] = v end
127
+ def inertia = self[:inertia]
128
+ def inertia=(v) self[:inertia] = v end
129
+ def inverseInertia = self[:inverseInertia]
130
+ def inverseInertia=(v) self[:inverseInertia] = v end
131
+ def mass = self[:mass]
132
+ def mass=(v) self[:mass] = v end
133
+ def inverseMass = self[:inverseMass]
134
+ def inverseMass=(v) self[:inverseMass] = v end
135
+ def staticFriction = self[:staticFriction]
136
+ def staticFriction=(v) self[:staticFriction] = v end
137
+ def dynamicFriction = self[:dynamicFriction]
138
+ def dynamicFriction=(v) self[:dynamicFriction] = v end
139
+ def restitution = self[:restitution]
140
+ def restitution=(v) self[:restitution] = v end
141
+ def useGravity = self[:useGravity]
142
+ def useGravity=(v) self[:useGravity] = v end
143
+ def isGrounded = self[:isGrounded]
144
+ def isGrounded=(v) self[:isGrounded] = v end
145
+ def freezeOrient = self[:freezeOrient]
146
+ def freezeOrient=(v) self[:freezeOrient] = v end
147
+ def shape = self[:shape]
148
+ def shape=(v) self[:shape] = v end
149
+ end
150
+
151
+ class PhysicsManifoldData < FFI::Struct
152
+ layout(
153
+ :id, :uint, # Unique identifier
154
+ :bodyA, :pointer, # Manifold first physics body reference
155
+ :bodyB, :pointer, # Manifold second physics body reference
156
+ :penetration, :float, # Depth of penetration from collision
157
+ :normal, Vector2, # Normal direction vector from 'a' to 'b'
158
+ :contacts, [Vector2, 2], # Points of contact during collision
159
+ :contactsCount, :uint, # Current collision number of contacts
160
+ :restitution, :float, # Mixed restitution during collision
161
+ :dynamicFriction, :float, # Mixed dynamic friction during collision
162
+ :staticFriction, :float, # Mixed static friction during collision
163
+ )
164
+ def id = self[:id]
165
+ def id=(v) self[:id] = v end
166
+ def bodyA = self[:bodyA]
167
+ def bodyA=(v) self[:bodyA] = v end
168
+ def bodyB = self[:bodyB]
169
+ def bodyB=(v) self[:bodyB] = v end
170
+ def penetration = self[:penetration]
171
+ def penetration=(v) self[:penetration] = v end
172
+ def normal = self[:normal]
173
+ def normal=(v) self[:normal] = v end
174
+ def contacts = self[:contacts]
175
+ def contacts=(v) self[:contacts] = v end
176
+ def contactsCount = self[:contactsCount]
177
+ def contactsCount=(v) self[:contactsCount] = v end
178
+ def restitution = self[:restitution]
179
+ def restitution=(v) self[:restitution] = v end
180
+ def dynamicFriction = self[:dynamicFriction]
181
+ def dynamicFriction=(v) self[:dynamicFriction] = v end
182
+ def staticFriction = self[:staticFriction]
183
+ def staticFriction=(v) self[:staticFriction] = v end
184
+ end
185
+
186
+
187
+ # Function
188
+
189
+ def self.setup_physac_symbols
190
+ entries = [
191
+
192
+ # @!method InitPhysics()
193
+ # InitPhysics : Initializes physics system
194
+ # @return [void]
195
+ [:InitPhysics, :InitPhysics, [], :void],
196
+
197
+ # @!method UpdatePhysics()
198
+ # UpdatePhysics : Update physics system
199
+ # @return [void]
200
+ [:UpdatePhysics, :UpdatePhysics, [], :void],
201
+
202
+ # @!method ResetPhysics()
203
+ # ResetPhysics : Reset physics system (global variables)
204
+ # @return [void]
205
+ [:ResetPhysics, :ResetPhysics, [], :void],
206
+
207
+ # @!method ClosePhysics()
208
+ # ClosePhysics : Close physics system and unload used memory
209
+ # @return [void]
210
+ [:ClosePhysics, :ClosePhysics, [], :void],
211
+
212
+ # @!method SetPhysicsTimeStep(delta)
213
+ # SetPhysicsTimeStep : Sets physics fixed time step in milliseconds. 1.666666 by default
214
+ # @param delta [double]
215
+ # @return [void]
216
+ [:SetPhysicsTimeStep, :SetPhysicsTimeStep, [:double], :void],
217
+
218
+ # @!method SetPhysicsGravity(x, y)
219
+ # SetPhysicsGravity : Sets physics global gravity force
220
+ # @param x [float]
221
+ # @param y [float]
222
+ # @return [void]
223
+ [:SetPhysicsGravity, :SetPhysicsGravity, [:float, :float], :void],
224
+
225
+ # @!method CreatePhysicsBodyCircle(pos, radius, density)
226
+ # CreatePhysicsBodyCircle : Creates a new circle physics body with generic parameters
227
+ # @param pos [Vector2]
228
+ # @param radius [float]
229
+ # @param density [float]
230
+ # @return [PhysicsBody]
231
+ [:CreatePhysicsBodyCircle, :CreatePhysicsBodyCircle, [Vector2.by_value, :float, :float], :pointer],
232
+
233
+ # @!method CreatePhysicsBodyRectangle(pos, width, height, density)
234
+ # CreatePhysicsBodyRectangle : Creates a new rectangle physics body with generic parameters
235
+ # @param pos [Vector2]
236
+ # @param width [float]
237
+ # @param height [float]
238
+ # @param density [float]
239
+ # @return [PhysicsBody]
240
+ [:CreatePhysicsBodyRectangle, :CreatePhysicsBodyRectangle, [Vector2.by_value, :float, :float, :float], :pointer],
241
+
242
+ # @!method CreatePhysicsBodyPolygon(pos, radius, sides, density)
243
+ # CreatePhysicsBodyPolygon : Creates a new polygon physics body with generic parameters
244
+ # @param pos [Vector2]
245
+ # @param radius [float]
246
+ # @param sides [int]
247
+ # @param density [float]
248
+ # @return [PhysicsBody]
249
+ [:CreatePhysicsBodyPolygon, :CreatePhysicsBodyPolygon, [Vector2.by_value, :float, :int, :float], :pointer],
250
+
251
+ # @!method DestroyPhysicsBody(body)
252
+ # DestroyPhysicsBody : Destroy a physics body
253
+ # @param body [PhysicsBody]
254
+ # @return [void]
255
+ [:DestroyPhysicsBody, :DestroyPhysicsBody, [:pointer], :void],
256
+
257
+ # @!method PhysicsAddForce(body, force)
258
+ # PhysicsAddForce : Adds a force to a physics body
259
+ # @param body [PhysicsBody]
260
+ # @param force [Vector2]
261
+ # @return [void]
262
+ [:PhysicsAddForce, :PhysicsAddForce, [:pointer, Vector2.by_value], :void],
263
+
264
+ # @!method PhysicsAddTorque(body, amount)
265
+ # PhysicsAddTorque : Adds an angular force to a physics body
266
+ # @param body [PhysicsBody]
267
+ # @param amount [float]
268
+ # @return [void]
269
+ [:PhysicsAddTorque, :PhysicsAddTorque, [:pointer, :float], :void],
270
+
271
+ # @!method PhysicsShatter(body, position, force)
272
+ # PhysicsShatter : Shatters a polygon shape physics body to little physics bodies with explosion force
273
+ # @param body [PhysicsBody]
274
+ # @param position [Vector2]
275
+ # @param force [float]
276
+ # @return [void]
277
+ [:PhysicsShatter, :PhysicsShatter, [:pointer, Vector2.by_value, :float], :void],
278
+
279
+ # @!method SetPhysicsBodyRotation(body, radians)
280
+ # SetPhysicsBodyRotation : Sets physics body shape transform based on radians parameter
281
+ # @param body [PhysicsBody]
282
+ # @param radians [float]
283
+ # @return [void]
284
+ [:SetPhysicsBodyRotation, :SetPhysicsBodyRotation, [:pointer, :float], :void],
285
+
286
+ # @!method GetPhysicsBody(index)
287
+ # GetPhysicsBody : Returns a physics body of the bodies pool at a specific index
288
+ # @param index [int]
289
+ # @return [PhysicsBody]
290
+ [:GetPhysicsBody, :GetPhysicsBody, [:int], :pointer],
291
+
292
+ # @!method GetPhysicsBodiesCount()
293
+ # GetPhysicsBodiesCount : Returns the current amount of created physics bodies
294
+ # @return [int]
295
+ [:GetPhysicsBodiesCount, :GetPhysicsBodiesCount, [], :int],
296
+
297
+ # @!method GetPhysicsShapeType(index)
298
+ # GetPhysicsShapeType : Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
299
+ # @param index [int]
300
+ # @return [int]
301
+ [:GetPhysicsShapeType, :GetPhysicsShapeType, [:int], :int],
302
+
303
+ # @!method GetPhysicsShapeVerticesCount(index)
304
+ # GetPhysicsShapeVerticesCount : Returns the amount of vertices of a physics body shape
305
+ # @param index [int]
306
+ # @return [int]
307
+ [:GetPhysicsShapeVerticesCount, :GetPhysicsShapeVerticesCount, [:int], :int],
308
+
309
+ # @!method GetPhysicsShapeVertex(body, vertex)
310
+ # GetPhysicsShapeVertex : Returns transformed position of a body shape (body position + vertex transformed position)
311
+ # @param body [PhysicsBody]
312
+ # @param vertex [int]
313
+ # @return [Vector2]
314
+ [:GetPhysicsShapeVertex, :GetPhysicsShapeVertex, [:pointer, :int], Vector2.by_value],
315
+ ]
316
+ entries.each do |entry|
317
+ attach_function entry[0], entry[1], entry[2], entry[3]
318
+ rescue FFI::NotFoundError => e
319
+ warn "[Warning] Failed to import #{entry[0]} (#{e})."
320
+ end
321
+ end
322
+ end
Binary file
Binary file