Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » An Allegro Game in 20 lines of code - Possible?

This thread is locked; no one can reply to it. rss feed Print
An Allegro Game in 20 lines of code - Possible?
Hard Rock
Member #1,547
September 2001
avatar

Allright heres my entry, Nibbles/Snake 19 lines, or 20 if you count the comment on the top

1//Wow, i still have room for comments, Nibbles/Snake Game in 20 lines...
2#include <allegro.h> // ... By Hard Rock
3int main(void) {
4 int alive = 1,x = 100, y = 100, direction = 0,score = 0;
5 allegro_init();
6 install_keyboard();
7 install_timer();
8 set_gfx_mode(GFX_AUTODETECT,320,200,0,0);
9 hline(screen,0,8,screen->w,4);
10 while (alive && !key[KEY_ESC]) { //Main Loop
11 textprintf_centre(screen, font, 100, 0, 1, " Your Score is %d",score );
12 if(x < 0 || x > screen->w || y < 9 || y > screen->h) break; //Hits end and our snake is dead, was gonna do alive = 0, but what the heck. break works too
13 key[KEY_UP] ? direction = 0: key[KEY_DOWN] ? direction = 1 : key[KEY_RIGHT] ? direction = 2 : key[KEY_LEFT] ? direction = 3 : NULL; //Check which buttons are pressed and where to go
14 direction ==0 ? y = y -1 : direction ==1 ? y = y + 1 : direction ==2 ? x = x +1 : direction == 3 ?x = x-1:NULL;
15 if(getpixel(screen,x,y) == 1) alive = 0;
16 putpixel(screen,x,y,1);
17 rest(10);
18 score++;
19 } return 0;
20} END_OF_MAIN();

I could probably cheat and drop a lot more lines, but it works fine as is... well maybe is should make the score a long.................. becuase it wont take long for the int to overfill.
So you can just drop comments then and change it.., easily yourself if you want.

_________________________________________________
Hard Rock
[ Stars Dev Company ][ Twitter ][Global Warming: ARA My TINS 07 Entry][Pong Ultra Website][GifAllegS Ver 1.07]
"Well there's also coolwebsearch but we'll let that be an IE exclusive feature" - arielb on the New Browser Plugins "What's better, HTML or Variables?"

Goodbytes
Member #448
June 2000
avatar

Well, after seeing that Hard Rock has done a nibbles/snake game, I don't know if my entry is going to be very impressive, but here goes. It's one of those 15-square puzzles. Enjoy!

1#include <allegro.h>
2int main() {
3 int cells[16] = { 12, 5, 10, 6, 2, 4, 11, 7, 13, 3, 0, 8, 14, 1, 15, 9 }, i, zp, c, cp, quit = 0;
4 allegro_init();
5 install_mouse();
6 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0);
7 show_mouse(screen);
8 while(!(mouse_b & 2) && !quit) {
9 for(i = 0; i < 16; i++, zp = cells<i> ? zp : i)
10 textprintf(screen, font, 64 + i % 4 * 48, 32 + i / 4 * 48, cells<i>, "%d ", cells<i>);
11 if((c = getpixel(screen, mouse_x, mouse_y)) && mouse_b & 1) {
12 for(i = 0; i < 16; i++)
13 cp = (c == cells<i> ? i : cp);
14 if(vector_length_f(zp % 4 - cp % 4, zp / 4 - cp / 4, 0) < 1.01)
15 cells[zp] = c, cells[cp] = 0;
16 }
17 for(i = 0, quit = 1; i < 14; i++)
18 quit = cells<i> > cells[i + 1] ? 0 : quit;
19 }
20} END_OF_MAIN();

It's 20 lines, and it's pretty much normal C-style indenting except for the fact that all of the lines are stuck together, and ignoring that little commanated 14th line that I hope no one notices :)

[EDIT]

By the way, are we going to do the whole 80x25 screen thing? I think it would be pretty damn cool. The rules are straightforward enough... let's say one file, must fit in 80x25 screen, absolutely no exceptions, no external files, and we post them in a thread in a week or so? What do you guys say? If whoever suggested the idea doesn't want to, I'll organize it ;D


--
~Goodbytes

Steve Terry
Member #1,989
March 2002
avatar

goodbytes... quit is not initialized :P set it to 0 otherwise sometimes it will just exit immediately like it did to me.

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

