konpeito 0.5.0 → 0.6.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/lib/konpeito/codegen/inliner.rb +34 -0
- data/lib/konpeito/codegen/mruby_backend.rb +3 -1
- data/lib/konpeito/stdlib/raylib/raylib.rb +112 -0
- data/lib/konpeito/stdlib/raylib/raylib.rbs +288 -0
- data/lib/konpeito/stdlib/raylib/raylib_native.c +510 -0
- data/lib/konpeito/type_checker/rbs_loader.rb +2 -2
- data/lib/konpeito/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6e49cc678968c9afbf41e3483ce19ac9d0f506bf18b31def5de3468fdef18b3
|
|
4
|
+
data.tar.gz: f6f85c8b6d646c56ace6b35338ea66adeabc53eec3a21b50b0953346145b0d59
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc766128892195b93c5acf173b7a84c3ee86415932b9d477a952a824cb9167b15c7e63b74ab894dcd7e8213e731b5c6b2dfd1f2ef829c2e380583d7e85f1536b
|
|
7
|
+
data.tar.gz: 692f32eee6feb583b24b7f468fbd659c784f01c41ecde853272966c13bdda0032c47e8d55d0d0f0d084dd9493f0df50d9f0f483245f7d9f1a8ef98f43bbb6c70
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0] - 2026-03-11
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Raylib stdlib expansion**: 119 new cfunc bindings (87 → 206 total) for 2D RPG/SLG game development
|
|
14
|
+
- Texture/Sprite management (10): load, unload, draw, draw_rec, draw_pro, draw_scaled, dimensions, validity check
|
|
15
|
+
- Audio — Sound (10): load, unload, play, stop, pause, resume, playing?, volume, pitch
|
|
16
|
+
- Audio — Music (13): load, unload, play, stop, pause, resume, update, playing?, volume, pitch, time_length, time_played, seek
|
|
17
|
+
- Audio — Device (4): init, close, ready?, master volume
|
|
18
|
+
- Camera2D (4): begin/end mode, world-to-screen coordinate conversion (x/y)
|
|
19
|
+
- File I/O (4): save/load text files, file/directory existence checks
|
|
20
|
+
- Font management (6): load, load_ex, unload, draw_text_ex, measure_text_ex (x/y)
|
|
21
|
+
- Gamepad input (7 + 21 constants): button pressed/down/released/up, axis movement/count, D-pad/face/trigger/middle button and axis constants
|
|
22
|
+
- Extended shapes (5): draw_rectangle_pro, draw_rectangle_rounded, gradient v/h, circle sector
|
|
23
|
+
- Collision detection (5): recs, circles, circle-rec, point-rec, point-circle
|
|
24
|
+
- ID table pattern for resource management: textures (256), sounds (128), music (32), fonts (32)
|
|
25
|
+
- **RPG tilemap demo**: `examples/mruby_rpg_demo/rpg_demo.rb` — 40×40 tilemap, smooth camera scrolling, 4-direction player movement with animation, sign interaction, HUD with step counter
|
|
26
|
+
- macOS audio framework linker flags (CoreAudio, AudioToolbox, CoreFoundation)
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- **Inliner CFuncCall bug**: `clone_and_rename()` now handles `CFuncCall`, `ExternConstructorCall`, and `ExternMethodCall` — parameters are correctly remapped when user functions calling `@cfunc` are inlined (previously fell through to default case, returning instructions with unmapped parameters)
|
|
30
|
+
- **CI lint**: use anonymous block forwarding (`&`) in `rbs_loader.rb`
|
|
31
|
+
- **CI test isolation**: use unique symbol names in `module_native_array_test` to avoid ELF symbol interposition on Linux
|
|
32
|
+
|
|
10
33
|
## [0.5.0] - 2026-03-10
|
|
11
34
|
|
|
12
35
|
### Added
|
|
@@ -542,6 +542,40 @@ module Konpeito
|
|
|
542
542
|
result_var: new_result
|
|
543
543
|
)
|
|
544
544
|
|
|
545
|
+
when HIR::CFuncCall
|
|
546
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
547
|
+
new_args = inst.args.map { |a| transform_value(a, prefix, param_map) }
|
|
548
|
+
HIR::CFuncCall.new(
|
|
549
|
+
c_func_name: inst.c_func_name,
|
|
550
|
+
args: new_args,
|
|
551
|
+
cfunc_type: inst.cfunc_type,
|
|
552
|
+
result_var: new_result
|
|
553
|
+
)
|
|
554
|
+
|
|
555
|
+
when HIR::ExternConstructorCall
|
|
556
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
557
|
+
new_args = inst.args.map { |a| transform_value(a, prefix, param_map) }
|
|
558
|
+
HIR::ExternConstructorCall.new(
|
|
559
|
+
extern_type: inst.extern_type,
|
|
560
|
+
c_func_name: inst.c_func_name,
|
|
561
|
+
args: new_args,
|
|
562
|
+
method_sig: inst.method_sig,
|
|
563
|
+
result_var: new_result
|
|
564
|
+
)
|
|
565
|
+
|
|
566
|
+
when HIR::ExternMethodCall
|
|
567
|
+
new_result = inst.result_var ? prefix + inst.result_var : nil
|
|
568
|
+
new_receiver = transform_value(inst.receiver, prefix, param_map)
|
|
569
|
+
new_args = inst.args.map { |a| transform_value(a, prefix, param_map) }
|
|
570
|
+
HIR::ExternMethodCall.new(
|
|
571
|
+
receiver: new_receiver,
|
|
572
|
+
c_func_name: inst.c_func_name,
|
|
573
|
+
args: new_args,
|
|
574
|
+
extern_type: inst.extern_type,
|
|
575
|
+
method_sig: inst.method_sig,
|
|
576
|
+
result_var: new_result
|
|
577
|
+
)
|
|
578
|
+
|
|
545
579
|
else
|
|
546
580
|
# For other instructions, just return as-is with renamed result
|
|
547
581
|
inst
|
|
@@ -1171,7 +1171,9 @@ module Konpeito
|
|
|
1171
1171
|
# Known framework dependencies for popular libraries
|
|
1172
1172
|
case lib_name
|
|
1173
1173
|
when "raylib"
|
|
1174
|
-
["-framework", "IOKit", "-framework", "Cocoa", "-framework", "OpenGL"
|
|
1174
|
+
["-framework", "IOKit", "-framework", "Cocoa", "-framework", "OpenGL",
|
|
1175
|
+
"-framework", "CoreAudio", "-framework", "AudioToolbox",
|
|
1176
|
+
"-framework", "CoreFoundation"]
|
|
1175
1177
|
when "SDL2", "sdl2"
|
|
1176
1178
|
["-framework", "IOKit", "-framework", "Cocoa", "-framework", "Carbon",
|
|
1177
1179
|
"-framework", "CoreAudio", "-framework", "AudioToolbox",
|
|
@@ -144,4 +144,116 @@ module Raylib
|
|
|
144
144
|
def self.flag_window_resizable() end
|
|
145
145
|
def self.flag_window_highdpi() end
|
|
146
146
|
def self.flag_msaa_4x_hint() end
|
|
147
|
+
|
|
148
|
+
# Texture Management
|
|
149
|
+
def self.load_texture(path) end
|
|
150
|
+
def self.unload_texture(id) end
|
|
151
|
+
def self.draw_texture(id, x, y, tint) end
|
|
152
|
+
def self.draw_texture_rec(id, sx, sy, sw, sh, dx, dy, tint) end
|
|
153
|
+
def self.draw_texture_pro(id, sx, sy, sw, sh, dx, dy, dw, dh, ox, oy, rotation, tint) end
|
|
154
|
+
def self.get_texture_width(id) end
|
|
155
|
+
def self.get_texture_height(id) end
|
|
156
|
+
def self.texture_valid?(id) end
|
|
157
|
+
def self.draw_texture_scaled(id, x, y, scale, tint) end
|
|
158
|
+
|
|
159
|
+
# Audio — Device
|
|
160
|
+
def self.init_audio_device() end
|
|
161
|
+
def self.close_audio_device() end
|
|
162
|
+
def self.audio_device_ready?() end
|
|
163
|
+
def self.set_master_volume(vol) end
|
|
164
|
+
def self.get_master_volume() end
|
|
165
|
+
|
|
166
|
+
# Audio — Sound
|
|
167
|
+
def self.load_sound(path) end
|
|
168
|
+
def self.unload_sound(id) end
|
|
169
|
+
def self.play_sound(id) end
|
|
170
|
+
def self.stop_sound(id) end
|
|
171
|
+
def self.pause_sound(id) end
|
|
172
|
+
def self.resume_sound(id) end
|
|
173
|
+
def self.sound_playing?(id) end
|
|
174
|
+
def self.set_sound_volume(id, vol) end
|
|
175
|
+
def self.set_sound_pitch(id, pitch) end
|
|
176
|
+
|
|
177
|
+
# Audio — Music
|
|
178
|
+
def self.load_music(path) end
|
|
179
|
+
def self.unload_music(id) end
|
|
180
|
+
def self.play_music(id) end
|
|
181
|
+
def self.stop_music(id) end
|
|
182
|
+
def self.pause_music(id) end
|
|
183
|
+
def self.resume_music(id) end
|
|
184
|
+
def self.update_music(id) end
|
|
185
|
+
def self.music_playing?(id) end
|
|
186
|
+
def self.set_music_volume(id, vol) end
|
|
187
|
+
def self.set_music_pitch(id, pitch) end
|
|
188
|
+
def self.get_music_time_length(id) end
|
|
189
|
+
def self.get_music_time_played(id) end
|
|
190
|
+
def self.seek_music(id, position) end
|
|
191
|
+
|
|
192
|
+
# Camera2D
|
|
193
|
+
def self.begin_mode_2d(offset_x, offset_y, target_x, target_y, rotation, zoom) end
|
|
194
|
+
def self.end_mode_2d() end
|
|
195
|
+
def self.get_world_to_screen_2d_x(world_x, world_y, offset_x, offset_y, target_x, target_y, rotation, zoom) end
|
|
196
|
+
def self.get_world_to_screen_2d_y(world_x, world_y, offset_x, offset_y, target_x, target_y, rotation, zoom) end
|
|
197
|
+
|
|
198
|
+
# File I/O
|
|
199
|
+
def self.save_file_text(path, text) end
|
|
200
|
+
def self.load_file_text(path) end
|
|
201
|
+
def self.file_exists?(path) end
|
|
202
|
+
def self.directory_exists?(path) end
|
|
203
|
+
|
|
204
|
+
# Font Management
|
|
205
|
+
def self.load_font(path) end
|
|
206
|
+
def self.load_font_ex(path, size) end
|
|
207
|
+
def self.unload_font(id) end
|
|
208
|
+
def self.draw_text_ex(font_id, text, x, y, size, spacing, tint) end
|
|
209
|
+
def self.measure_text_ex_x(font_id, text, size, spacing) end
|
|
210
|
+
def self.measure_text_ex_y(font_id, text, size, spacing) end
|
|
211
|
+
|
|
212
|
+
# Gamepad Input
|
|
213
|
+
def self.gamepad_available?(gamepad) end
|
|
214
|
+
def self.gamepad_button_pressed?(gamepad, button) end
|
|
215
|
+
def self.gamepad_button_down?(gamepad, button) end
|
|
216
|
+
def self.gamepad_button_released?(gamepad, button) end
|
|
217
|
+
def self.gamepad_button_up?(gamepad, button) end
|
|
218
|
+
def self.get_gamepad_axis_movement(gamepad, axis) end
|
|
219
|
+
def self.get_gamepad_axis_count(gamepad) end
|
|
220
|
+
|
|
221
|
+
# Gamepad Button Constants
|
|
222
|
+
def self.gamepad_button_left_face_up() end
|
|
223
|
+
def self.gamepad_button_left_face_right() end
|
|
224
|
+
def self.gamepad_button_left_face_down() end
|
|
225
|
+
def self.gamepad_button_left_face_left() end
|
|
226
|
+
def self.gamepad_button_right_face_up() end
|
|
227
|
+
def self.gamepad_button_right_face_right() end
|
|
228
|
+
def self.gamepad_button_right_face_down() end
|
|
229
|
+
def self.gamepad_button_right_face_left() end
|
|
230
|
+
def self.gamepad_button_left_trigger_1() end
|
|
231
|
+
def self.gamepad_button_left_trigger_2() end
|
|
232
|
+
def self.gamepad_button_right_trigger_1() end
|
|
233
|
+
def self.gamepad_button_right_trigger_2() end
|
|
234
|
+
def self.gamepad_button_middle_left() end
|
|
235
|
+
def self.gamepad_button_middle() end
|
|
236
|
+
def self.gamepad_button_middle_right() end
|
|
237
|
+
|
|
238
|
+
# Gamepad Axis Constants
|
|
239
|
+
def self.gamepad_axis_left_x() end
|
|
240
|
+
def self.gamepad_axis_left_y() end
|
|
241
|
+
def self.gamepad_axis_right_x() end
|
|
242
|
+
def self.gamepad_axis_right_y() end
|
|
243
|
+
def self.gamepad_axis_left_trigger() end
|
|
244
|
+
def self.gamepad_axis_right_trigger() end
|
|
245
|
+
|
|
246
|
+
# Drawing — Extended Shapes
|
|
247
|
+
def self.draw_rectangle_pro(x, y, w, h, ox, oy, rotation, color) end
|
|
248
|
+
def self.draw_rectangle_rounded(x, y, w, h, roundness, segments, color) end
|
|
249
|
+
def self.draw_rectangle_gradient_v(x, y, w, h, color1, color2) end
|
|
250
|
+
def self.draw_rectangle_gradient_h(x, y, w, h, color1, color2) end
|
|
251
|
+
def self.draw_circle_sector(cx, cy, radius, start_angle, end_angle, segments, color) end
|
|
252
|
+
|
|
253
|
+
# Collision Detection
|
|
254
|
+
def self.check_collision_recs(x1, y1, w1, h1, x2, y2, w2, h2) end
|
|
255
|
+
def self.check_collision_circles(cx1, cy1, r1, cx2, cy2, r2) end
|
|
256
|
+
def self.check_collision_circle_rec(cx, cy, radius, rx, ry, rw, rh) end
|
|
257
|
+
def self.check_collision_point_rec(px, py, rx, ry, rw, rh) end
|
|
258
|
+
def self.check_collision_point_circle(px, py, cx, cy, radius) end
|
|
147
259
|
end
|
|
@@ -386,4 +386,292 @@ module Raylib
|
|
|
386
386
|
|
|
387
387
|
%a{cfunc: "konpeito_flag_msaa_4x_hint"}
|
|
388
388
|
def self.flag_msaa_4x_hint: () -> Integer
|
|
389
|
+
|
|
390
|
+
# ── Texture Management ──
|
|
391
|
+
|
|
392
|
+
%a{cfunc: "konpeito_load_texture"}
|
|
393
|
+
def self.load_texture: (String path) -> Integer
|
|
394
|
+
|
|
395
|
+
%a{cfunc: "konpeito_unload_texture"}
|
|
396
|
+
def self.unload_texture: (Integer id) -> void
|
|
397
|
+
|
|
398
|
+
%a{cfunc: "konpeito_draw_texture"}
|
|
399
|
+
def self.draw_texture: (Integer id, Integer x, Integer y, Integer tint) -> void
|
|
400
|
+
|
|
401
|
+
%a{cfunc: "konpeito_draw_texture_rec"}
|
|
402
|
+
def self.draw_texture_rec: (Integer id, Float sx, Float sy, Float sw, Float sh, Integer dx, Integer dy, Integer tint) -> void
|
|
403
|
+
|
|
404
|
+
%a{cfunc: "konpeito_draw_texture_pro"}
|
|
405
|
+
def self.draw_texture_pro: (Integer id, Float sx, Float sy, Float sw, Float sh, Float dx, Float dy, Float dw, Float dh, Float ox, Float oy, Float rotation, Integer tint) -> void
|
|
406
|
+
|
|
407
|
+
%a{cfunc: "konpeito_get_texture_width"}
|
|
408
|
+
def self.get_texture_width: (Integer id) -> Integer
|
|
409
|
+
|
|
410
|
+
%a{cfunc: "konpeito_get_texture_height"}
|
|
411
|
+
def self.get_texture_height: (Integer id) -> Integer
|
|
412
|
+
|
|
413
|
+
%a{cfunc: "konpeito_is_texture_valid"}
|
|
414
|
+
def self.texture_valid?: (Integer id) -> Integer
|
|
415
|
+
|
|
416
|
+
%a{cfunc: "konpeito_draw_texture_scaled"}
|
|
417
|
+
def self.draw_texture_scaled: (Integer id, Integer x, Integer y, Float scale, Integer tint) -> void
|
|
418
|
+
|
|
419
|
+
# ── Audio — Device ──
|
|
420
|
+
|
|
421
|
+
%a{cfunc: "konpeito_init_audio_device"}
|
|
422
|
+
def self.init_audio_device: () -> void
|
|
423
|
+
|
|
424
|
+
%a{cfunc: "konpeito_close_audio_device"}
|
|
425
|
+
def self.close_audio_device: () -> void
|
|
426
|
+
|
|
427
|
+
%a{cfunc: "konpeito_is_audio_device_ready"}
|
|
428
|
+
def self.audio_device_ready?: () -> Integer
|
|
429
|
+
|
|
430
|
+
%a{cfunc: "konpeito_set_master_volume"}
|
|
431
|
+
def self.set_master_volume: (Float vol) -> void
|
|
432
|
+
|
|
433
|
+
%a{cfunc: "konpeito_get_master_volume"}
|
|
434
|
+
def self.get_master_volume: () -> Float
|
|
435
|
+
|
|
436
|
+
# ── Audio — Sound ──
|
|
437
|
+
|
|
438
|
+
%a{cfunc: "konpeito_load_sound"}
|
|
439
|
+
def self.load_sound: (String path) -> Integer
|
|
440
|
+
|
|
441
|
+
%a{cfunc: "konpeito_unload_sound"}
|
|
442
|
+
def self.unload_sound: (Integer id) -> void
|
|
443
|
+
|
|
444
|
+
%a{cfunc: "konpeito_play_sound"}
|
|
445
|
+
def self.play_sound: (Integer id) -> void
|
|
446
|
+
|
|
447
|
+
%a{cfunc: "konpeito_stop_sound"}
|
|
448
|
+
def self.stop_sound: (Integer id) -> void
|
|
449
|
+
|
|
450
|
+
%a{cfunc: "konpeito_pause_sound"}
|
|
451
|
+
def self.pause_sound: (Integer id) -> void
|
|
452
|
+
|
|
453
|
+
%a{cfunc: "konpeito_resume_sound"}
|
|
454
|
+
def self.resume_sound: (Integer id) -> void
|
|
455
|
+
|
|
456
|
+
%a{cfunc: "konpeito_is_sound_playing"}
|
|
457
|
+
def self.sound_playing?: (Integer id) -> Integer
|
|
458
|
+
|
|
459
|
+
%a{cfunc: "konpeito_set_sound_volume"}
|
|
460
|
+
def self.set_sound_volume: (Integer id, Float vol) -> void
|
|
461
|
+
|
|
462
|
+
%a{cfunc: "konpeito_set_sound_pitch"}
|
|
463
|
+
def self.set_sound_pitch: (Integer id, Float pitch) -> void
|
|
464
|
+
|
|
465
|
+
# ── Audio — Music ──
|
|
466
|
+
|
|
467
|
+
%a{cfunc: "konpeito_load_music"}
|
|
468
|
+
def self.load_music: (String path) -> Integer
|
|
469
|
+
|
|
470
|
+
%a{cfunc: "konpeito_unload_music"}
|
|
471
|
+
def self.unload_music: (Integer id) -> void
|
|
472
|
+
|
|
473
|
+
%a{cfunc: "konpeito_play_music"}
|
|
474
|
+
def self.play_music: (Integer id) -> void
|
|
475
|
+
|
|
476
|
+
%a{cfunc: "konpeito_stop_music"}
|
|
477
|
+
def self.stop_music: (Integer id) -> void
|
|
478
|
+
|
|
479
|
+
%a{cfunc: "konpeito_pause_music"}
|
|
480
|
+
def self.pause_music: (Integer id) -> void
|
|
481
|
+
|
|
482
|
+
%a{cfunc: "konpeito_resume_music"}
|
|
483
|
+
def self.resume_music: (Integer id) -> void
|
|
484
|
+
|
|
485
|
+
%a{cfunc: "konpeito_update_music"}
|
|
486
|
+
def self.update_music: (Integer id) -> void
|
|
487
|
+
|
|
488
|
+
%a{cfunc: "konpeito_is_music_playing"}
|
|
489
|
+
def self.music_playing?: (Integer id) -> Integer
|
|
490
|
+
|
|
491
|
+
%a{cfunc: "konpeito_set_music_volume"}
|
|
492
|
+
def self.set_music_volume: (Integer id, Float vol) -> void
|
|
493
|
+
|
|
494
|
+
%a{cfunc: "konpeito_set_music_pitch"}
|
|
495
|
+
def self.set_music_pitch: (Integer id, Float pitch) -> void
|
|
496
|
+
|
|
497
|
+
%a{cfunc: "konpeito_get_music_time_length"}
|
|
498
|
+
def self.get_music_time_length: (Integer id) -> Float
|
|
499
|
+
|
|
500
|
+
%a{cfunc: "konpeito_get_music_time_played"}
|
|
501
|
+
def self.get_music_time_played: (Integer id) -> Float
|
|
502
|
+
|
|
503
|
+
%a{cfunc: "konpeito_seek_music"}
|
|
504
|
+
def self.seek_music: (Integer id, Float position) -> void
|
|
505
|
+
|
|
506
|
+
# ── Camera2D ──
|
|
507
|
+
|
|
508
|
+
%a{cfunc: "konpeito_begin_mode_2d"}
|
|
509
|
+
def self.begin_mode_2d: (Float offset_x, Float offset_y, Float target_x, Float target_y, Float rotation, Float zoom) -> void
|
|
510
|
+
|
|
511
|
+
%a{cfunc: "konpeito_end_mode_2d"}
|
|
512
|
+
def self.end_mode_2d: () -> void
|
|
513
|
+
|
|
514
|
+
%a{cfunc: "konpeito_get_world_to_screen_2d_x"}
|
|
515
|
+
def self.get_world_to_screen_2d_x: (Float world_x, Float world_y, Float offset_x, Float offset_y, Float target_x, Float target_y, Float rotation, Float zoom) -> Integer
|
|
516
|
+
|
|
517
|
+
%a{cfunc: "konpeito_get_world_to_screen_2d_y"}
|
|
518
|
+
def self.get_world_to_screen_2d_y: (Float world_x, Float world_y, Float offset_x, Float offset_y, Float target_x, Float target_y, Float rotation, Float zoom) -> Integer
|
|
519
|
+
|
|
520
|
+
# ── File I/O ──
|
|
521
|
+
|
|
522
|
+
%a{cfunc: "konpeito_save_file_text"}
|
|
523
|
+
def self.save_file_text: (String path, String text) -> Integer
|
|
524
|
+
|
|
525
|
+
%a{cfunc: "konpeito_load_file_text"}
|
|
526
|
+
def self.load_file_text: (String path) -> String
|
|
527
|
+
|
|
528
|
+
%a{cfunc: "konpeito_file_exists"}
|
|
529
|
+
def self.file_exists?: (String path) -> Integer
|
|
530
|
+
|
|
531
|
+
%a{cfunc: "konpeito_directory_exists"}
|
|
532
|
+
def self.directory_exists?: (String path) -> Integer
|
|
533
|
+
|
|
534
|
+
# ── Font Management ──
|
|
535
|
+
|
|
536
|
+
%a{cfunc: "konpeito_load_font"}
|
|
537
|
+
def self.load_font: (String path) -> Integer
|
|
538
|
+
|
|
539
|
+
%a{cfunc: "konpeito_load_font_ex"}
|
|
540
|
+
def self.load_font_ex: (String path, Integer size) -> Integer
|
|
541
|
+
|
|
542
|
+
%a{cfunc: "konpeito_unload_font"}
|
|
543
|
+
def self.unload_font: (Integer id) -> void
|
|
544
|
+
|
|
545
|
+
%a{cfunc: "konpeito_draw_text_ex"}
|
|
546
|
+
def self.draw_text_ex: (Integer font_id, String text, Float x, Float y, Float size, Float spacing, Integer tint) -> void
|
|
547
|
+
|
|
548
|
+
%a{cfunc: "konpeito_measure_text_ex_x"}
|
|
549
|
+
def self.measure_text_ex_x: (Integer font_id, String text, Float size, Float spacing) -> Integer
|
|
550
|
+
|
|
551
|
+
%a{cfunc: "konpeito_measure_text_ex_y"}
|
|
552
|
+
def self.measure_text_ex_y: (Integer font_id, String text, Float size, Float spacing) -> Integer
|
|
553
|
+
|
|
554
|
+
# ── Gamepad Input ──
|
|
555
|
+
|
|
556
|
+
%a{cfunc: "konpeito_is_gamepad_available"}
|
|
557
|
+
def self.gamepad_available?: (Integer gamepad) -> Integer
|
|
558
|
+
|
|
559
|
+
%a{cfunc: "konpeito_is_gamepad_button_pressed"}
|
|
560
|
+
def self.gamepad_button_pressed?: (Integer gamepad, Integer button) -> Integer
|
|
561
|
+
|
|
562
|
+
%a{cfunc: "konpeito_is_gamepad_button_down"}
|
|
563
|
+
def self.gamepad_button_down?: (Integer gamepad, Integer button) -> Integer
|
|
564
|
+
|
|
565
|
+
%a{cfunc: "konpeito_is_gamepad_button_released"}
|
|
566
|
+
def self.gamepad_button_released?: (Integer gamepad, Integer button) -> Integer
|
|
567
|
+
|
|
568
|
+
%a{cfunc: "konpeito_is_gamepad_button_up"}
|
|
569
|
+
def self.gamepad_button_up?: (Integer gamepad, Integer button) -> Integer
|
|
570
|
+
|
|
571
|
+
%a{cfunc: "konpeito_get_gamepad_axis_movement"}
|
|
572
|
+
def self.get_gamepad_axis_movement: (Integer gamepad, Integer axis) -> Float
|
|
573
|
+
|
|
574
|
+
%a{cfunc: "konpeito_get_gamepad_axis_count"}
|
|
575
|
+
def self.get_gamepad_axis_count: (Integer gamepad) -> Integer
|
|
576
|
+
|
|
577
|
+
# ── Gamepad Button Constants ──
|
|
578
|
+
|
|
579
|
+
%a{cfunc: "konpeito_gamepad_button_left_face_up"}
|
|
580
|
+
def self.gamepad_button_left_face_up: () -> Integer
|
|
581
|
+
|
|
582
|
+
%a{cfunc: "konpeito_gamepad_button_left_face_right"}
|
|
583
|
+
def self.gamepad_button_left_face_right: () -> Integer
|
|
584
|
+
|
|
585
|
+
%a{cfunc: "konpeito_gamepad_button_left_face_down"}
|
|
586
|
+
def self.gamepad_button_left_face_down: () -> Integer
|
|
587
|
+
|
|
588
|
+
%a{cfunc: "konpeito_gamepad_button_left_face_left"}
|
|
589
|
+
def self.gamepad_button_left_face_left: () -> Integer
|
|
590
|
+
|
|
591
|
+
%a{cfunc: "konpeito_gamepad_button_right_face_up"}
|
|
592
|
+
def self.gamepad_button_right_face_up: () -> Integer
|
|
593
|
+
|
|
594
|
+
%a{cfunc: "konpeito_gamepad_button_right_face_right"}
|
|
595
|
+
def self.gamepad_button_right_face_right: () -> Integer
|
|
596
|
+
|
|
597
|
+
%a{cfunc: "konpeito_gamepad_button_right_face_down"}
|
|
598
|
+
def self.gamepad_button_right_face_down: () -> Integer
|
|
599
|
+
|
|
600
|
+
%a{cfunc: "konpeito_gamepad_button_right_face_left"}
|
|
601
|
+
def self.gamepad_button_right_face_left: () -> Integer
|
|
602
|
+
|
|
603
|
+
%a{cfunc: "konpeito_gamepad_button_left_trigger_1"}
|
|
604
|
+
def self.gamepad_button_left_trigger_1: () -> Integer
|
|
605
|
+
|
|
606
|
+
%a{cfunc: "konpeito_gamepad_button_left_trigger_2"}
|
|
607
|
+
def self.gamepad_button_left_trigger_2: () -> Integer
|
|
608
|
+
|
|
609
|
+
%a{cfunc: "konpeito_gamepad_button_right_trigger_1"}
|
|
610
|
+
def self.gamepad_button_right_trigger_1: () -> Integer
|
|
611
|
+
|
|
612
|
+
%a{cfunc: "konpeito_gamepad_button_right_trigger_2"}
|
|
613
|
+
def self.gamepad_button_right_trigger_2: () -> Integer
|
|
614
|
+
|
|
615
|
+
%a{cfunc: "konpeito_gamepad_button_middle_left"}
|
|
616
|
+
def self.gamepad_button_middle_left: () -> Integer
|
|
617
|
+
|
|
618
|
+
%a{cfunc: "konpeito_gamepad_button_middle"}
|
|
619
|
+
def self.gamepad_button_middle: () -> Integer
|
|
620
|
+
|
|
621
|
+
%a{cfunc: "konpeito_gamepad_button_middle_right"}
|
|
622
|
+
def self.gamepad_button_middle_right: () -> Integer
|
|
623
|
+
|
|
624
|
+
# ── Gamepad Axis Constants ──
|
|
625
|
+
|
|
626
|
+
%a{cfunc: "konpeito_gamepad_axis_left_x"}
|
|
627
|
+
def self.gamepad_axis_left_x: () -> Integer
|
|
628
|
+
|
|
629
|
+
%a{cfunc: "konpeito_gamepad_axis_left_y"}
|
|
630
|
+
def self.gamepad_axis_left_y: () -> Integer
|
|
631
|
+
|
|
632
|
+
%a{cfunc: "konpeito_gamepad_axis_right_x"}
|
|
633
|
+
def self.gamepad_axis_right_x: () -> Integer
|
|
634
|
+
|
|
635
|
+
%a{cfunc: "konpeito_gamepad_axis_right_y"}
|
|
636
|
+
def self.gamepad_axis_right_y: () -> Integer
|
|
637
|
+
|
|
638
|
+
%a{cfunc: "konpeito_gamepad_axis_left_trigger"}
|
|
639
|
+
def self.gamepad_axis_left_trigger: () -> Integer
|
|
640
|
+
|
|
641
|
+
%a{cfunc: "konpeito_gamepad_axis_right_trigger"}
|
|
642
|
+
def self.gamepad_axis_right_trigger: () -> Integer
|
|
643
|
+
|
|
644
|
+
# ── Drawing — Extended Shapes ──
|
|
645
|
+
|
|
646
|
+
%a{cfunc: "konpeito_draw_rectangle_pro"}
|
|
647
|
+
def self.draw_rectangle_pro: (Float x, Float y, Float w, Float h, Float ox, Float oy, Float rotation, Integer color) -> void
|
|
648
|
+
|
|
649
|
+
%a{cfunc: "konpeito_draw_rectangle_rounded"}
|
|
650
|
+
def self.draw_rectangle_rounded: (Float x, Float y, Float w, Float h, Float roundness, Integer segments, Integer color) -> void
|
|
651
|
+
|
|
652
|
+
%a{cfunc: "konpeito_draw_rectangle_gradient_v"}
|
|
653
|
+
def self.draw_rectangle_gradient_v: (Integer x, Integer y, Integer w, Integer h, Integer color1, Integer color2) -> void
|
|
654
|
+
|
|
655
|
+
%a{cfunc: "konpeito_draw_rectangle_gradient_h"}
|
|
656
|
+
def self.draw_rectangle_gradient_h: (Integer x, Integer y, Integer w, Integer h, Integer color1, Integer color2) -> void
|
|
657
|
+
|
|
658
|
+
%a{cfunc: "konpeito_draw_circle_sector"}
|
|
659
|
+
def self.draw_circle_sector: (Integer cx, Integer cy, Float radius, Float start_angle, Float end_angle, Integer segments, Integer color) -> void
|
|
660
|
+
|
|
661
|
+
# ── Collision Detection ──
|
|
662
|
+
|
|
663
|
+
%a{cfunc: "konpeito_check_collision_recs"}
|
|
664
|
+
def self.check_collision_recs: (Float x1, Float y1, Float w1, Float h1, Float x2, Float y2, Float w2, Float h2) -> Integer
|
|
665
|
+
|
|
666
|
+
%a{cfunc: "konpeito_check_collision_circles"}
|
|
667
|
+
def self.check_collision_circles: (Float cx1, Float cy1, Float r1, Float cx2, Float cy2, Float r2) -> Integer
|
|
668
|
+
|
|
669
|
+
%a{cfunc: "konpeito_check_collision_circle_rec"}
|
|
670
|
+
def self.check_collision_circle_rec: (Float cx, Float cy, Float radius, Float rx, Float ry, Float rw, Float rh) -> Integer
|
|
671
|
+
|
|
672
|
+
%a{cfunc: "konpeito_check_collision_point_rec"}
|
|
673
|
+
def self.check_collision_point_rec: (Float px, Float py, Float rx, Float ry, Float rw, Float rh) -> Integer
|
|
674
|
+
|
|
675
|
+
%a{cfunc: "konpeito_check_collision_point_circle"}
|
|
676
|
+
def self.check_collision_point_circle: (Float px, Float py, Float cx, Float cy, Float radius) -> Integer
|
|
389
677
|
end
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <raylib.h>
|
|
13
13
|
#include <string.h>
|
|
14
14
|
#include <math.h>
|
|
15
|
+
#include <stdlib.h>
|
|
15
16
|
|
|
16
17
|
/* ── macOS app activation ── */
|
|
17
18
|
#ifdef __APPLE__
|
|
@@ -258,3 +259,512 @@ int konpeito_get_random_value(int min, int max) {
|
|
|
258
259
|
int konpeito_flag_window_resizable(void) { return FLAG_WINDOW_RESIZABLE; }
|
|
259
260
|
int konpeito_flag_window_highdpi(void) { return FLAG_WINDOW_HIGHDPI; }
|
|
260
261
|
int konpeito_flag_msaa_4x_hint(void) { return FLAG_MSAA_4X_HINT; }
|
|
262
|
+
|
|
263
|
+
/* ═══════════════════════════════════════════
|
|
264
|
+
* Texture Management (ID-based table)
|
|
265
|
+
* ═══════════════════════════════════════════ */
|
|
266
|
+
|
|
267
|
+
#define MAX_TEXTURES 256
|
|
268
|
+
|
|
269
|
+
static Texture2D g_textures[MAX_TEXTURES];
|
|
270
|
+
static int g_texture_used[MAX_TEXTURES];
|
|
271
|
+
static int g_textures_initialized = 0;
|
|
272
|
+
|
|
273
|
+
static void ensure_textures_init(void) {
|
|
274
|
+
if (g_textures_initialized) return;
|
|
275
|
+
memset(g_texture_used, 0, sizeof(g_texture_used));
|
|
276
|
+
g_textures_initialized = 1;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
static int alloc_texture_slot(void) {
|
|
280
|
+
ensure_textures_init();
|
|
281
|
+
for (int i = 0; i < MAX_TEXTURES; i++) {
|
|
282
|
+
if (!g_texture_used[i]) {
|
|
283
|
+
g_texture_used[i] = 1;
|
|
284
|
+
return i;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return -1;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
int konpeito_load_texture(const char *path) {
|
|
291
|
+
int slot = alloc_texture_slot();
|
|
292
|
+
if (slot < 0) return -1;
|
|
293
|
+
g_textures[slot] = LoadTexture(path);
|
|
294
|
+
if (g_textures[slot].id == 0) {
|
|
295
|
+
g_texture_used[slot] = 0;
|
|
296
|
+
return -1;
|
|
297
|
+
}
|
|
298
|
+
return slot;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
void konpeito_unload_texture(int id) {
|
|
302
|
+
if (id < 0 || id >= MAX_TEXTURES || !g_texture_used[id]) return;
|
|
303
|
+
UnloadTexture(g_textures[id]);
|
|
304
|
+
g_texture_used[id] = 0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
void konpeito_draw_texture(int id, int x, int y, int tint) {
|
|
308
|
+
if (id < 0 || id >= MAX_TEXTURES || !g_texture_used[id]) return;
|
|
309
|
+
DrawTexture(g_textures[id], x, y, int_to_color(tint));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
void konpeito_draw_texture_rec(int id, double sx, double sy, double sw, double sh,
|
|
313
|
+
int dx, int dy, int tint) {
|
|
314
|
+
if (id < 0 || id >= MAX_TEXTURES || !g_texture_used[id]) return;
|
|
315
|
+
Rectangle source = { (float)sx, (float)sy, (float)sw, (float)sh };
|
|
316
|
+
Vector2 pos = { (float)dx, (float)dy };
|
|
317
|
+
DrawTextureRec(g_textures[id], source, pos, int_to_color(tint));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
void konpeito_draw_texture_pro(int id,
|
|
321
|
+
double sx, double sy, double sw, double sh,
|
|
322
|
+
double dx, double dy, double dw, double dh,
|
|
323
|
+
double ox, double oy, double rotation, int tint) {
|
|
324
|
+
if (id < 0 || id >= MAX_TEXTURES || !g_texture_used[id]) return;
|
|
325
|
+
Rectangle source = { (float)sx, (float)sy, (float)sw, (float)sh };
|
|
326
|
+
Rectangle dest = { (float)dx, (float)dy, (float)dw, (float)dh };
|
|
327
|
+
Vector2 origin = { (float)ox, (float)oy };
|
|
328
|
+
DrawTexturePro(g_textures[id], source, dest, origin, (float)rotation, int_to_color(tint));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
int konpeito_get_texture_width(int id) {
|
|
332
|
+
if (id < 0 || id >= MAX_TEXTURES || !g_texture_used[id]) return 0;
|
|
333
|
+
return g_textures[id].width;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
int konpeito_get_texture_height(int id) {
|
|
337
|
+
if (id < 0 || id >= MAX_TEXTURES || !g_texture_used[id]) return 0;
|
|
338
|
+
return g_textures[id].height;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
int konpeito_is_texture_valid(int id) {
|
|
342
|
+
if (id < 0 || id >= MAX_TEXTURES || !g_texture_used[id]) return 0;
|
|
343
|
+
return (int)IsTextureValid(g_textures[id]);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
void konpeito_draw_texture_scaled(int id, int x, int y, double scale, int tint) {
|
|
347
|
+
if (id < 0 || id >= MAX_TEXTURES || !g_texture_used[id]) return;
|
|
348
|
+
DrawTextureEx(g_textures[id], (Vector2){(float)x, (float)y},
|
|
349
|
+
0.0f, (float)scale, int_to_color(tint));
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/* ═══════════════════════════════════════════
|
|
353
|
+
* Audio Management (ID-based tables)
|
|
354
|
+
* ═══════════════════════════════════════════ */
|
|
355
|
+
|
|
356
|
+
#define MAX_SOUNDS 128
|
|
357
|
+
#define MAX_MUSIC 32
|
|
358
|
+
|
|
359
|
+
static Sound g_sounds[MAX_SOUNDS];
|
|
360
|
+
static int g_sound_used[MAX_SOUNDS];
|
|
361
|
+
static int g_sounds_initialized = 0;
|
|
362
|
+
|
|
363
|
+
static Music g_music[MAX_MUSIC];
|
|
364
|
+
static int g_music_used[MAX_MUSIC];
|
|
365
|
+
static int g_music_initialized = 0;
|
|
366
|
+
|
|
367
|
+
static void ensure_sounds_init(void) {
|
|
368
|
+
if (g_sounds_initialized) return;
|
|
369
|
+
memset(g_sound_used, 0, sizeof(g_sound_used));
|
|
370
|
+
g_sounds_initialized = 1;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
static void ensure_music_init(void) {
|
|
374
|
+
if (g_music_initialized) return;
|
|
375
|
+
memset(g_music_used, 0, sizeof(g_music_used));
|
|
376
|
+
g_music_initialized = 1;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/* Audio device */
|
|
380
|
+
void konpeito_init_audio_device(void) { InitAudioDevice(); }
|
|
381
|
+
void konpeito_close_audio_device(void) { CloseAudioDevice(); }
|
|
382
|
+
int konpeito_is_audio_device_ready(void) { return (int)IsAudioDeviceReady(); }
|
|
383
|
+
void konpeito_set_master_volume(double vol) { SetMasterVolume((float)vol); }
|
|
384
|
+
double konpeito_get_master_volume(void) { return (double)GetMasterVolume(); }
|
|
385
|
+
|
|
386
|
+
/* Sound */
|
|
387
|
+
int konpeito_load_sound(const char *path) {
|
|
388
|
+
ensure_sounds_init();
|
|
389
|
+
for (int i = 0; i < MAX_SOUNDS; i++) {
|
|
390
|
+
if (!g_sound_used[i]) {
|
|
391
|
+
g_sounds[i] = LoadSound(path);
|
|
392
|
+
if (g_sounds[i].frameCount == 0) return -1;
|
|
393
|
+
g_sound_used[i] = 1;
|
|
394
|
+
return i;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return -1;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
void konpeito_unload_sound(int id) {
|
|
401
|
+
if (id < 0 || id >= MAX_SOUNDS || !g_sound_used[id]) return;
|
|
402
|
+
UnloadSound(g_sounds[id]);
|
|
403
|
+
g_sound_used[id] = 0;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
void konpeito_play_sound(int id) {
|
|
407
|
+
if (id < 0 || id >= MAX_SOUNDS || !g_sound_used[id]) return;
|
|
408
|
+
PlaySound(g_sounds[id]);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
void konpeito_stop_sound(int id) {
|
|
412
|
+
if (id < 0 || id >= MAX_SOUNDS || !g_sound_used[id]) return;
|
|
413
|
+
StopSound(g_sounds[id]);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
void konpeito_pause_sound(int id) {
|
|
417
|
+
if (id < 0 || id >= MAX_SOUNDS || !g_sound_used[id]) return;
|
|
418
|
+
PauseSound(g_sounds[id]);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
void konpeito_resume_sound(int id) {
|
|
422
|
+
if (id < 0 || id >= MAX_SOUNDS || !g_sound_used[id]) return;
|
|
423
|
+
ResumeSound(g_sounds[id]);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
int konpeito_is_sound_playing(int id) {
|
|
427
|
+
if (id < 0 || id >= MAX_SOUNDS || !g_sound_used[id]) return 0;
|
|
428
|
+
return (int)IsSoundPlaying(g_sounds[id]);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
void konpeito_set_sound_volume(int id, double vol) {
|
|
432
|
+
if (id < 0 || id >= MAX_SOUNDS || !g_sound_used[id]) return;
|
|
433
|
+
SetSoundVolume(g_sounds[id], (float)vol);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
void konpeito_set_sound_pitch(int id, double pitch) {
|
|
437
|
+
if (id < 0 || id >= MAX_SOUNDS || !g_sound_used[id]) return;
|
|
438
|
+
SetSoundPitch(g_sounds[id], (float)pitch);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/* Music stream */
|
|
442
|
+
int konpeito_load_music(const char *path) {
|
|
443
|
+
ensure_music_init();
|
|
444
|
+
for (int i = 0; i < MAX_MUSIC; i++) {
|
|
445
|
+
if (!g_music_used[i]) {
|
|
446
|
+
g_music[i] = LoadMusicStream(path);
|
|
447
|
+
if (g_music[i].frameCount == 0) return -1;
|
|
448
|
+
g_music_used[i] = 1;
|
|
449
|
+
return i;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return -1;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
void konpeito_unload_music(int id) {
|
|
456
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
457
|
+
UnloadMusicStream(g_music[id]);
|
|
458
|
+
g_music_used[id] = 0;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
void konpeito_play_music(int id) {
|
|
462
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
463
|
+
PlayMusicStream(g_music[id]);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
void konpeito_stop_music(int id) {
|
|
467
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
468
|
+
StopMusicStream(g_music[id]);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
void konpeito_pause_music(int id) {
|
|
472
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
473
|
+
PauseMusicStream(g_music[id]);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
void konpeito_resume_music(int id) {
|
|
477
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
478
|
+
ResumeMusicStream(g_music[id]);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
void konpeito_update_music(int id) {
|
|
482
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
483
|
+
UpdateMusicStream(g_music[id]);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
int konpeito_is_music_playing(int id) {
|
|
487
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return 0;
|
|
488
|
+
return (int)IsMusicStreamPlaying(g_music[id]);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
void konpeito_set_music_volume(int id, double vol) {
|
|
492
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
493
|
+
SetMusicVolume(g_music[id], (float)vol);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
void konpeito_set_music_pitch(int id, double pitch) {
|
|
497
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
498
|
+
SetMusicPitch(g_music[id], (float)pitch);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
double konpeito_get_music_time_length(int id) {
|
|
502
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return 0.0;
|
|
503
|
+
return (double)GetMusicTimeLength(g_music[id]);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
double konpeito_get_music_time_played(int id) {
|
|
507
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return 0.0;
|
|
508
|
+
return (double)GetMusicTimePlayed(g_music[id]);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
void konpeito_seek_music(int id, double position) {
|
|
512
|
+
if (id < 0 || id >= MAX_MUSIC || !g_music_used[id]) return;
|
|
513
|
+
SeekMusicStream(g_music[id], (float)position);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/* ═══════════════════════════════════════════
|
|
517
|
+
* Camera2D
|
|
518
|
+
* ═══════════════════════════════════════════ */
|
|
519
|
+
|
|
520
|
+
void konpeito_begin_mode_2d(double offset_x, double offset_y,
|
|
521
|
+
double target_x, double target_y,
|
|
522
|
+
double rotation, double zoom) {
|
|
523
|
+
Camera2D cam = {0};
|
|
524
|
+
cam.offset = (Vector2){ (float)offset_x, (float)offset_y };
|
|
525
|
+
cam.target = (Vector2){ (float)target_x, (float)target_y };
|
|
526
|
+
cam.rotation = (float)rotation;
|
|
527
|
+
cam.zoom = (float)zoom;
|
|
528
|
+
BeginMode2D(cam);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
void konpeito_end_mode_2d(void) {
|
|
532
|
+
EndMode2D();
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/* World ↔ screen coordinate conversion */
|
|
536
|
+
int konpeito_get_world_to_screen_2d_x(double world_x, double world_y,
|
|
537
|
+
double offset_x, double offset_y,
|
|
538
|
+
double target_x, double target_y,
|
|
539
|
+
double rotation, double zoom) {
|
|
540
|
+
Camera2D cam = {0};
|
|
541
|
+
cam.offset = (Vector2){ (float)offset_x, (float)offset_y };
|
|
542
|
+
cam.target = (Vector2){ (float)target_x, (float)target_y };
|
|
543
|
+
cam.rotation = (float)rotation;
|
|
544
|
+
cam.zoom = (float)zoom;
|
|
545
|
+
Vector2 result = GetWorldToScreen2D((Vector2){(float)world_x, (float)world_y}, cam);
|
|
546
|
+
return (int)result.x;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
int konpeito_get_world_to_screen_2d_y(double world_x, double world_y,
|
|
550
|
+
double offset_x, double offset_y,
|
|
551
|
+
double target_x, double target_y,
|
|
552
|
+
double rotation, double zoom) {
|
|
553
|
+
Camera2D cam = {0};
|
|
554
|
+
cam.offset = (Vector2){ (float)offset_x, (float)offset_y };
|
|
555
|
+
cam.target = (Vector2){ (float)target_x, (float)target_y };
|
|
556
|
+
cam.rotation = (float)rotation;
|
|
557
|
+
cam.zoom = (float)zoom;
|
|
558
|
+
Vector2 result = GetWorldToScreen2D((Vector2){(float)world_x, (float)world_y}, cam);
|
|
559
|
+
return (int)result.y;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/* ═══════════════════════════════════════════
|
|
563
|
+
* File I/O (Save / Load)
|
|
564
|
+
* ═══════════════════════════════════════════ */
|
|
565
|
+
|
|
566
|
+
int konpeito_save_file_text(const char *path, const char *text) {
|
|
567
|
+
return (int)SaveFileText(path, (char *)text);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const char *konpeito_load_file_text(const char *path) {
|
|
571
|
+
return LoadFileText(path);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
int konpeito_file_exists(const char *path) {
|
|
575
|
+
return (int)FileExists(path);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
int konpeito_directory_exists(const char *path) {
|
|
579
|
+
return (int)DirectoryExists(path);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/* ═══════════════════════════════════════════
|
|
583
|
+
* Font Management (ID-based table)
|
|
584
|
+
* ═══════════════════════════════════════════ */
|
|
585
|
+
|
|
586
|
+
#define MAX_FONTS 32
|
|
587
|
+
|
|
588
|
+
static Font g_raylib_fonts[MAX_FONTS];
|
|
589
|
+
static int g_raylib_font_used[MAX_FONTS];
|
|
590
|
+
static int g_raylib_fonts_initialized = 0;
|
|
591
|
+
|
|
592
|
+
static void ensure_fonts_init(void) {
|
|
593
|
+
if (g_raylib_fonts_initialized) return;
|
|
594
|
+
memset(g_raylib_font_used, 0, sizeof(g_raylib_font_used));
|
|
595
|
+
g_raylib_fonts_initialized = 1;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
int konpeito_load_font(const char *path) {
|
|
599
|
+
ensure_fonts_init();
|
|
600
|
+
for (int i = 0; i < MAX_FONTS; i++) {
|
|
601
|
+
if (!g_raylib_font_used[i]) {
|
|
602
|
+
g_raylib_fonts[i] = LoadFont(path);
|
|
603
|
+
if (g_raylib_fonts[i].baseSize == 0) return -1;
|
|
604
|
+
g_raylib_font_used[i] = 1;
|
|
605
|
+
return i;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return -1;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
int konpeito_load_font_ex(const char *path, int size) {
|
|
612
|
+
ensure_fonts_init();
|
|
613
|
+
for (int i = 0; i < MAX_FONTS; i++) {
|
|
614
|
+
if (!g_raylib_font_used[i]) {
|
|
615
|
+
g_raylib_fonts[i] = LoadFontEx(path, size, NULL, 0);
|
|
616
|
+
if (g_raylib_fonts[i].baseSize == 0) return -1;
|
|
617
|
+
g_raylib_font_used[i] = 1;
|
|
618
|
+
return i;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return -1;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
void konpeito_unload_font(int id) {
|
|
625
|
+
if (id < 0 || id >= MAX_FONTS || !g_raylib_font_used[id]) return;
|
|
626
|
+
UnloadFont(g_raylib_fonts[id]);
|
|
627
|
+
g_raylib_font_used[id] = 0;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
void konpeito_draw_text_ex(int font_id, const char *text,
|
|
631
|
+
double x, double y, double size,
|
|
632
|
+
double spacing, int tint) {
|
|
633
|
+
Font font;
|
|
634
|
+
if (font_id < 0 || font_id >= MAX_FONTS || !g_raylib_font_used[font_id]) {
|
|
635
|
+
font = GetFontDefault();
|
|
636
|
+
} else {
|
|
637
|
+
font = g_raylib_fonts[font_id];
|
|
638
|
+
}
|
|
639
|
+
DrawTextEx(font, text, (Vector2){(float)x, (float)y},
|
|
640
|
+
(float)size, (float)spacing, int_to_color(tint));
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
int konpeito_measure_text_ex_x(int font_id, const char *text,
|
|
644
|
+
double size, double spacing) {
|
|
645
|
+
Font font;
|
|
646
|
+
if (font_id < 0 || font_id >= MAX_FONTS || !g_raylib_font_used[font_id]) {
|
|
647
|
+
font = GetFontDefault();
|
|
648
|
+
} else {
|
|
649
|
+
font = g_raylib_fonts[font_id];
|
|
650
|
+
}
|
|
651
|
+
Vector2 v = MeasureTextEx(font, text, (float)size, (float)spacing);
|
|
652
|
+
return (int)v.x;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
int konpeito_measure_text_ex_y(int font_id, const char *text,
|
|
656
|
+
double size, double spacing) {
|
|
657
|
+
Font font;
|
|
658
|
+
if (font_id < 0 || font_id >= MAX_FONTS || !g_raylib_font_used[font_id]) {
|
|
659
|
+
font = GetFontDefault();
|
|
660
|
+
} else {
|
|
661
|
+
font = g_raylib_fonts[font_id];
|
|
662
|
+
}
|
|
663
|
+
Vector2 v = MeasureTextEx(font, text, (float)size, (float)spacing);
|
|
664
|
+
return (int)v.y;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/* ═══════════════════════════════════════════
|
|
668
|
+
* Gamepad Input
|
|
669
|
+
* ═══════════════════════════════════════════ */
|
|
670
|
+
|
|
671
|
+
int konpeito_is_gamepad_available(int gamepad) { return (int)IsGamepadAvailable(gamepad); }
|
|
672
|
+
int konpeito_is_gamepad_button_pressed(int gp, int btn) { return (int)IsGamepadButtonPressed(gp, btn); }
|
|
673
|
+
int konpeito_is_gamepad_button_down(int gp, int btn) { return (int)IsGamepadButtonDown(gp, btn); }
|
|
674
|
+
int konpeito_is_gamepad_button_released(int gp, int btn){ return (int)IsGamepadButtonReleased(gp, btn); }
|
|
675
|
+
int konpeito_is_gamepad_button_up(int gp, int btn) { return (int)IsGamepadButtonUp(gp, btn); }
|
|
676
|
+
double konpeito_get_gamepad_axis_movement(int gp, int axis) {
|
|
677
|
+
return (double)GetGamepadAxisMovement(gp, axis);
|
|
678
|
+
}
|
|
679
|
+
int konpeito_get_gamepad_axis_count(int gp) { return GetGamepadAxisCount(gp); }
|
|
680
|
+
|
|
681
|
+
/* Gamepad button constants */
|
|
682
|
+
int konpeito_gamepad_button_left_face_up(void) { return GAMEPAD_BUTTON_LEFT_FACE_UP; }
|
|
683
|
+
int konpeito_gamepad_button_left_face_right(void) { return GAMEPAD_BUTTON_LEFT_FACE_RIGHT; }
|
|
684
|
+
int konpeito_gamepad_button_left_face_down(void) { return GAMEPAD_BUTTON_LEFT_FACE_DOWN; }
|
|
685
|
+
int konpeito_gamepad_button_left_face_left(void) { return GAMEPAD_BUTTON_LEFT_FACE_LEFT; }
|
|
686
|
+
int konpeito_gamepad_button_right_face_up(void) { return GAMEPAD_BUTTON_RIGHT_FACE_UP; }
|
|
687
|
+
int konpeito_gamepad_button_right_face_right(void){ return GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; }
|
|
688
|
+
int konpeito_gamepad_button_right_face_down(void) { return GAMEPAD_BUTTON_RIGHT_FACE_DOWN; }
|
|
689
|
+
int konpeito_gamepad_button_right_face_left(void) { return GAMEPAD_BUTTON_RIGHT_FACE_LEFT; }
|
|
690
|
+
int konpeito_gamepad_button_left_trigger_1(void) { return GAMEPAD_BUTTON_LEFT_TRIGGER_1; }
|
|
691
|
+
int konpeito_gamepad_button_left_trigger_2(void) { return GAMEPAD_BUTTON_LEFT_TRIGGER_2; }
|
|
692
|
+
int konpeito_gamepad_button_right_trigger_1(void) { return GAMEPAD_BUTTON_RIGHT_TRIGGER_1; }
|
|
693
|
+
int konpeito_gamepad_button_right_trigger_2(void) { return GAMEPAD_BUTTON_RIGHT_TRIGGER_2; }
|
|
694
|
+
int konpeito_gamepad_button_middle_left(void) { return GAMEPAD_BUTTON_MIDDLE_LEFT; }
|
|
695
|
+
int konpeito_gamepad_button_middle(void) { return GAMEPAD_BUTTON_MIDDLE; }
|
|
696
|
+
int konpeito_gamepad_button_middle_right(void) { return GAMEPAD_BUTTON_MIDDLE_RIGHT; }
|
|
697
|
+
|
|
698
|
+
/* Gamepad axis constants */
|
|
699
|
+
int konpeito_gamepad_axis_left_x(void) { return GAMEPAD_AXIS_LEFT_X; }
|
|
700
|
+
int konpeito_gamepad_axis_left_y(void) { return GAMEPAD_AXIS_LEFT_Y; }
|
|
701
|
+
int konpeito_gamepad_axis_right_x(void) { return GAMEPAD_AXIS_RIGHT_X; }
|
|
702
|
+
int konpeito_gamepad_axis_right_y(void) { return GAMEPAD_AXIS_RIGHT_Y; }
|
|
703
|
+
int konpeito_gamepad_axis_left_trigger(void) { return GAMEPAD_AXIS_LEFT_TRIGGER; }
|
|
704
|
+
int konpeito_gamepad_axis_right_trigger(void){ return GAMEPAD_AXIS_RIGHT_TRIGGER; }
|
|
705
|
+
|
|
706
|
+
/* ═══════════════════════════════════════════
|
|
707
|
+
* Drawing — Extended Shapes
|
|
708
|
+
* ═══════════════════════════════════════════ */
|
|
709
|
+
|
|
710
|
+
void konpeito_draw_rectangle_pro(double x, double y, double w, double h,
|
|
711
|
+
double ox, double oy, double rotation, int color) {
|
|
712
|
+
DrawRectanglePro((Rectangle){(float)x, (float)y, (float)w, (float)h},
|
|
713
|
+
(Vector2){(float)ox, (float)oy}, (float)rotation, int_to_color(color));
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
void konpeito_draw_rectangle_rounded(double x, double y, double w, double h,
|
|
717
|
+
double roundness, int segments, int color) {
|
|
718
|
+
DrawRectangleRounded((Rectangle){(float)x, (float)y, (float)w, (float)h},
|
|
719
|
+
(float)roundness, segments, int_to_color(color));
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
void konpeito_draw_rectangle_gradient_v(int x, int y, int w, int h, int color1, int color2) {
|
|
723
|
+
DrawRectangleGradientV(x, y, w, h, int_to_color(color1), int_to_color(color2));
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
void konpeito_draw_rectangle_gradient_h(int x, int y, int w, int h, int color1, int color2) {
|
|
727
|
+
DrawRectangleGradientH(x, y, w, h, int_to_color(color1), int_to_color(color2));
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
void konpeito_draw_circle_sector(int cx, int cy, double radius,
|
|
731
|
+
double start_angle, double end_angle,
|
|
732
|
+
int segments, int color) {
|
|
733
|
+
DrawCircleSector((Vector2){(float)cx, (float)cy}, (float)radius,
|
|
734
|
+
(float)start_angle, (float)end_angle, segments, int_to_color(color));
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/* ═══════════════════════════════════════════
|
|
738
|
+
* Collision Detection Helpers
|
|
739
|
+
* ═══════════════════════════════════════════ */
|
|
740
|
+
|
|
741
|
+
int konpeito_check_collision_recs(double x1, double y1, double w1, double h1,
|
|
742
|
+
double x2, double y2, double w2, double h2) {
|
|
743
|
+
Rectangle r1 = { (float)x1, (float)y1, (float)w1, (float)h1 };
|
|
744
|
+
Rectangle r2 = { (float)x2, (float)y2, (float)w2, (float)h2 };
|
|
745
|
+
return (int)CheckCollisionRecs(r1, r2);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
int konpeito_check_collision_circles(double cx1, double cy1, double r1,
|
|
749
|
+
double cx2, double cy2, double r2) {
|
|
750
|
+
return (int)CheckCollisionCircles((Vector2){(float)cx1, (float)cy1}, (float)r1,
|
|
751
|
+
(Vector2){(float)cx2, (float)cy2}, (float)r2);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
int konpeito_check_collision_circle_rec(double cx, double cy, double radius,
|
|
755
|
+
double rx, double ry, double rw, double rh) {
|
|
756
|
+
return (int)CheckCollisionCircleRec((Vector2){(float)cx, (float)cy}, (float)radius,
|
|
757
|
+
(Rectangle){(float)rx, (float)ry, (float)rw, (float)rh});
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
int konpeito_check_collision_point_rec(double px, double py,
|
|
761
|
+
double rx, double ry, double rw, double rh) {
|
|
762
|
+
return (int)CheckCollisionPointRec((Vector2){(float)px, (float)py},
|
|
763
|
+
(Rectangle){(float)rx, (float)ry, (float)rw, (float)rh});
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
int konpeito_check_collision_point_circle(double px, double py,
|
|
767
|
+
double cx, double cy, double radius) {
|
|
768
|
+
return (int)CheckCollisionPointCircle((Vector2){(float)px, (float)py},
|
|
769
|
+
(Vector2){(float)cx, (float)cy}, (float)radius);
|
|
770
|
+
}
|
|
@@ -140,8 +140,8 @@ module Konpeito
|
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
# Iterate over all native modules
|
|
143
|
-
def each_native_module(&
|
|
144
|
-
@native_modules.each(&
|
|
143
|
+
def each_native_module(&)
|
|
144
|
+
@native_modules.each(&)
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
# Check if a class is explicitly boxed (VALUE-based, for CRuby interop)
|
data/lib/konpeito/version.rb
CHANGED