Dungeon crawler game

Hey all! I recently made a simple text-based dungeon crawler using a mix functional and object-oriented programming in OCaml. Feel free to check it out if it interests you :slight_smile: I have a video of the game being played and explained here. You can find the source on GitHub here.

9 Likes

Cool. I see you’ve made heavy use of the object system. If you’re interested in games built using the more idiomatic functional/ocaml approach (i.e. modules), you should check out a-nikolaev/wanderers.

I also wrote bramford/2d-exploration-game - a simple terminal/ncurses game while I was learning ocaml. I tried a couple of different approaches using the module system. I never felt that I got it quite right so while it is quite simple, it may not be the best example.

2 Likes

Nice, I hope you will make more adventures :slight_smile:

On my side I started a shmup game with abstract graphics because I’m fond of Kenta Cho games, not yet in a git repository, I put it in a gist: shmup_av6.ml

Quite functional too, only shot and missed variables are imperative.

My best score is:
shot: 460
missed: 25
score: 435

1 Like

The name made my day :smiley:

Speaking of the code a small piece of advice, instead of writting

        | (k,`String v) when k="name" -> e#set_name v
        | (k,`Int i) when k="health" -> e#set_health i
        | (k,`Int i) when k="damage" -> e#set_dmg i

you can do

        | ("name",`String v) -> e#set_name v
        | ("health",`Int i)  -> e#set_health i
        | ("damage",`Int i)  -> e#set_dmg i
2 Likes

Brilliant! I’ll keep that in mind for next time, thanks

1 Like

That’s so cool! I’d love to see it when you put it on Github

That sounds great, I’ll check it out :slight_smile:

I updated it to remove the dependencies on ageom and timeline by including the pieces of code used: shmup_av10.ml

As there is only one source code file, you can run it directly with ocaml:

opam install ocamlsdl2

If you’re using SDL2 version 2.0.9, or if you installed an older version:

opam install ocamlsdl2.0.02

Then you can run the game with:

eval $(opam env)
ocaml -I $(ocamlfind query sdl2) sdl2.cma shmup_av10.ml

I created a basic webpage for this game, there are screenshots and an executable binary for Windows.

1 Like