lines of code (semicolon delimited for all you cheaters)

Ok, by strict interpretation of the rules, my game is 16 lines long.

The name of the game is "20 Lines". Interesting fact (to me anyway) is that it only one variable is created in the process (and a second one use used for static data).

NO cheating here. I would not stoop to the level of using commas! >:(

No warnings are generated during compilation using -W -Wall.

And yes, I wrote it all by hand. Thank Bill Gates for VC.NET which easily lets me see which ( [ { pair with } ] )... :P

The controls are a bit laggy, I never got around to updating that portion of the code.

View it here: [url http://www.leverton.cc/misc/20lines.html]

http://www.leverton.cc/pics/20lines.png

Thomas Fjellstrom
Member #476
June 2000
avatar

You my friend are officially insane. Welcome to the club.

I ddin't think it would be possible to do a tetris clone.. But here you've proved me wrong.

One thing though. The fact that it's windowed scores against it :) the XWIN driver is slower than the GDI driver. :)

edit: Oh, so the controlls really are laggy? ok. I thought that was the fault of the driver. I know my pong is laggy in windowed mode...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matthew Leverton
Supreme Loser
January 1999
avatar

Well, there's no reason it cannot be full screen. Just AUTODETECT_FULLSCREEN and set real screen size. Also, on the final buffer->screen blit, you wouldn't have to do a SCREEN_W,SCREEN_H as that would do a lot of extra black space.

The main reason it's laggy is that I only allow the Key's to be pressed at certain times, that way they blocks don't just slide around like crazy. It works fine on my XP 1800 PC, but is a bit laggy on my C333 running FreeBSD.

Thomas Fjellstrom
Member #476
June 2000
avatar

so your code draws it all centered or something? So setting a large mod wouldn't do anything weird?

edit: Guess not. :) The controlls are much better now :)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matthew Leverton
Supreme Loser
January 1999
avatar

Change this:

/*14*/}blit(buffer,screen,0,50,SCREEN_W/2-96,SCREEN_H/2 -176,192,352);

Untested, but something like that should center the output if you chose full screen.

Thomas Fjellstrom
Member #476
June 2000
avatar

ja. that should work. :) I still think you need counseling.

You should think about submitting that to the ioccc one year.

edit:

w00t. and it only took an hour. :) I've slimmed down and unhackified (lots less comma hack) my pong a bit, here for your enjoyment tfpong 2.0beta1:

/*1 */int main(void) { int i=0,x=320,y=rand()%480,dx=-1,dy=1,p1y=240,p2y=240,p1p=0,p2p=0,y1d=10,y2d=470, xs[] = {320, 10, 630}, *y1s[] = { &y1d, &p1y, &p2y }, *y2s[] = { &y2d, &p1y, &p2y };
/*2 */  BITMAP *buff = (allegro_init() == 0 && install_keyboard() == 0 && set_gfx_mode(GFX_AUTODETECT,640,480,0,0) == 0) ? create_bitmap(SCREEN_W, SCREEN_H) : NULL;
/*3 */  while(buff && !key[KEY_ESC] && !key[KEY_Q]) { clear(buff);
/*4 */    ( ((x += dx) | (y += dy)) && (y-2 <= 0 || y+2 >= 480) ) ? (dy = -dy) : ( ( (x-2 <= 10) && (p1y-12 <= y-2 && y+2 <= p1y+12)) ? (dx = -dx) : ( (x-2 <= 10) ? (++p2p, (x=320), (y=rand()%480)) : ( ( (x+2 >= 630) && (p2y-12 <= y-2 && y+2 <= p2y+12)) ? (dx = -dx) : ( (x+2 >= 630) ? (++p1p, (x=320), (y=rand()%480)) : 1))));
/*5 */    (key[KEY_UP] && p2y > 12) ? (( (key[KEY_DOWN] && p2y < 468) ? (p2y+=2) : 1) && (p2y-=2)) : ( (key[KEY_DOWN] && p2y < 468) ? (p2y+=2) : 1);
/*6 */    (key[KEY_W] && p1y > 12) ? (( (key[KEY_S] && p1y < 468) ? (p1y+=2) : 1) && (p1y-=2)) : ( (key[KEY_S] && p1y < 468) ? (p1y+=2) : 1);
/*7 */    textprintf_centre(buff, font, 320, 2, makecol(200,200,200), "%03i    %03i", p1p, p2p); 
/*8 */    for(i=0; i < 3; ++i) vline(buff, xs<i>, (*y1s<i>)-10, (*y2s<i>)+10, makecol(255,255,255));
/*9 */    circlefill(buff, x-2, y-2, 2, makecol(255,255,255));
/*10*/    blit(buff, screen, 0, 0, 0, 0, 640, 480);
/*11*/  } return 0;
/*12*/}END_OF_MAIN();

