about

About

This is the website for my Allefant project which for many years was hosted on SourceForge. It is a collection of various games I wrote over the years for short game programming competitions, such competitions usually taking about 2 days to create the complete game (code as well as art). The first such game I made was Allefant back in the year 2000. Some of the games also were worked on afterwards and polished a bit, so they are actually playable. Most are little more than a tech demo though. They are all open source.

pyweek-14

Pyweek #14

Yay, finally finished a compo entry again! I made a little puzzle game called Yellow and Dangerous for PyWeek 14.

This one was a lot of fun. I used Python 3, which just is so nice to use. Very high level, very clean syntax and my code just works as intended :) Which allowed me to do quite a lot in the limited time. Basically a complete isometric engine which uses masking to solve the old (impossible) 3d sorting problem.

It probably would have been easier to do full 3d and use a regular z buffer. But I’ve basically been waiting for 20 years or so to do a 2d isometric engine like this – ever since I played Cadaver on the Amiga. And now I finally managed to do a 100% clone of the engine they used back then. My life is complete now. And I managed to do it in (the free time of) a week no less (well, the implementation, there’s years of research in it…) :)

The game itself is rather simple. During the competition someone made a mockup of a Portal like game (he never actually made the game though, unfortunately). But it prompted me to create a Companion Cube like cube as placeholder for my initial testing. And I liked it so much I kept it as the main game mechanic. The goal in each level is to place cubes on pressure plates to unlock the exit. However to do so, you need to push, pull and stack other objects. Either to move them, or to create structures which help you move. For example to create a bridge over a gap or to create some kind of stairway to climb up to a high place. I also tried using the 3D aspect in some of the levels, for example one level has a block hidden behind a bush. And another arranges platforms in a way so the isometric view makes it hard to see where they actually are. Similar to those M. C. Escher drawings.

Posted in News | Leave a comment

FOSDEM 2012 in Brussels

Really need to add a blog entry about this – I was there a few weeks ago. Was coding some Wesnoth related stuff: units.wesnoth.org Also not directly related, I made a Pacman clone while bored:

It uses no external datafiles, just plain Allegro 5 primitives:

#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_color.h>
#include <math.h>
 
ALLEGRO_DISPLAY *d;
ALLEGRO_EVENT_QUEUE *q;
ALLEGRO_EVENT e;
ALLEGRO_TIMER *t;
ALLEGRO_COLOR c;
bool k[ALLEGRO_KEY_MAX];
int w = 30;
int h = 38;
int s = 16;
int a, b, g;
double p = ALLEGRO_PI, f;
bool r;
int x, y, px, py, kx, ky, sx, sy;
int gx[4], gy[4], dx[4], dy[4];
char n[] =
"                              "
"                              "
"                              "
"                              "
" ############################ "
" #............##............# "
" #.####.#####.##.#####.####.# "
" #.#  #.#   #.##.#   #.#  #.# "
" #.####.#####.##.#####.####.# "
" #..........................# "
" #.####.##.########.##.####.# "
" #.####.##.########.##.####.# "
" #......##....##....##......# "
" ######.##### ## #####.###### "
"      #.##### ## #####.#      "
"      #.##    []    ##.#      "
"      #.## ###  ### ##.#      "
" ######.## #~~~~~~# ##.###### "
"       .   #[][][]#   .       "
" ######.## #~~~~~~# ##.###### "
"      #.## ######## ##.#      "
"      #.##          ##.#      "
"      #.## ######## ##.#      "
" ######.## ######## ##.###### "
" #............##............# "
" #.####.#####.##.#####.####.# "
" #.####.#####.##.#####.####.# "
" #...##.......().......##...# "
" ###.##.##.########.##.##.### "
" ###.##.##.########.##.##.### "
" #......##....##....##......# "
" #.##########.##.##########.# "
" #.##########.##.##########.# "
" #..........................# "
" ############################ "
"                              "
"                              "
"                              ";
char *m;
#define P(x) (((x) - 1) * s)
#define Q(x) (1 + (x) / s)
#define M(x, y) m[(y) * w + (x)]
 
