Skip to content

Commit

Permalink
Use a set version of ocamlformat
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetiot authored and tjammer committed Oct 26, 2024
1 parent 401174a commit 923a28e
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

profile = default
version = 0.26.2
2 changes: 1 addition & 1 deletion examples/audio/audio_module_playing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ let rec loop circles music pause =

circles.(i) <-
(if alpha <= 0.0 then random_circle ()
else { circle with alpha; speed; radius })))
else { circle with alpha; speed; radius })))
circles;
begin_drawing ();

Expand Down
15 changes: 8 additions & 7 deletions examples/core/core_2d_camera.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,26 @@ let rec loop (player, buildings, colors, camera) =
| false ->
let open Raylib in
(if is_key_down Key.Right then Rectangle.(set_x player (x player +. 2.0))
else if is_key_down Key.Left then
Rectangle.(set_x player (x player -. 2.0)));
else if is_key_down Key.Left then
Rectangle.(set_x player (x player -. 2.0)));

Camera2D.set_target camera
(Vector2.create
(Rectangle.x player +. 20.0)
(Rectangle.y player +. 20.0));

(if is_key_down Key.A then
Camera2D.(
set_rotation camera (Float.max (-40.0) (rotation camera -. 1.0)))
else if is_key_down Key.S then
Camera2D.(set_rotation camera (Float.min 40.0 (rotation camera +. 1.0))));
Camera2D.(
set_rotation camera (Float.max (-40.0) (rotation camera -. 1.0)))
else if is_key_down Key.S then
Camera2D.(
set_rotation camera (Float.min 40.0 (rotation camera +. 1.0))));

Camera2D.(
set_zoom camera (zoom camera +. (get_mouse_wheel_move () *. 0.05)));

(if Camera2D.zoom camera > 3.0 then Camera2D.(set_zoom camera 3.0)
else if Camera2D.zoom camera < 0.1 then Camera2D.(set_zoom camera 0.1));
else if Camera2D.zoom camera < 0.1 then Camera2D.(set_zoom camera 0.1));

if is_key_pressed Key.R then (
Camera2D.(
Expand Down
25 changes: 13 additions & 12 deletions examples/shapes/shapes_collision_area.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@ let rec loop (pause, box_a, box_a_speed_x, box_b, box_collision) =

(* Make sure Box B does not go out of move area limits *)
(if
Rectangle.(x box_b +. width box_b >= Float.of_int (get_screen_width ()))
then
Rectangle.(
set_x box_b (Float.of_int (get_screen_width ()) -. width box_b))
else if Rectangle.(x box_b <= 0.0) then Rectangle.(set_x box_b 0.0));
Rectangle.(
x box_b +. width box_b >= Float.of_int (get_screen_width ()))
then
Rectangle.(
set_x box_b (Float.of_int (get_screen_width ()) -. width box_b))
else if Rectangle.(x box_b <= 0.0) then Rectangle.(set_x box_b 0.0));
(if
Rectangle.(
y box_b +. height box_b >= Float.of_int (get_screen_height ()))
then
Rectangle.(
set_y box_b (Float.of_int (get_screen_height ()) -. height box_b))
else if Rectangle.(y box_b <= screen_upper_limit) then
Rectangle.(set_y box_b screen_upper_limit));
Rectangle.(
y box_b +. height box_b >= Float.of_int (get_screen_height ()))
then
Rectangle.(
set_y box_b (Float.of_int (get_screen_height ()) -. height box_b))
else if Rectangle.(y box_b <= screen_upper_limit) then
Rectangle.(set_y box_b screen_upper_limit));

(* Check boxes collision *)
let collision = check_collision_recs box_a box_b in
Expand Down
6 changes: 3 additions & 3 deletions examples/text/text_font_filters.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ let rec loop font font_size font_position filter =
let text_size = measure_text_ex font msg (Float.of_int font_size) 0.0 in

(if is_key_down Key.Left then
Vector2.(set_x font_position (x font_position -. 10.0))
else if is_key_down Key.Right then
Vector2.(set_x font_position (x font_position +. 10.0)));
Vector2.(set_x font_position (x font_position -. 10.0))
else if is_key_down Key.Right then
Vector2.(set_x font_position (x font_position +. 10.0)));

let font =
if is_file_dropped () then (
Expand Down
10 changes: 5 additions & 5 deletions examples/textures/textures_bunnymark.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ let rec loop bunnies bunnies_count tex_bunny =
V.(set_x b.position (x b.position +. x b.speed));
V.(set_y b.position (y b.position +. y b.speed));
(if
V.x b.position +. (Float.of_int (Texture.width tex_bunny) /. 2.0)
> Float.of_int (get_screen_width ())
|| V.x b.position +. (Float.of_int (Texture.width tex_bunny) /. 2.0)
< 0.0
then V.(set_x b.speed (x b.speed *. -1.0)));
V.x b.position +. (Float.of_int (Texture.width tex_bunny) /. 2.0)
> Float.of_int (get_screen_width ())
|| V.x b.position +. (Float.of_int (Texture.width tex_bunny) /. 2.0)
< 0.0
then V.(set_x b.speed (x b.speed *. -1.0)));
if
V.y b.position +. (Float.of_int (Texture.height tex_bunny) /. 2.0)
> Float.of_int (get_screen_height ())
Expand Down
10 changes: 8 additions & 2 deletions src/c/functions/raylib_functions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,16 @@ module Description (F : Ctypes.FOREIGN) = struct
foreign "UnloadRandomSequence" (ptr int @-> returning void)

let take_screenshot = foreign "TakeScreenshot" (string @-> returning void)
let set_config_flags = foreign "SetConfigFlags" (ConfigFlags.t_bitmask @-> returning void)

let set_config_flags =
foreign "SetConfigFlags" (ConfigFlags.t_bitmask @-> returning void)

let open_url = foreign "OpenURL" (string @-> returning void)
let trace_log = foreign "TraceLog" (int @-> string @-> returning void)
let set_trace_log_level = foreign "SetTraceLogLevel" (TraceLogLevel.t @-> returning void)

let set_trace_log_level =
foreign "SetTraceLogLevel" (TraceLogLevel.t @-> returning void)

let mem_alloc = foreign "MemAlloc" (int @-> returning (ptr void))

let mem_realloc =
Expand Down
10 changes: 5 additions & 5 deletions src/util/raylib_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ module Enum = struct
let nm = enum.name.name in
Printf.sprintf "module %s = struct\n include %s\n\n" nm nm
^ (if enum.bitmask then
Printf.sprintf
" let t_bitmask = build_enum_bitmask \"%s\" Ctypes.int64_t \
~typedef:true vals\n\n"
nm
else "")
Printf.sprintf
" let t_bitmask = build_enum_bitmask \"%s\" Ctypes.int64_t \
~typedef:true vals\n\n"
nm
else "")
^ " let to_int x = Unsigned.UInt32.to_int Ctypes.(coerce t uint32_t x)\n"
^ " let of_int i = Ctypes.(coerce uint32_t t (Unsigned.UInt32.of_int i))\n\
end\n\n"
Expand Down

0 comments on commit 923a28e

Please sign in to comment.