notes: This new version should be equivelent to the last, including the same bugs, as its the same code, just reoganized a bit.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

nonnus29
Member #2,606
August 2002
avatar

Bravo Matthew! Line 7 is the longest line of code I have ever seen. I was trying to think of how to do Tetris clone in that amount of space. You must have really been 'in the zone' for this one!

EDIT: We've got a two player pong, a tetris, snakes, a couple of shooters, a bouncy ball game, a tile puzzle, some shooters... come on people, Who's going to take us into THE THIRD DIMENSION??

miran
Member #2,407
June 2002

Quote:

THE THIRD DIMENSION

Funny you should mention that... ;);D;)8-);D;)8-)

1#include <allegro.h>
2#include <math.h>
3class Vector {public: float x, y, z; Vector& operator*=(float l) { x*=l, y*=l, z*=l; return *this;}} Origin;
4void fd_planes(int x, int y, int *u, int *v, int *z) { Vector Direction = {(x-160)/120.0f,(y-100)/120.0f,1}, Intersect;
5Direction *= 1.0f/sqrt(Direction.x*Direction.x + Direction.y*Direction.y + Direction.z*Direction.z);
6float t = ((Direction.y>0?1:-1)*550-Origin.y)/Direction.y;
7Intersect.x = Origin.x + Direction.x*t, Intersect.y = Origin.y + Direction.y*t, Intersect.z = Origin.z + Direction.z*t;
8*u = (int)(fabs(Intersect.x)*0.3);
9*v = (int)(fabs(Intersect.z)*0.3);
10((t = (Intersect.x-Origin.x)*(Intersect.x-Origin.x) + (Intersect.z-Origin.z)*(Intersect.z-Origin.z)) <= 1.0E-6) ? (*z = 0) : (t = 50000.0/sqrt(t), *z = (int)(t > 63 ? 63 : t));}
11static volatile int timer = 0;
12static void timer_f() { ++timer; } END_OF_STATIC_FUNCTION(timer_f);
13void main() { int deltaz = 32, u=0, v=0, z=0, i,j;
14BITMAP *buffer, *texture;
15allegro_init(), install_keyboard(), install_timer(), set_color_depth(16), set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0), clear(screen), buffer = create_bitmap(SCREEN_W, SCREEN_H), clear(buffer), texture = create_bitmap(256,256);
16for (i=0; i<256; i++) for (j=0; j<256; j++) putpixel(texture, i, j, (i&j)|(~i^j));
17LOCK_VARIABLE(timer) LOCK_FUNCTION(timer_f) install_int_ex(timer_f, BPS_TO_TIMER(25));
18Origin.x = 0.0f, Origin.y = 0.0f, Origin.z = 0.0f;
19while (!key[KEY_ESC]) { while ((timer = (timer>0) ? -1 : 0)) { --timer, Origin.z += (float)deltaz; }
20for (int y=0; y<SCREEN_H; ++y) { for (int x=0; x<SCREEN_W; ++x) { fd_planes(x,y,&u,&v,&z), putpixel(buffer, x, y, makecol((getr(getpixel(texture, u&255, v&255))*(int)z)>>6, (getg(getpixel(texture, u&255, v&255))*(int)z)>>6, (getb(getpixel(texture, u&255, v&255))*(int)z)>>6));}}
21blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); }
22} END_OF_MAIN();

It's not exactly 20 lines, it's 22 but two of them are includes. Also it is in C++ not C and I cheated big time on this one with the commas and all that. It's impossible to make a raytracer in 20 lines whithout cheating. Oh yeah, it's a raytracer so it should be pretty slow on low end machines...

--
sig used to be here

Evert
Member #794
November 2000
avatar

Very impressive so far! Too bad I couldn't run Miran's code...

miran
Member #2,407
June 2002