int main() {
    srand(time(NULL));
    al_init();
    al_install_keyboard();
    al_init_primitives_addon();
    al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
    al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);
    d = al_create_display((w - 2) * s, (h - 2) * s);
    al_set_window_title(d, "Bambam and the Globals");
    q = al_create_event_queue();
    t = al_create_timer(1.0 / 60);
    al_register_event_source(q, al_get_keyboard_event_source());
    al_register_event_source(q, al_get_timer_event_source(t));
    al_register_event_source(q, al_get_display_event_source(d));
    al_start_timer(t);
    m = malloc(strlen(n) + 1);
    restart:
    strcpy(m, n);
    b = 0;
    y = 1;
    starty:
    x = 1;
    startx:
    if (M(x, y) != '(') goto noparenthesis;
    px = P(x) + s;
    py = P(y) + s / 2;
    noparenthesis:
    if (M(x, y) != '[') goto nobracket;
    gx[b] = P(x) + s;
    gy[b] = P(y) + s / 2;
    if (b == 0) goto notfirst;
    sx = gx[0];
    sy = gy[0];
    notfirst:
    b++;
    nobracket:
    x++;
    if (x &lt; w - 1) goto startx;
    y++;
    if (y &lt; h - 1) goto starty;
    mainloop:
    if (!r || !al_is_event_queue_empty(q)) goto dontdraw;
    al_clear_to_color(al_color_name("black"));
    b = 7;
    loopdrawhighlight:
    c = al_color_name("blue");
    if (b == 1) c = al_color_name("wheat");
    y = 1;
    loopdrawy:
    x = 1;
    loopdrawx:
    if (M(x, y) != '.') goto nodot;
    al_draw_filled_rectangle(
        P(x) + s * 0.4,
        P(y) + s * 0.4,
        P(x) + s * 0.6,
        P(y) + s * 0.6,
        al_color_name("peachpuff"));
    nodot:
    if (M(x, y) != '#') goto nohash;
    a =   1 * (M(x + 0, y - 1) == '#') +
          2 * (M(x + 1, y - 1) == '#') +
          4 * (M(x + 1, y + 0) == '#') +
          8 * (M(x + 1, y + 1) == '#') +
         16 * (M(x + 0, y + 1) == '#') +
         32 * (M(x - 1, y + 1) == '#') +
         64 * (M(x - 1, y + 0) == '#') +
        128 * (M(x - 1, y - 1) == '#');
 
    if (a == 64)
        al_draw_line(P(x), P(y) + s / 2, P(x) + s,
            P(y) + s / 2, c, b);
    else if (a == 4)
        al_draw_line(P(x), P(y) + s / 2, P(x) + s,
            P(y) + s / 2, c, b);    
 
    else if ((a &amp; 85) == 5)
        al_draw_arc(P(x) + s, P(y),
            s / 2, p / 2, p / 2, c, b);
    else if ((a &amp; 85) == 20)
        al_draw_arc(P(x) + s, P(y) + s,
            s / 2, p, p / 2, c, b);
    else if ((a &amp; 85) == 65)
        al_draw_arc(P(x), P(y),
            s / 2, 0, p / 2, c, b);
    else if ((a &amp; 85) == 80)
        al_draw_arc(P(x), P(y) + s,
            s / 2, p * 1.5, p / 2, c, b);
 
    else if ((a &amp; 7) == 5)
        al_draw_arc(P(x) + s, P(y),
            s / 2, p / 2, p / 2, c, b);
    else if ((a &amp; 28) == 20)
        al_draw_arc(P(x) + s, P(y) + s,
            s / 2, p, p / 2, c, b);
    else if ((a &amp; 193) == 65)
        al_draw_arc(P(x), P(y),
            s / 2, 0, p / 2, c, b);
    else if ((a &amp; 112) == 80)
        al_draw_arc(P(x), P(y) + s,
            s / 2, p * 1.5, p / 2, c, b);
 
    else if ((a &amp; 17) == 17)
        al_draw_line(P(x) + s / 2, P(y), P(x) + s / 2,
            P(y) + s, c, b);
 
    else if ((a &amp; 68) == 68)
        al_draw_line(P(x), P(y) + s / 2, P(x) + s,
            P(y) + s / 2, c, b);
    nohash:
    x++;
    if (x &lt; w - 1) goto loopdrawx;
    y++;
    if (y &lt; h - 1) goto loopdrawy;
    b -= 6;
    if (b &gt; 0) goto loopdrawhighlight;
 
    b = 0;
    looptwice:
    al_draw_filled_pieslice(px + b * (w - 2) * s, py, s,
        f + p * 0.25 * fabs(sin(2 * p * (g % 60) / 60.0)),
        p * 2 - p * 0.5 * fabs(sin(2 * p * (g % 60) / 60.0)),
        al_color_name("yellow"));
    b++;
    if (b &lt; 2) goto looptwice;
    b = 0;
    loopdrawghosts:
 
    if (b == 0) c = al_color_name("red");
    if (b == 1) c = al_color_name("cyan");
    if (b == 2) c = al_color_name("pink");
    if (b == 3) c = al_color_name("orange");
    x = gx[b];
    y = gy[b];
    al_draw_filled_pieslice(x, y, s, p * 0.6, p * 1.8, c);
    al_draw_filled_triangle(x, y, x - s, y, x - s, y + s, c);
    al_draw_filled_triangle(x, y, x + s, y, x + s, y + s, c);
    al_draw_filled_rectangle(x - s * 0.5, y,
        x + s * 0.5, y + s * 0.5, c);
    al_draw_filled_circle(x - s * 0.5, y, s * 0.25,
        al_color_name("white"));
    al_draw_filled_circle(x + s * 0.5, y, s * 0.25,
        al_color_name("white"));
 
    b++;
    if (b &lt; 4) goto loopdrawghosts;
 
    al_flip_display();
    g++;
    r = false;
 
    dontdraw:
    al_wait_for_event(q, &amp;e);
    if (e.type == ALLEGRO_EVENT_DISPLAY_CLOSE) goto done;
    if (e.type != ALLEGRO_EVENT_TIMER) goto nottimer;
    if (k[ALLEGRO_KEY_ESCAPE]) goto done;
    if (k[ALLEGRO_KEY_LEFT]) {kx = -1; ky = 0; f = p;}
    if (k[ALLEGRO_KEY_RIGHT]) {kx = 1; ky = 0; f = 0;}
    if (k[ALLEGRO_KEY_UP]) {kx = 0; ky = -1; f = p * 1.5;}
    if (k[ALLEGRO_KEY_DOWN]) {kx = 0; ky = 1; f = p * 0.5;}
 
    if (M(Q(px + kx * s / 2), Q(py + ky * s / 2)) == '#') goto cango;
    px += kx;
    py += ky;
    if (px &lt; -s) px += (w - 2) * s;
    if (px &gt; (w - 3) * s) px -= (w - 2) * s;
    if (M(Q(px + kx * s), Q(py + ky * s)) == '.')
        M(Q(px + kx * s), Q(py + ky * s)) = ' ';
    cango:
 
    b = 0;
    loopghosts:
    x = gx[b] - px;
    y = gy[b] - py;
    if (x * x + y * y &lt; s * s * 2 * 2) goto restart;
    if (dx[b] == 0 &amp;&amp; dy[b] == 0) dx[b] = (rand() % 2) * 2 - 1;
 
    if (M(Q(gx[b]), Q(gy[b])) != '~') goto noteleport;
    gx[b] = sx;
    gy[b] = sy;
    dy[b] = 0;
    noteleport:
 
    if (M(Q(gx[b] + dx[b] * s / 2), Q(gy[b] + dy[b] * s / 2)) == '#')
        goto ghostwall;
    gx[b] += dx[b];
    gy[b] += dy[b];
    goto ghostmoved;
    ghostwall:
    if (dx[b] == 0) goto nodx;
    dx[b] = 0;
    dy[b] = (rand() % 2) * 2 - 1;
    goto ghostmoved;
    nodx:
    dy[b] = 0;
    dx[b] = (rand() % 2) * 2 - 1;
    ghostmoved:
    b++;
    if (b &lt; 4) goto loopghosts;
 
    r = true;
    goto mainloop;
    nottimer:
    if (e.type == ALLEGRO_EVENT_KEY_DOWN) k[e.keyboard.keycode] = true;
    if (e.type == ALLEGRO_EVENT_KEY_UP) k[e.keyboard.keycode] = false;
 
    goto mainloop;
    done:
    free(m);
    al_uninstall_system();
}
Posted in News | Leave a comment

