This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository elimine.

View the commit online.

commit be6e2c0ad1a3bf51b41f3246d9ebed42b06d5cb7
Author: Vincent Torri <vto...@outlook.fr>
AuthorDate: Sat Jun 28 11:58:38 2025 +0200

    initial commit
---
 AUTHORS             |   1 +
 README.md           |  24 ++
 meson.build         |  17 ++
 src/bin/elimine.c   | 736 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/bin/meson.build |   9 +
 5 files changed, 787 insertions(+)

diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..df35bad
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Vincent Torri <vincent dot torri at gmail dot com>
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a80f584
--- /dev/null
+++ b/README.md
@@ -0,0 +1,24 @@
+<!--
+SPDX-FileCopyrightText: Vincent Torri <vincent.to...@gmail.com>
+SPDX-License-Identifier: BSD-2-Clause
+-->
+
+### Elimine
+#### A simple minesweeper which mimics theold mine sweeper on Windows XP, written with the EFL (Enlightement Foundation Libraries)
+
+Development is done in [Enlightenment repository](https://git.enlightenment.org/vtorri/entice). Github mirror can be found [here](https://github.com/vtorri/entice).
+
+### License
+
+This application is released under the BSD 2-Clause License
+
+### Requirements
+
+The EFL.
+
+### Build instructions
+
+Entice uses [meson](https://mesonbuild.com/) as build system. Just use the classic instructions:
+
+1. `meson setup builddir`
+2. `ninja -C builddir`
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..7080fbc
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,17 @@
+# SPDX-FileCopyrightText: Vincent Torri <vincent.to...@gmail.com>
+# SPDX-License-Identifier: BSD-2-Clause
+
+project('elimine', 'c',
+  version         : '0.0.1',
+  license         : 'BSD 2 clause',
+  default_options : [
+                      'buildtype=debug',
+                      'warning_level=2'
+                    ],
+  meson_version   : '>= 0.60',
+)
+
+efl_req = '>= 1.27'
+elm_deps = dependency('elementary', version : efl_req)
+
+subdir('src/bin')
diff --git a/src/bin/elimine.c b/src/bin/elimine.c
new file mode 100644
index 0000000..0dae8cf
--- /dev/null
+++ b/src/bin/elimine.c
@@ -0,0 +1,736 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <Elementary.h>
+
+typedef enum
+{
+    NOTHING,
+    ONE,
+    TWO,
+    THREE,
+    FOUR,
+    FIVE,
+    SIX,
+    SEVEN,
+    HEIGHT,
+    UNKNOWN,
+    FLAG,
+    BOMB,
+    BOMB_WRONG,
+    BOMB_EXPLODED,
+    TYPE_GUARD
+} Tile_Type;
+
+/*
+ * Boards (width x height x mines):
+ * - 9x9x10
+ * - 16x16x40
+ * - 30x16x99
+ */
+
+typedef enum
+{
+    BEGINNER,
+    INTERMEDIATE,
+    HARD,
+    CUSTOM
+} Difficulty;
+
+typedef struct
+{
+    Evas_Object *win;
+    Evas_Object *tbl;
+
+    int *state;
+    int *known;
+    int nl; /* number of lines of the board */
+    int nc; /* number of columns of the board */
+    int nm; /* number of mines in the board */
+    int tile_sz; /* size in pixels of a tile */
+
+    Eina_Bool finished;
+} Ctx;
+
+static unsigned int colors[] =
+{
+    0xffc1c1c1, /* LIGHT_GREY */
+    0xff1900fc, /* BLUE 1 */
+    0xff00810d, /* GREEN 2 */
+    0xffff171c, /* RED 3 */
+    0xff07007e, /* DARK_BLUE 4 */
+    0xff820608, /* PURPLE 5*/
+    0xff008080, /* PALE_GRREN 6 */
+    0xff000000, /* BLACK  7 */
+    0xff808080, /* DARK_GREY  8 */
+    0xffffffff, /* WHITE */
+};
+
+static int tiles[TYPE_GUARD][16][16] =
+{
+    /* nothing0 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* 1 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* 2 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 },
+        { 8, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0 },
+        { 8, 0, 0, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0 },
+        { 8, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* 3 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 },
+        { 8, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0 },
+        { 8, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0 },
+        { 8, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* 4 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 4, 4, 4, 0, 4, 4, 4, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 4, 4, 4, 0, 4, 4, 4, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 4, 4, 4, 0, 0, 4, 4, 4, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 4, 4, 4, 0, 0, 4, 4, 4, 0, 0, 0, 0 },
+        { 8, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0 },
+        { 8, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* 5 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0 },
+        { 8, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0 },
+        { 8, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0 },
+        { 8, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0 },
+        { 8, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0 },
+        { 8, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* 6 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0 },
+        { 8, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0 },
+        { 8, 0, 0, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0 },
+        { 8, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0 },
+        { 8, 0, 0, 6, 6, 6, 0, 0, 0, 0, 6, 6, 6, 0, 0, 0 },
+        { 8, 0, 0, 6, 6, 6, 0, 0, 0, 0, 6, 6, 6, 0, 0, 0 },
+        { 8, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0 },
+        { 8, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* 7 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* 8 */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0 },
+        { 8, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0 },
+        { 8, 0, 0, 8, 8, 8, 0, 0, 0, 0, 8, 8, 8, 0, 0, 0 },
+        { 8, 0, 0, 8, 8, 8, 0, 0, 0, 0, 8, 8, 8, 0, 0, 0 },
+        { 8, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0 },
+        { 8, 0, 0, 8, 8, 8, 0, 0, 0, 0, 8, 8, 8, 0, 0, 0 },
+        { 8, 0, 0, 8, 8, 8, 0, 0, 0, 0, 8, 8, 8, 0, 0, 0 },
+        { 8, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0 },
+        { 8, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* unknown */
+    {
+        { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0 },
+        { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }
+    },
+    /* flag */
+    {
+        { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0 },
+        { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8 },
+        { 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }
+    },
+    /* bomb */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 7, 0, 7, 7, 7, 7, 7, 0, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 7, 7, 9, 9, 7, 7, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 7, 7, 9, 9, 7, 7, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0 },
+        { 8, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 7, 0, 7, 7, 7, 7, 7, 0, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* bomb wrong */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0 },
+        { 8, 0, 3, 3, 0, 0, 0, 0, 7, 0, 0, 0, 0, 3, 3, 0 },
+        { 8, 0, 0, 3, 3, 0, 7, 7, 7, 7, 7, 0, 3, 3, 0, 0 },
+        { 8, 0, 0, 0, 3, 3, 7, 7, 7, 7, 7, 3, 3, 0, 0, 0 },
+        { 8, 0, 0, 0, 7, 3, 3, 9, 7, 7, 3, 3, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 7, 7, 3, 3, 7, 3, 3, 7, 7, 0, 0, 0 },
+        { 8, 0, 7, 7, 7, 7, 7, 3, 3, 3, 7, 7, 7, 7, 7, 0 },
+        { 8, 0, 0, 0, 7, 7, 7, 3, 3, 3, 7, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 7, 7, 3, 3, 7, 3, 3, 7, 7, 0, 0, 0 },
+        { 8, 0, 0, 0, 0, 3, 3, 7, 7, 7, 3, 3, 0, 0, 0, 0 },
+        { 8, 0, 0, 0, 3, 3, 7, 7, 7, 7, 7, 3, 3, 0, 0, 0 },
+        { 8, 0, 0, 3, 3, 0, 0, 0, 7, 0, 0, 0, 3, 3, 0, 0 },
+        { 8, 0, 3, 3, 0, 0, 0, 0, 7, 0, 0, 0, 0, 3, 3, 0 },
+        { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+    },
+    /* bomb_exploded */
+    {
+        { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+        { 8, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
+        { 8, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3 },
+        { 8, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3 },
+        { 8, 3, 3, 3, 7, 3, 7, 7, 7, 7, 7, 3, 7, 3, 3, 3 },
+        { 8, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3 },
+        { 8, 3, 3, 3, 7, 7, 9, 9, 7, 7, 7, 7, 7, 3, 3, 3 },
+        { 8, 3, 3, 3, 7, 7, 9, 9, 7, 7, 7, 7, 7, 3, 3, 3 },
+        { 8, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3 },
+        { 8, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3 },
+        { 8, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3 },
+        { 8, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3 },
+        { 8, 3, 3, 3, 7, 3, 7, 7, 7, 7, 7, 3, 7, 3, 3, 3 },
+        { 8, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3 },
+        { 8, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3 },
+        { 8, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }
+    },
+
+};
+
+#define lookup(l, c) (l) * ctx->nc + (c)
+
+static inline int in_board(Ctx *ctx, int l, int c)
+{
+    return  (l >= 0) && (c >= 0) && (l < ctx->nl) && (c < ctx->nc);
+}
+
+void display_board(Ctx *ctx)
+{
+    int l;
+
+    for (l = 0; l < ctx->nl; l++)
+    {
+        int c;
+
+        for (c = 0; c < ctx->nc; c++)
+        {
+            printf("%c ",
+                   ctx->state[lookup(l,c)] == BOMB ? '*' : '0' + ctx->state[lookup(l,c)]);
+        }
+        printf("\n");
+    }
+}
+
+Evas_Object *icon_new(Evas_Object *win, Tile_Type type, int sz)
+{
+    int *data;
+    Evas_Object *o;
+    unsigned int *m;
+    int size;
+
+    size = 16 * sz;
+    data = "" *)tiles[type];
+
+    o = evas_object_image_add(evas_object_evas_get(win));
+    evas_object_image_size_set(o, size, size);
+    evas_object_image_fill_set(o, 0, 0, size, size);
+    m = evas_object_image_data_get(o, EINA_TRUE);
+
+    size_t it = 0;
+    for (int l = 0; l < 16; l++)
+    {
+        for (int c = 0; c < 16; c++)
+        {
+            unsigned int color = colors[data[l * 16 + c]];
+
+            for (int j = 0; j < sz; j++)
+            {
+                for (int i = 0; i < sz; i++, it++)
+                {
+                    m[(sz * l + j) * size + sz * c + i] = color;
+                    //m[it] = color;
+                }
+            }
+        }
+    }
+    evas_object_image_data_set(o, m);
+    evas_object_resize(o, size, size);
+    evas_object_size_hint_min_set(o, size, size);
+    evas_object_size_hint_max_set(o, size, size);
+
+    return o;
+}
+
+Ctx *ctx_new(Difficulty d, int tile_sz)
+{
+    Ctx *ctx;
+    int count;
+    int l;
+
+    ctx = (Ctx *)calloc(1, sizeof(Ctx));
+    if (!ctx)
+        return NULL;
+
+    ctx->tile_sz = tile_sz;
+
+    switch (d)
+    {
+        case BEGINNER:
+            ctx->nl = 9;
+            ctx->nc = 9;
+            ctx->nm = 10;
+            break;
+        case INTERMEDIATE:
+            ctx->nl = 16;
+            ctx->nc = 16;
+            ctx->nm = 40;
+            break;
+        case HARD:
+            ctx->nl = 30;
+            ctx->nc = 16;
+            ctx->nm = 99;
+            break;
+        default:
+            free(ctx);
+            return NULL;
+    }
+
+    ctx->state = (int *)calloc(ctx->nl * ctx->nc, sizeof(int));
+    if (!ctx->state)
+    {
+        free(ctx);
+        return NULL;
+    }
+
+    ctx->known = (int *)calloc(ctx->nl * ctx->nc, sizeof(int));
+    if (!ctx->known)
+    {
+        free(ctx->state);
+        free(ctx);
+        return NULL;
+    }
+
+    /* state */
+
+    srand(time(NULL));
+
+    count = 0;
+    while (count < ctx->nm)
+    {
+        int pos = rand() % (ctx->nc * ctx->nl);
+        if (ctx->state[pos] != BOMB)
+        {
+            ctx->state[pos] = BOMB;
+            count++;
+        }
+    }
+
+    for (l = 0; l < ctx->nl; l++)
+    {
+        int c;
+
+        for (c = 0; c < ctx->nc; c++)
+        {
+            if (ctx->state[lookup(l, c)] <9)
+            {
+                int j;
+
+                int n = 0;
+                for (j = -1; j <= 1; j++)
+                {
+                    int i;
+
+                    for (i = -1; i <= 1; i++)
+                    {
+                        if (in_board(ctx, l + j, c + i) && ! ((i == 0) && (j == 0)))
+                        {
+                            if (ctx->state[lookup(l + j, c + i)] == BOMB)
+                                n++;
+                        }
+                    }
+                }
+                ctx->state[lookup(l, c)] = n;
+            }
+        }
+    }
+
+    /* konwn */
+
+    for (l = 0; l < ctx->nl; l++)
+    {
+        int c;
+
+        for (c = 0; c < ctx->nc; c++)
+        {
+            ctx->known[lookup(l, c)] = UNKNOWN;
+        }
+    }
+
+    return ctx;
+}
+
+void ctx_del(Ctx *ctx)
+{
+    if (!ctx)
+        return;
+
+    free(ctx->state);
+    free(ctx->known);
+    free(ctx);
+}
+
+
+#define TILE(t, l, c) \
+do { \
+    o = icon_new(win, t, 5); \
+    elm_table_pack(tbl, o, c, l, 1, 1); \
+    evas_object_show(o); \
+} while (0)
+
+void ctx_draw(Ctx *ctx)
+{
+    int l;
+
+    for (l = 0; l < ctx->nl; l++)
+    {
+        int c;
+
+        for (c = 0; c < ctx->nc; c++)
+        {
+            Evas_Object *o;
+
+            o = icon_new(ctx->win, ctx->known[lookup(l, c)], ctx->tile_sz);    \
+            elm_table_pack(ctx->tbl, o, c, l, 1, 1); \
+            evas_object_show(o);
+        }
+    }
+}
+
+static int in_bounds(Ctx *ctx, int l, int c)
+{
+    return (l >= 0) && (c >= 0) && (l < ctx->nl) && (c < ctx->nc);
+}
+
+static void uncover(Ctx *ctx, int l, int c)
+{
+    int x;
+    int y;
+
+    if (ctx->state[lookup(l, c)] == BOMB)
+        return;
+
+    if ((ctx->state[lookup(l, c)] >= ONE) &&
+        (ctx->state[lookup(l, c)] <= HEIGHT))
+    {
+        ctx->known[lookup(l, c)] = ctx->state[lookup(l, c)];
+        return;
+    }
+
+    ctx->known[lookup(l, c)] = NOTHING;
+
+    for (y = -1; y <= 1; y++)
+    {
+        for (x = -1; x <= 1; x++)
+        {
+            if (!((x == 0) && (y == 0)) &&
+                in_bounds(ctx, l +  y, c + x) &&
+                (ctx->known[lookup(l + y, c + x)] == UNKNOWN))
+            {
+                uncover(ctx, l + y, c + x);
+            }
+        }
+    }
+}
+
+static void
+_cb_mouse_up(void *ctx_, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+    Ctx *ctx;
+    Evas_Event_Mouse_Up *ev;
+    int l;
+    int c;
+
+    ctx = (Ctx *)ctx_;
+    if (ctx->finished == EINA_TRUE)
+        return;
+
+    ev = (Evas_Event_Mouse_Up *)event_info;
+    c = ev->output.x / (16 * ctx->tile_sz);
+    l = ev->output.y / (16 * ctx->tile_sz);
+
+    if ((ev->button == 3) ||
+        ((ev->button == 1) &&
+         (evas_key_modifier_is_set(ev->modifiers, "Control"))))
+    {
+        if (ctx->known[lookup(l, c)] == UNKNOWN)
+        {
+            ctx->known[lookup(l, c)] = FLAG;
+            ctx_draw(ctx);
+        }
+        else if (ctx->known[lookup(l, c)] == FLAG)
+        {
+            ctx->known[lookup(l, c)] = UNKNOWN;
+            ctx_draw(ctx);
+        }
+
+        return;
+    }
+
+    if ((ev->button == 1) && (ctx->known[lookup(l, c)] == UNKNOWN))
+    {
+        if (ctx->state[lookup(l, c)] == BOMB)
+        {
+            int y;
+
+            for (y = 0; y < ctx->nl; y++)
+            {
+                int x;
+
+                for (x = 0; x < ctx->nc; x++)
+                {
+                    /* wrongly flagged tile */
+                    if ((ctx->known[lookup(y, x)] == FLAG) &&
+                        (ctx->state[lookup(y, x)] != BOMB))
+                    {
+                        ctx->known[lookup(y, x)] = BOMB_WRONG;
+                    }
+
+                    if (ctx->state[lookup(y, x)] == BOMB)
+                    {
+                        if ((x == c) && (y == l))
+                        {
+                            ctx->known[lookup(y, x)] = BOMB_EXPLODED;
+                        }
+                        else
+                        {
+                            ctx->known[lookup(y, x)] = BOMB;
+                        }
+                    }
+                }
+            }
+
+            ctx->finished = EINA_TRUE;
+        }
+        else if (ctx->state[lookup(l, c)] == NOTHING)
+        {
+            uncover(ctx, l, c);
+        }
+        else
+        {
+            ctx->known[lookup(l, c)] = ctx->state[lookup(l, c)];
+        }
+        ctx_draw(ctx);
+    }
+}
+
+EAPI_MAIN int
+elm_main(int argc, char **argv)
+{
+    Ctx *ctx;
+
+    ctx = ctx_new(BEGINNER, 3);
+
+    display_board(ctx);
+
+    Evas_Object *win;
+    Evas_Object *tbl;
+    Evas_Object *o;
+    int win_w;
+    int win_h;
+
+    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+    elm_app_name_set("elimine");
+
+    win = elm_win_add(NULL, "Elimine", ELM_WIN_BASIC);
+    elm_win_title_set(win, "Elimine");
+    elm_win_autodel_set(win, EINA_TRUE);
+
+    /* background */
+    o = elm_bg_add(win);
+    evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    elm_object_style_set(o, "grad_vert_focus_title_match");
+    elm_win_resize_object_add(win, o);
+    evas_object_show(o);
+
+    /* table */
+    tbl = elm_table_add(win);
+    evas_object_size_hint_weight_set(tbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_fill_set(tbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    elm_win_resize_object_add(win, tbl);
+    evas_object_show(tbl);
+
+    o = evas_object_rectangle_add(win);
+    evas_object_color_set(o, 0, 0, 0, 0);
+    evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    elm_win_resize_object_add(win, o);
+    evas_object_repeat_events_set(o, EINA_TRUE);
+    evas_object_show(o);
+    evas_object_event_callback_add(tbl, EVAS_CALLBACK_MOUSE_UP,
+                                   _cb_mouse_up, ctx);
+
+    ctx->win = win;
+    ctx->tbl = tbl;
+    ctx->finished = EINA_FALSE;
+
+    ctx_draw(ctx);
+
+    win_w = ctx->nc * ctx->tile_sz;
+    win_h = ctx->nl * ctx->tile_sz;
+    evas_object_resize(win,
+                       win_w * elm_config_scale_get(),
+                       win_h * elm_config_scale_get());
+
+    evas_object_show(win);
+
+    elm_run();
+
+    return 0;
+
+    ctx_del(ctx);
+
+    (void)argc;
+    (void)argv;
+}
+ELM_MAIN()
diff --git a/src/bin/meson.build b/src/bin/meson.build
new file mode 100644
index 0000000..d34787c
--- /dev/null
+++ b/src/bin/meson.build
@@ -0,0 +1,9 @@
+# SPDX-FileCopyrightText: Vincent Torri <vincent.to...@gmail.com>
+# SPDX-License-Identifier: BSD-2-Clause
+
+
+elimine = executable('elimine',
+  files('elimine.c'),
+  dependencies        : [ elm_deps ],
+  install             : true
+)
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to