Why not? Do you have a slow machine or does the code not work/compile?

--
sig used to be here

Evert
Member #794
November 2000
avatar

Nothing you can fix:

eglebbk@huygens: ~/Program/20>g++ -W -Wall miran.cc -o miran `allegro-config --libs`
miran.cc: In function `void _mangled_main()':
miran.cc:13: warning: unused variable `int c'
eglebbk@huygens: ~/Program/20>./miran
ld.so.1: ./miran: fatal: libstdc++.so.2.10.0: open failed: No such file or directory
Killed

I'll try on my own Linux box later.
The machine I'm on now probably is too slow too...

Thomas Fjellstrom
Member #476
June 2000
avatar

Worked for me. It was a bit slow, But it shul be fine in Full screen mode. Yup. the ESC key reacts alot quicker in full screen mode :)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Goodbytes
Member #448
June 2000
avatar

Steve Terry said:

goodbytes... quit is not initialized set it to 0 otherwise sometimes it will just exit immediately like it did to me.

No, it's... it's... damn.

Blame that on untested code changes. :P

p.s. Miran and Matthew, you are el337 h4XX0r5.


--
~Goodbytes

Evert
Member #794
November 2000
avatar

Anyone done TicTacToe already? No? Fine here's mine :P
I spend about an hour on that one. It'd be nice if I could add some AI to it - I have three whopping lines left to play with afterall;D!
More if I'm allowed to use 20 ;'s in my code.

So who'se going to post the first RPG?

1#include <allegro.h>
2#include <time.h>
3#define DRAWTILE(c) rect(screen, c/3*33, c%3*33, c/3*33+33, c%3*33+33, 0), b[c/3][c%3]?circlefill(screen, (c/3)*33+16, (c%3)*33+16, 10, b[c/3][c%3]==1?4:1):0
4#define CHECKROW(x1,y1,x2,y2,x3,y3) ( (b[x1][y1]+b[x2][y2]+b[x3][y3])? ( (b[x1][y1]+b[x2][y2]+b[x3][y3])/3 ):0 )
5int main(void) { int b[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}}, moves = 0, done = 0,drawme = 1, c;
6 srand(time(NULL)), allegro_init(),install_keyboard(),install_timer,install_mouse(),set_gfx_mode(GFX_AUTODETECT, 99,99,0,0), clear_to_color(screen, 15), text_mode(-1), show_mouse(screen);
7 while (moves<9 && !key[KEY_ESC] && !done) {
8 if (moves&1) { do {c = (rand()>>8)%9;
9 } while (b[c/3][c%3]);
10 b[c/3][c%3]=-1, moves++, drawme=1;
11 } else {(mouse_b)? b[mouse_x/33][mouse_y/33]==0?b[mouse_x/33][mouse_y/33]=1, moves++:0:0;}
12 done = CHECKROW(0,0, 0,1, 0,2) || CHECKROW(1,0, 1,1, 1,2) || CHECKROW(2,0, 2,1, 2,2) || CHECKROW(0,0, 1,0, 2,0) || CHECKROW(0,1, 1,1, 2,1) || CHECKROW(0,2, 1,2, 2,2) || CHECKROW(0,0, 1,1, 2,2) || CHECKROW(2,0, 1,1, 0,2);
13 scare_mouse(), drawme ? DRAWTILE(0), DRAWTILE(1), DRAWTILE(2), DRAWTILE(3), DRAWTILE(4), DRAWTILE(5), DRAWTILE(6), DRAWTILE(7), DRAWTILE(8), DRAWTILE(9), drawme = 0: 0, unscare_mouse();
14 }
15 done ? textprintf_centre(screen, font, 45, 45, 14, moves&1?"You win!":"You lose!"),readkey():0;
16 return 0;
17} END_OF_MAIN()

EDIT: fixed some minor bugs.

miran
Member #2,407
June 2002

Doesn't work in Windows, at least not on my box. Had to change the window size to 120x120...

--
sig used to be here

Evert
Member #794
November 2000
avatar

Ah, yes - Allegro has this limit that doesn't allow you to make a window of less than 100 pixels!
I'll update it later to a larger window size. Just changing the dimensions in set_gfx_mode probably means you're toast if you move the mouse off the plaing board (no range checks).

Paul Pridham
Member #250
April 2000
avatar