Global Game Jam 2012

On Friday I travelled to Vienna to attend my sister’s “Sponsionsfeier” (ceremony where she was awarded her Master’s degree in biomedicine). I had heard of the GGJ earlier from Oncer in #Moosader so looked up the address and went there. And decided to register and take part.

I teamed up with someone who wanted to make a 3D snake clone. The result turned out quite interesting I think:

Posted in News | Leave a comment
santahack-2011

SantaHack 2011

I took part in SantaHack 2011 and made a game called xmas. Download (.exe plus sources) is here.

Posted in News | Leave a comment

The Coke diet

How Coke helped me lose weight!

I love Coca Cola. I was drinking 2 liters of it per day. Every day for about 10 years. And despite what people claim I never had any health problems. About half a year ago I bought a scale and then, just as some kind of experiment initially, tried watching what would happen if I’d reduce my Coke intake to 1 liter per day. And in the following weeks actually reduced it further to no Coke anymore. This is the somewhat interesting result:

I started losing weight really fast by just leaving out one liter of coke at first. And then constantly kept losing weight. After about three months I was losing much less weight even though I was eating/drinking the exact same things, not sure why. Still, by simply replacing those 2 liters of coke with 2 liters of carbonated water I keep losing weight. The three days at the end without data points is when I wasn’t home (and also got sick which explains the somewhat abrupt weight loss there). But that means I’m now down 10 kg, from about 80 kg to about 70 kg, which means my experiment is now done I guess.

