commit 409bed9573a6a8af35227ec05eb76abfed9dbb2a
parent d044484fbd4353efb08ffe14f55e7679d80c562f
Author: Claudio Alessi <smoppy@gmail.com>
Date: Thu, 21 Jun 2018 22:55:30 +0200
Implements z-index
Diffstat:
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -1,22 +1,22 @@
/* See LICENSE file for copyright and license details. */
Object objects[] = {
- /* symbol flags ontick argument */
- { VACUUM, OF_OPEN, falling, {0} },
-[1] = {'o', OF_PLAYER|OF_OPEN|OF_FALL, NULL, {.i = 2} },
-[2] = {'a', OF_PLAYER|OF_OPEN|OF_FALL, NULL, {.i = 2} },
- {'_', OF_OPEN|OF_STICK|OF_JUMPFROM, NULL, {0} },
- {'|', 0, NULL, {0} },
- {'*', OF_OPEN, earnenergy, {.i = 2} },
- {')', OF_OPENLEFT|OF_STICK, finish, {0} },
- {'(', OF_OPENRIGHT|OF_STICK, finish, {0} },
- {'t', 0, cannon, {.v = &objects[11]} },
- {'j', 0, cannon, {.v = &objects[12]} },
-[11] = {'.', OF_OPEN|OF_AI, cannonball, {.i = +1} },
-[12] = {',', OF_OPEN|OF_AI, cannonball, {.i = -1} },
- {'#', OF_FALL|OF_PUSHABLE, NULL, {0} },
- {'@', OF_FALL|OF_PUSHABLE, NULL, {0} },
- {'x', OF_PLAYER|OF_AI|OF_OPEN|OF_FALL, zombie, {.i = 8} },
+ /* symbol z-index flags ontick argument */
+ { VACUUM, 0, OF_OPEN, falling, {0} },
+[1] = {'o', 8, OF_PLAYER|OF_OPEN|OF_FALL, NULL, {.i = 2} },
+[2] = {'a', 8, OF_PLAYER|OF_OPEN|OF_FALL, NULL, {.i = 2} },
+ {'_', 1, OF_OPEN|OF_STICK|OF_JUMPFROM, NULL, {0} },
+ {'|', 1, 0, NULL, {0} },
+ {'*', 2, OF_OPEN, earnenergy, {.i = 2} },
+ {')', 9, OF_OPENLEFT|OF_STICK, finish, {0} },
+ {'(', 9, OF_OPENRIGHT|OF_STICK, finish, {0} },
+ {'t', 1, 0, cannon, {.v = &objects[11]} },
+ {'j', 1, 0, cannon, {.v = &objects[12]} },
+[11] = {'.', 2, OF_OPEN|OF_AI, cannonball, {.i = +1} },
+[12] = {',', 2, OF_OPEN|OF_AI, cannonball, {.i = -1} },
+ {'#', 2, OF_FALL|OF_PUSHABLE, NULL, {0} },
+ {'@', 2, OF_FALL|OF_PUSHABLE, NULL, {0} },
+ {'x', 8, OF_PLAYER|OF_AI|OF_OPEN|OF_FALL, zombie, {.i = 8} },
};
#include "levels.h"
diff --git a/globox.c b/globox.c
@@ -83,6 +83,7 @@ typedef struct {
typedef struct Object Object;
struct Object {
char sym;
+ int zidx;
unsigned int flags;
int (*ontick)(Object *);
const Arg arg;
@@ -311,8 +312,8 @@ draw(void) {
continue;
t = b;
for(b2 = scene->blocks; b2; b2 = b2->next)
- if((ISSET(b2->o->flags, OF_PLAYER | OF_AI) || !ISSET(b2->o->flags, OF_OPEN))
- && b->x == b2->x && b->y == b2->y)
+ if(b2 != b && b2->x == b->x && b2->y == b->y
+ && b2->o->zidx > t->o->zidx)
t = b2;
for(b2 = scene->blocks; b2; b2 = b2->next)
if(b2 != t && t->x == b2->x && t->y == b2->y)