In this lesson, we will program a ball which bounces against the edges of a box, and which is duplicated on every emission of a signal split split. Here is an example of what we aim to achieve: lessons/lesson2/split.rml

We first define the data structure to represent the bounds of a box.

type box =
    { left: float;
      right: float;
      top: float;
      bot: float; }

We create a box.

let box =
  { left = 0.; right = 400.;
    bot = 0.; top = 400.; }

We display the box.

let () =
  let g =
    " " ^
    (string_of_int (int_of_float (box.right -. box.left))) ^
    "x" ^
    (string_of_int (int_of_float (box.top -. box.bot)))
  in
  Graphics.open_graph g