Maybe next I’ll see how fast I can get the weight back if I start drinking Coke again :)

Posted in News | Leave a comment
speedhack-2011

Speedhack 2011

Took part in Speedhack 2011. The game I made is called Red, White & You. The speedhack rules this timere were ESRB-E rating, random, color, propaganda and lazyness. Not much to get a specific game idea so I just started coding, using pymunk. In hindsight pymunk was a bad choice as I had a hard time getting it to work on Windows. It uses some Python 2.x constructs (I’m using Python 3) and its setup.py script couldn’t compile a new chipmunk.dll which does not depend on msvcr71.dll. Also I know the chipmunk C API so the extra cruft pymunk adds wasn’t so useful, especially as it’s very incomplete. Next time I’ll just use ctypes and chipmunk (mingw compiled dll for windows) directly. Will solve all problems :)

Coding the game itself was a lot of fun though, so I’m happy :)

Posted in News | Leave a comment
ld48-2011-20

LD48 2011 (#20)

Took part in this LD. However, I had no time to prepare and also have too much stress with work and getting Fargoal 2 done to be really into it. Coding for 2 days straight as I did in some of the previous LDs seriously impacts me for the next days, the brain gets exhausted from it :) Which I can’t afford now – almost had a bad conscience for “taking off” this weekend.

Also, this must be the worst theme any LD ever had. Just a phrase from the beginning of Zelda1 which would fit for virtually any game. So one of the most fun parts of LDs for me, coming up with an idea fitting to the theme, was missing. Still, I’m quite happy about the theme since I got to watch a play-through of Zelda 1 on Youtube instead – it’s a game I long have on my list of must-try games. I didn’t get around to actually try it in a NES emulator so I’ll leave it on the list, but seeing a video also tells a bit.

Also, my actual game turned out nice enough – even though it’s basically just a model viewer of a custom Blender exporter I wrote. I needed to get starting with Blender 2.5 scripting anyway, after this it should now be a lot easier to update all my 2.4 scripts. I spent quite a bit of time figuring out the matrix manipulations of armatures.

The first stumbling block was:

scene.frame_set(0)

Basically, my first problem was that the exported mesh always had my armature applied already. So I made a frame 0 with everything key-framed to the rest position. Probably there’s a way to get the raw mesh vertices – but well I couldn’t find it. The next trouble was:

v *= armature.pose.bones[group].matrix.inverted()

This is what I spent the most time on. First I used .matrix_base of the pose vertices and tried to re-assemble bone position and orientation by following all the parents. But it never quite worked out. So then finally I decided to go the brute force route and added the above. Basically, I take the pose (again in rest position with the frame 0 trick) and then apply the inverse transformation to each vertex. When I now in-game just send the matrix to OpenGL everything ends up at the right place – and it all kept working with complex armature hierarchies. If a vertex is affected by more than one bone it might need more tweaking but the models for this game don’t use vertex weights.

Finally the third problem was gamma correction. With the simple solution of disabling “color management” in render settings. Just took some time to identify the problem then find that button in a rather unrelated place (i wasn’t rendering anything, my scene didn’t even have a camera or any lights).

Now I’m only sad that it will be at least several weeks before I’ll have time to get back to this game which I’d really like to finish.

Posted in News | Leave a comment
fosdem-picture

fosdem picture

Just testing how this will appear on ludumdare.com/planet. Will it show my name as “allefant”? Do pictures appear?

Posted in News | 1 Comment

fosdem

2011 is the year of travelling for me, travelled infinitely many more times than any previous year already :)

Mainly meeting the Wesnoth devs here, which is quite fun. They seem to be talking about Wesnoth all the time. And at fosdem, instead of going to any talks they took over one of the hack rooms and do talks and discuss stuff. And there’s a lot of them, close to 15 people I’d say. And well, I’m doing the same, sitting in the hacking room and working on SoF 2.

Posted in News | Leave a comment

Global Game Jam 2011

Last weekend I went to Vienna and took part in the global game jam. indeterminatus mentioned it in #allegro on Tuesday or Wednesday, on Thursday in a moment of insanity I ordered train tickets and on Friday was standing in the Vienna subway trying to find the game jam location… with only wireless internet I really should have noted down the location and maybe brought a map :P

Still, when I saw a station called Karlsplatz in the subway plan I remembered, and went there. Outside the station I saw a university building… and at the main entrance there was a sign saying “game jam” and then another sign pointing up a stairway. And there I was.

The main difference to LD48/pyweek/speedhack and so on was that it was a team competition. I mainly did some support coding. Will put a link to the game later.

Posted in News | Leave a comment