Skip to content

dalps/crobots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0884c33 · Mar 4, 2024
Feb 2, 2024
Mar 4, 2024
Mar 4, 2024
Mar 4, 2024
Dec 4, 2023
Feb 2, 2024
Mar 4, 2024
Dec 1, 2023
Dec 1, 2023

Repository files navigation

🤖 CROBOTS2000 🤖

demo

A silly remake of the vintage game CROBOTS with 2D graphics and rigid body physics!

Made for fun with the OCaml bindings of the raylib library.

Play

dune exec crobots <robot-files>

Watch the sample robots in the test directory compete, or write and test your own robots!

Robot API

The physics engine introduces a few changes to the robot API. The robot programming style is a bit different than the original game, in that:

  • The new heading primitive can be used to check a robot's current heading

  • A change in a robot's heading is not instantaneous but requires a number of CPU cycles to reach a desired angle.

    In order to make the robot travel on a precise course (e.g. towards the top left corner of the field, 135°), you call the drive primitive with a desired speed of 0 to begin turning the robot in place:

    drive(course, 0);

    Cycle until the desired heading is met:

    while (heading() != course) ; // do nothing

    Then set off with your desired speed:

    drive(course, speed);

    The effect of this procedure is shown in the right animation: the robot first rotates then moves in a clean straight line, whereas in the left simulation the robot turns and accelerates at the same time, missing the top-left corner.

    free in-place

  • Acceleration takes a few more CPU cycles than the original game. Before testing a robot's speed against 0 (i.e. the robot stopping due to damage or collision), make sure it is actually accelerating (i.e. the robot approaching a non-null speed), otherwise you'd risk stopping the robot unintentionally.

About

OCaml remake of the retro game CROBOTS 🤖

Topics

Resources

License

Stars

Watchers

Forks

Languages