# Remaking an Old Game in OCaml

**URL:** <https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760>\
**Category:** Community\
**Tags:** tsdl, games\
**Created:** [May 2, 2022, 7:15am UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760 "2022-05-02T07:15:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluddy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bluddy/32/104_2.png) [@bluddy](https://discuss.ocaml.org/u/bluddy)\
**Post date:** [May 2, 2022, 7:15am UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/1 "2022-05-02T07:15:18Z")

</div>

I’ve starting blogging about a [side-project of mine](https://justabluddyblog.wordpress.com/2022/05/01/remaking-an-old-game-in-ocaml/). Hopefully I’ll find the time to write some further entries in the series, including about reverse engineering a binary with IDA.

---

<div class="post-metadata">

**Author:** ![fccm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/fccm/32/1587_2.png) [@fccm](https://discuss.ocaml.org/u/fccm)\
**Post date:** [June 1, 2022, 12:26am UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/2 "2022-06-01T00:26:27Z")

</div>

(maybe you forgot the link to the code: [gh/rails](https://github.com/bluddy/rails))

I’ve tried to install the deps[1], and I get this error with `integers.0.5.1`:

```auto
/usr/lib/gcc/i586-mageia-linux-gnu/8.4.0/include/stdint.h:9:16: \
  fatal error: stdint.h: No such file or directory
# include_next <stdint.h>

```

```auto
$ ll /usr/lib/gcc/i586-mageia-linux-gnu/8.4.0/include/stdint.h
-rw-r--r-- 1 root root 328 Mar 4 2020 /usr/lib/gcc/i586-mageia-linux-gnu/8.4.0/include/stdint.h
$ ll /usr/include/stdint.h
-rw-r--r-- 1 root root 8.3K Jun 22 2021 /usr/include/stdint.h

```

[1]: ppx\_derivers, optint, seq, csexp, ocamlbuild, stdlib-shims, sexplib0, integers, owl-base, cmdliner, cppo, conf-libffi, result, either, ocaml-compiler-libs, bigarray-compat, topkg, ctypes-foreign, dune-configurator, ppxlib, astring, ctypes, iter, gen, containers, checkseum, base, ppx\_deriving, ocb-stubblr, tsdl, containers-data, decompress, ppx\_sexp\_conv, ppx\_compare, lens, imagelib, ppx\_hash

---

<div class="post-metadata">

**Author:** ![bluddy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bluddy/32/104_2.png) [@bluddy](https://discuss.ocaml.org/u/bluddy)\
**Post date:** [June 1, 2022, 8:57am UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/3 "2022-06-01T08:57:39Z")

</div>

I haven’t really made the code easy to install. Hopefully tonight I’ll have time to do so and I’ll see if there are really any potential dependency conflicts.

---

<div class="post-metadata">

**Author:** ![fccm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/fccm/32/1587_2.png) [@fccm](https://discuss.ocaml.org/u/fccm)\
**Post date:** [June 1, 2022, 12:35pm UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/4 "2022-06-01T12:35:11Z")

</div>

The deps are not really hard to install while we only require one command with opam for that, it’s only that there is a compilation error.

---

<div class="post-metadata">

**Author:** ![bluddy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bluddy/32/104_2.png) [@bluddy](https://discuss.ocaml.org/u/bluddy)\
**Post date:** [June 1, 2022, 12:47pm UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/5 "2022-06-01T12:47:32Z")

</div>

Well I can tell you my main dependency versions (I’ll be adding them to an opam file soon):

```auto
tsdl 0.9.8
owl-base 1.0.2
ocaml 4.13.1
iter 1.4
imagelib 20210511
gen 1.0
containers 3.7
containers-data 3.7
ppx_deriving 5.2.1
ppx_hash 0.15.0
lens 1.2.5

```

All other packages are requirements of these main ones.

---

<div class="post-metadata">

**Author:** ![bluddy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bluddy/32/104_2.png) [@bluddy](https://discuss.ocaml.org/u/bluddy)\
**Post date:** [June 1, 2022, 9:01pm UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/6 "2022-06-01T21:01:01Z")

</div>

I added an opam lock file. You should be able to install all the dependencies using just the `opam switch create . --locked` command.

---

<div class="post-metadata">

**Author:** ![fccm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/fccm/32/1587_2.png) [@fccm](https://discuss.ocaml.org/u/fccm)\
**Post date:** [July 26, 2022, 3:56pm UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/7 "2022-07-26T15:56:35Z")

</div>

Ok, I have finally succeed to compile it: I switched to an ocaml 4.14 switch in opam, and then there was no compilation errors anymore with all the dependencies.

So now I have a binary that I can run, but when I run it I get the error:

```auto
Sys error: "./data/EASTUS.PIC", no such file or directory.

```

I was trying to figure out if your game was worth to be added in the [ocaml-awesome-gamedev repo](https://github.com/fccm/awesome-gamedev-ocaml)?

(also if someone could tell me what would be the right name for this repo: “ocaml-awesome-gamedev”, “awesome-gamedev-ocaml” or awesome-ocaml-gamedev"?)

I was also trying to figure out if the game would be worth to be adapted to be compiled with rescript to get an html5/canvas game that everyone could play with in a browser.

I recently [made some experimentations](http://decapode314.free.fr/games/) with it, and the beginnings are promising.

I also wrote a tutorial, [1) with a snake example](http://decapode314.free.fr/re/tut/ocaml-re-tut.html), and [2) with a platformer example](http://decapode314.free.fr/re/tut2/ocaml-re-tut.html) where you see how to make [something like this](http://decapode314.free.fr/re/tut2/platform7/platform.html).

I thought the platformer will be slow because MariOCaml is very slow on my old and small computer, but it’s not slow at all, even with a bigger canvas.

---

<div class="post-metadata">

**Author:** ![bluddy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bluddy/32/104_2.png) [@bluddy](https://discuss.ocaml.org/u/bluddy)\
**Post date:** [July 26, 2022, 4:13pm UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/8 "2022-07-26T16:13:48Z")

</div>

The engine expects the files from the original Railroad Tycoon to be placed under ‘./data’. The game unfortunately isn’t sold on any digital storefront nowadays.

---

<div class="post-metadata">

**Author:** ![fccm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/fccm/32/1587_2.png) [@fccm](https://discuss.ocaml.org/u/fccm)\
**Post date:** [July 27, 2022, 2:04am UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/9 "2022-07-27T02:04:39Z")

</div>

The data directory indeed contains 3 files, but not this one.  
Maybe you forgot to include it?

Check [github/rails/data/](https://github.com/bluddy/rails/tree/master/data), it only contains:

```auto
FONTS.RR
SPRITES_extra.png
TRACKS_extra.png

```

I tryed to find `EASTUS.PIC` with google, but it doesn’t seem to be available anywhere.

From the screenshots and the yt video it doesn’t look like something very difficult to re-create.  
Look at undune2 or mindustry on [itch.io](http://itch.io), players can even be happy with big pixels, or you can just display squares at early dev steps that can be replaced by graphics after.

Do you know the website [OpenGameArt.org](https://opengameart.org/)?

---

<div class="post-metadata">

**Author:** ![bluddy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bluddy/32/104_2.png) [@bluddy](https://discuss.ocaml.org/u/bluddy)\
**Post date:** [July 27, 2022, 6:55am UTC](https://discuss.ocaml.org/t/remaking-an-old-game-in-ocaml/9760/10 "2022-07-27T06:55:59Z")

</div>

The first version is an exact replica of Railroad Tycoon (with some modern UI conveniences) and therefore needs the game files, similar to the way [OpenXcom](https://openxcom.org/), [OpenApoc](https://openapoc.github.io/) and [Julius](https://github.com/bvschaik/julius) work.

After 1.0, I’ll change/improve the graphics and then I can distribute them as well.