Yesterday I was a bit inspired by you guys, and so I made a little game. It's your standard "ship plummeting ever faster down the endless tunnel" game. Fun for a diversion at least. ;)

Get it here: http://www3.sympatico.ca/ppridham/misc/games/LongWayDown.zip

Yes, it's all written in main(), ;) because it was originally going to be done in 20 lines, but I decided to just add as much as I needed to give it a wee bit of polish.

Evert
Member #794
November 2000
avatar

Ok, an updated version of my TicTacToe:

1#include <allegro.h>
2#include <time.h>
3#define DRAWTILE(c) rect(screen, c/3*(SCREEN_W/3), c%3*(SCREEN_H/3), c/3*(SCREEN_W/3)+(SCREEN_W/3), c%3*(SCREEN_H/3)+(SCREEN_H/3), 0), b[c/3][c%3]?circlefill(screen, (c/3)*(SCREEN_W/3)+(SCREEN_W/6), (c%3)*(SCREEN_H/3)+(SCREEN_H/6), (SCREEN_W/10), b[c/3][c%3]==1?4:1):0
4#define CHECKROW(x1,y1,x2,y2,x3,y3) ( (b[x1][y1]+b[x2][y2]+b[x3][y3])? ( (b[x1][y1]+b[x2][y2]+b[x3][y3])/3 ):0 )
5int main(void) { int b[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}}, moves = 0, done = 0,drawme = 1, c;
6 srand(time(NULL)), allegro_init(), install_keyboard(),install_timer,install_mouse(),set_gfx_mode(GFX_AUTODETECT, 256,256,0,0), clear_to_color(screen, 15), text_mode(-1), show_mouse(screen);
7 while (moves<9 && !key[KEY_ESC] && !done) {
8 if (moves&1) { do {c = (rand()>>8)%9;
9 } while (b[c/3][c%3]);
10 b[c/3][c%3]=-1, moves++, drawme=1;
11 } else {(mouse_b)? b[mouse_x/(SCREEN_W/3)][mouse_y/(SCREEN_H/3)]==0?b[mouse_x/(SCREEN_W/3)][mouse_y/(SCREEN_H/3)]=1, moves++:0:0;}
12 done = CHECKROW(0,0, 0,1, 0,2) || CHECKROW(1,0, 1,1, 1,2) || CHECKROW(2,0, 2,1, 2,2) || CHECKROW(0,0, 1,0, 2,0) || CHECKROW(0,1, 1,1, 2,1) || CHECKROW(0,2, 1,2, 2,2) || CHECKROW(0,0, 1,1, 2,2) || CHECKROW(2,0, 1,1, 0,2);
13 if (drawme||done||(moves==9)) {scare_mouse(), DRAWTILE(0), DRAWTILE(1), DRAWTILE(2), DRAWTILE(3), DRAWTILE(4), DRAWTILE(5), DRAWTILE(6), DRAWTILE(7), DRAWTILE(8), DRAWTILE(9), unscare_mouse(), drawme = 0;}
14 } if (done||(moves==9)) { textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2, 2, done?moves&1?"You win!":"You lose!":"Draw!"),readkey(); }
15 return 0;
16} END_OF_MAIN()

And a game for two players: fox and geese.
Move teh geese with the left and right arrow keys, then move the fox with the QWAS keys. The fox wins if it reaches the other side of the board, the geese win if they reach it. Could use some more finess, but it's ok for now ;)

