# Looking for a little game prototype / code snippets in SWI-Prolog

**URL:** <https://swi-prolog.discourse.group/t/looking-for-a-little-game-prototype-code-snippets-in-swi-prolog/5366>\
**Category:** Help!\
**Tags:** how-to, software, gamdev\
**Created:** [May 1, 2022, 4:41pm UTC](https://swi-prolog.discourse.group/t/looking-for-a-little-game-prototype-code-snippets-in-swi-prolog/5366 "2022-05-01T16:41:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chansey97](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chansey97](https://swi-prolog.discourse.group/u/chansey97)\
**Post date:** [May 1, 2022, 4:41pm UTC](https://swi-prolog.discourse.group/t/looking-for-a-little-game-prototype-code-snippets-in-swi-prolog/5366/1 "2022-05-01T16:41:31Z")

</div>

Hi,

I am looking for a little game prototypes / code snippets in SWI-Prolog.

The requirement is just:

1. A game loop, which calls a `update` every 0.016ms.

2. A `get_keyboard_state` like interface, which can get keyboard state (i.e. check a key state up/down).,

3. A graphics interface, which allow me to draw some squares in the canvas.

Since I have no prior experience for developing graphical interactive applications in Prolog, can anyone give me some guidance ? (code snippets / prototypes would be nice)

Very Thanks.

P.S. Performance is not necessary.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [May 2, 2022, 10:56am UTC](https://swi-prolog.discourse.group/t/looking-for-a-little-game-prototype-code-snippets-in-swi-prolog/5366/2 "2022-05-02T10:56:19Z")

</div>

Anne does

> [**Ludum Dare**](https://ldjam.com/about) is an online event where games are made from scratch in a weekend. Check us out every April and October!

The code for some of them can be found at

> **[SWI-Prolog Ludum Dare Teams](https://github.com/SWI-PrologTeamLudumDare32)**
>
> SWI-Prolog's teams for Ludum Dares. SWI-Prolog Ludum Dare Teams has 5 repositories available. Follow their code on GitHub.

---

<div class="post-metadata">

**Author:** ![chansey97](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chansey97](https://swi-prolog.discourse.group/u/chansey97)\
**Post date:** [May 2, 2022, 3:40pm UTC](https://swi-prolog.discourse.group/t/looking-for-a-little-game-prototype-code-snippets-in-swi-prolog/5366/3 "2022-05-02T15:40:39Z")

</div>

Thanks. I have not dig into these remarkable projects. It seems that they use web technology which is a bit difficult for me.

* * *

I am using [plOpenGL](https://www.swi-prolog.org/pack/list?p=plOpenGL).

 ![opengl](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/2/2d3498a4bbd7608bb5570bcb6600fdca56767699.jpeg)

Although it’s a bit weak compared to other mature game engines or multimedia libraries, I believe it’s a good starting point. It would be nice if SWI-Prolog can provide [SDL](https://www.libsdl.org/) bindings.

Other possible directions:

1. [gnuprolog-libsdl2](https://github.com/emacstheviking/gnuprolog-libsdl2)

2. [xpce](https://www.swi-prolog.org/packages/xpce/)

but I haven’t explored them yet.

P.s. Still waiting for better solutions.