#include <allegro.h>
#define DRAWTILE(c) rectfill(screen, c/8*(SCREEN_W/8), c%8*(SCREEN_H/8),  c/8*(SCREEN_W/8)+(SCREEN_W/8), c%8*(SCREEN_H/8)+(SCREEN_H/8), ((c%8)&1)^((c/8)&1)?0:15), circlefill(screen, goose[0]%8*(SCREEN_W/8)+SCREEN_W/16, goose[0]/8*(SCREEN_H/8)+SCREEN_H/16, SCREEN_W/32, 4), circlefill(screen, goose[1]%8*(SCREEN_W/8)+SCREEN_W/16, goose[1]/8*(SCREEN_H/8)+SCREEN_H/16, SCREEN_W/32, 4), circlefill(screen, goose[2]%8*(SCREEN_W/8)+SCREEN_W/16, goose[2]/8*(SCREEN_H/8)+SCREEN_H/16, SCREEN_W/32, 4), circlefill(screen, goose[3]%8*(SCREEN_W/8)+SCREEN_W/16, goose[3]/8*(SCREEN_H/8)+SCREEN_H/16, SCREEN_W/32, 4), circlefill(screen, fox%8*(SCREEN_W/8)+SCREEN_W/16, fox/8*(SCREEN_H/8)+SCREEN_H/16, SCREEN_W/32, 1), rect(screen, goose[sgoose]%8*(SCREEN_W/8), goose[sgoose]/8*(SCREEN_H/8),  goose[sgoose]%8*(SCREEN_W/8)+(SCREEN_W/8)-1, goose[sgoose]/8*(SCREEN_H/8)+(SCREEN_H/8)-1, 14)
int main(void) { int goose[4] = {63,61,59,57}, sgoose = 0, fox = 4, turn = 0, done = 0, drawme = 1, c;
   allegro_init(), install_keyboard(), install_timer, install_mouse(),set_gfx_mode(GFX_AUTODETECT, 256,256,0,0), clear_to_color(screen, 15), text_mode(-1), show_mouse(screen);
   while (!key[KEY_ESC] && !done) {
      turn ? ( (fox%8!=7) ? fox-=((goose[0]==fox+9||goose[1]==fox+9||goose[2]==fox+9||goose[3]==fox+9)?0:(9*key[KEY_S])), drawme |= !((key[KEY_S])?turn=0:1):0,(fox%8!=0) ? fox-=((goose[0]==fox+7||goose[1]==fox+7||goose[2]==fox+7||goose[3]==fox+7)?0:(7*key[KEY_A])), drawme |= !((key[KEY_A])?turn=0:1):0, (fox%8!=0 && fox>8) ? (fox +=((goose[0]==fox-9||goose[1]==fox-9||goose[2]==fox-9||goose[3]==fox-9)?0:(9*key[KEY_Q])), drawme |= !((key[KEY_Q])?turn=0:1)):0, (fox%8!=7 && fox>8) ? (fox +=((goose[0]==fox-7||goose[1]==fox-7||goose[2]==fox-7||goose[3]==fox-7)?0:(7*key[KEY_W])), drawme |= !((key[KEY_W])?turn=0:1)):0  ):( sgoose=( sgoose + (key[KEY_TAB]?(drawme=1):0) )&3, (goose[sgoose]%8!=0 && goose[sgoose]>8) ? (goose[sgoose] += (goose[sgoose]-9==fox?0:9*key[KEY_LEFT]), drawme |= ((key[KEY_LEFT])?turn=1:0)):0, (goose[sgoose]%8!=7 && goose[sgoose]>8) ? (goose[sgoose] += (goose[sgoose]-7==fox?0:7*key[KEY_RIGHT]), drawme |= ((key[KEY_RIGHT])?turn=1:0)):0);
      if (drawme) for(c=0;c<64;c++){ scare_mouse(), DRAWTILE(c), unscare_mouse(), drawme = 0; }
      rest(50);
      done = (fox>56 || (goose[0]<8 && goose[1]<8 && goose[2]<8 && goose[3]<8) ) ? 1:0;
   } while(keypressed()) readkey();
   done?textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2, 2, (fox>56)?"Fox wins!":"Geese win!"), readkey():0;
   return 0;
} END_OF_MAIN()

Zaphos
Member #1,468
August 2001

Matthew: Heh, I never knew MSVC had a 2048 character per line limit ... but now that I tried to copy paste your program into it, now I know! ... see what useful information I get from this site?

Goodbytes: I'd love to have a 25x80 compo! Judging from the programs already written, I think we'd see some cool stuff ...

Goodbytes
Member #448
June 2000
avatar

Quote:

Goodbytes: I'd love to have a 25x80 compo! Judging from the programs already written, I think we'd see some cool stuff ...

That sounds like an invitation! Well, then it's official... and one day, I will be the Contest Ruler of Allegro!!!!! hey... there's no evil smiley. That is unfortunate.

Anyways... okay then.


--
~Goodbytes

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

there's no evil smiley. That is unfortunate.

well... hopefully http://strangesoft.net/kefka.gif will suffice! :D

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

there's no evil smiley.

Sure there is.

Evil.gif Evil.gif Evil.gif

It just doesn't work :P

KefkaL.gif

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.



Go to: