The 2004 Allegro ScreenHack
Goodbytes

A few months/years ago we had a '20 line' programming contest, during which spellcaster suggested we have a 80x25 programming contest. I can't actually find the thread, since the forum search function is lame, but trust me. It happened. :)

Anyway, I have decided to steal spellcaster's idea. (Hope you don't mind, sc? :)) Let's do this thing.

The 2004 Allegro ScreenHack Rules
Post some C or C++ source code that will completely fit into an 80-character by 25-character screen (the standard DOS prompt size) and that will compile on its own (along with a full complement of Allegro/system headers, that is). The best entry (I'm talking games here) will be chosen by vote sometime in the near future. You are allowed to submit as many entries as you like.

Who's up for the challenge? Prove your mettle! Post me some code! ;D

Eric Love

I'll never forget a discussion on GameDev a few years ago. Someone complained that the way they implemented Tetris (OO with two files for each class I guess) made for 117 files (or some number like that). Someone said "117 files? Tetris should be like 117 lines!" and then the race was on to implement Tetris in a miminum of space. It was done in around 13 lines. I don't still have it, but many were surprised that it complied and ran.

So you can do a lot in 80x25, but it makes the code very difficult to read. I'm keen to see what people come up with. I also remember a comp with 256 byte .com files, one of which was a space shooter.

Evert

Matthew did a tetris for the 20 line thing.
As for 25x80 - I guess it's neat, but I'd rather see a 2000 byte limit on filesize.

Anyway, I'll see if I can think of anything (and actually implement it) this weekend. I've been meaning to get my chess programs ready for beta release for a few weeks now, and I hope to get round to that too.

Fladimir da Gorf

What about a contest in which the code should look like a logo or a screenshot of the game? The better the code represents the game it compiles to, the better. :)

Evert

Hmm... I've seen ASCII art Mandelbrot fractals, but I woudn't want to write code to generate one that at the same time looks like one ;)

It's a neat idea though.

Fladimir da Gorf

The secret is to modify the code to look almost something sensible. Even by adding or deleting spaces here and there can make it look like something.

Oh, and then there's the famous #defines to play with...

Trezker

If you do these kind of things you have too much brainpower and should give some to me!

tareco

I was bored so I made a lame tic tac toe :P

1#include <allegro.h>
2#define I(x, y)if(x){y}
3#define E(z)else{z}
4#define C(y,z)case y: z break;
5#define W(x,y){a, x, y, 60, 60, 255, 0, 0, 0, 0, 0},
6int s=0,j[2];int a(int msg,DIALOG *d,int c){switch(msg){C(MSG_DRAW,rect(screen,d
7->x,d->y,d->x+d->w,d->y+d->h,d->fg);I(d->d1,I(d->d2,rectfill(screen,d->x+2,d->y+
82,d->x+d->w-2,d->y+d->h-2,d->fg);)E(line(screen,d->x,d->y,d->x+d->w,d->y+d->h,d
9->fg);line(screen,d->x,d->y+d->h,d->x+d->w,d->y,d->fg);)))C(MSG_LPRESS,I(!d->d1,
10d->d2=s;d->d1=1;I(s,s=0;)E(s=1;);return D_REDRAW;))}return D_O_K;}int z(int msg,
11DIALOG *d, int c){int x,y,p,l;DIALOG *b=d->dp;switch(msg){C(MSG_IDLE,for(p=0;p<3
12;p++){for(x=0;x<3;x++){l=0;for(y=0;y<3;y++){I(b[1+y*3+x].d1&&b[1+y*3+x].d2==p,l
13++;)}I(l==3,j[p]++;return D_CLOSE;)}for(y=0;y<3;y++){l=0;for(x=0;x<3;x++){I(b[1+
14y*3+x].d1&&b[1+y*3+x].d2==p,l++;)}I(l==3,j[p]++;return D_CLOSE;)}y=0;l=0;for(x=0
15;x<3;x++){I(b[1+y*3+x].d1&&b[1+y*3+x].d2==p,l++;)y++;}I(l==3,j[p]++;return
16D_CLOSE;)y=0;l=0;for(x=2;x>-1;x--){I(b[1+y*3+x].d1&&b[1+y*3+x].d2==p,l++;)y++;}I
17(l==3,j[p]++;return D_CLOSE;)l=0;for(x=0;x<3;x++){for(y=0;y<3;y++){I(b[1+y*3+x].
18d1,l++;)I(l==9,return D_CLOSE;)}}})}return D_O_K;}int game(){DIALOG w[]={{
19d_clear_proc,0,0,0,0,16,16},W(0,0)W(0,60)W(0,120)W(60,0)W(60,60)W(60,120)W(120,0
20)W(120,60)W(120,120){d_ctext_proc,250,20,0,0,40},{d_ctext_proc,250,30,0,0,1},{
21d_ctext_proc,250,0,0,0,255,0,0,0,0,0,"TicTacToe"},{z,0,0,0,0,0,0,0,0,0,0,w},{0}}
22;char v[2][20];sprintf(v[0],"%d",j[0]);sprintf(v[1],"%d",j[1]);w[10].dp=v[0];w
23[11].dp=v[1];I(do_dialog(w,-1)==-1,return 0;)return game();}void main(){
24allegro_init();install_keyboard();install_mouse();install_timer();set_gfx_mode(
25GFX_AUTODETECT_WINDOWED,320,200,0,0);game();}END_OF_MAIN();

EDIT: There, it should be working now.

Tobias Dammers

Bomberman, only without monsters, and no eye candy of course...

1#include <allegro.h>
2#define L(x) for (x=0; x<60;++x)
3#define I t[y][x]
4typedef int i;typedef void v;i(*k)()=readkey;RGB pl[256]={{0,0,0},{48,0,0},{0,32
5,63},{16,16,16},{32,32,32},{48,48,48},{0,32,0},{63,63,63}};typedef struct{i t;i
6c;}T;BITMAP* b,*s;i h=480,z=60,X=0,Y=0,c=0,d=0,g=0,e=1,m=9000;T t[60][60];v C(i
7x,i y,i cl){circlefill(b,x+4,y+4,3,cl);circle(b,x+4,y+4,3,0);}i R(){return X*8+(
8(d==1)?c:(d==2)?(-c):0);}i S(){return Y*8+((d==3)?c:(d==4)?(-c):0);}i E(i,i);v p
9(){i x,y;L(y)L(x){rectfill(b,x*8,y*8,x*8+8,y*8+8,(I.t<4)?6:I.t);if(I.t&&(I.t<4))
10C(x*8,y*8,I.t);}C(R(),S(),7);vsync();blit(b,s,0,0,80,0,h,h);textprintf(s,font,0,
110,7,"%3is",m/60);textprintf(s,font,0,10,2,"%i",e);}v pe(i xx,i yy){i x=xx,y=yy;I
12.t=1;I.c=z;for(x=xx+1;(x<=MIN(xx+e,59))&& E(x,y);++x);for(x=xx-1;(x>=MAX(xx-e,0)
13)&& E(x,y);--x);x=xx;for(y=yy+1;(y<=MIN(yy+e,59))&& E(x,y);++y);for(y=yy-1;(y>=
14MAX(yy-e,0))&& E(x,y);--y);}i E(i x,i y){i f=I.t;if(f==3)pe(x,y);if(f==4)return
150;I.t=1;I.c=z;return !f;}v u(i x,i y){if(I.c)--I.c;if(!I.c){if(I.t==1)I.t=0;if(I
16.t==3)pe(x,y);}}i main(){i x,y;allegro_init();install_keyboard();set_gfx_mode(0,
17640,h,0,0);srand(time(0));s=screen;b=create_bitmap(h,h);set_palette(pl);L(y)L(x)
18I.t=(x&y&1)?4:((((x&1)||(y&1))&&(x+y>3)&&!(rand()&1))?5:0);L(x)t[(rand()%z)&~1][
19(rand()%z)&~1].t=2;t[59][59].t=0;do{p();--m;L(y)L(x)u(x,y);if(d)++c;if(!(c&7)){X
20=R()/8;Y=S()/8;if(t[Y][X].t==1)m=0;if(t[Y][X].t==2){++e;m+=120;t[Y][X].t=0;}if((
21X==59)&&(Y==59))g=1;d=0;if(key[82])d=2;if(key[83])d=1;if(key[84])d=4;if(key[85])
22d=3;c=8;if((R()>=h)||(R()<0)||(S()>=h)||(S()<0)||(t[S()/8][R()/8].t>2))d=0;c=0;
23if(keypressed()){i j=k()>>8;if(j==75){t[Y][X].t=3;t[Y][X].c=180;}if(j==59)m=0;}}
24}while(m && !g);rest(1000);while(keypressed())k();clear(s);textprintf(s,font,260
25,240,g?7:1,"You %s! Score:%i",g?"win":"lose",m/z);k();}END_OF_MAIN()

CGamesPlay

Just to show you all how incredibly freaking awesome I am, I wrote a program to allow you do unobfuscate the program I submit to the competition. I have this contest in the bag. ;D

1#include <allegro.h> /* Obfuscated Code Jigsaw - Ryan Patterson */
2#include <stdio.h> /* This program is my entry into the 2004 Allegro */
3#include <string.h> /* ScreenHack competition. The game is a classic jigsaw */
4/* puzzle. Simply move pieces around to piece back together my horribly */
5/* obfuscated code. Compiles with gcc 3.3.1 and MSVC 7. Note that the file */
6/* needs to be run from the same directory as its source file -- it reads in */
7/* its source as the background for the puzzle. Even has animation. Enjoy! */
8int i,x,y,p=4,m=0;BITMAP*b[25],*d[25],*s,*w;char l[81],*c;k(){if((i==p-1&&p%5!=
90)||(i==p+1&&p%5!=4)||(i==p+5&&p<20)||(i==p-5&&p>4)){w=b[p];b[p]=b<i>;b<i>=w;p=
10i;if(!*l)++m;}}main(){FILE*f=fopen(__FILE__,"r");srand(time(NULL));allegro_init
11();install_keyboard();install_mouse();set_color_depth(32);set_gfx_mode(GFX_AUT\
12ODETECT_WINDOWED,640,200,0,0);s=create_bitmap(640,200);clear(s);for(i=0;i<25&&!
13feof(f)&&*fgets(l,81,f);++i,*l=0){if(strlen(l)<2){--i;continue;}c=strchr(l,13);
14if(!c)c=strchr(l,10);if(c)*c=0;textout(s,font,l,0,i*8,-1);}fclose(f);for(x=0;x<
155;++x)for(y=0;y<5;++y)b[y*5+x]=d[y*5+x]=create_sub_bitmap(s,x*128,y*40,128,40);
16clear(b[p]);*l=1;while(!key[KEY_ESC]){if(!*l){if(!(mouse_b&1))continue;i=(mous\
17e_y/40)*5+(mouse_x/128);k();i=0;for(x=0;x<5;++x)for(y=0;y<5;++y)if(b[y*5+x]!=d[
18y*5+x])i=1;if(!i){textprintf(screen,font,392,168,0xff00,"You won in %d moves!",
19m);rest(2000);readkey();break;}}else{textprintf(screen,font,392,168,0xff0000,"\
20Randomizing... %d%%",(unsigned char)*l*100/255);rest(100);switch(rand()%4){case
210:i=p-1;break;case 1:i=p+1;break;case 2:i=p-5;break;case 3:i=p+5;break;}k();++*
22l;}show_mouse(NULL);for(x=0;x<5;++x)for(y=0;y<5;++y)blit(b[y*5+x],screen,0,0,x*
23128,y*40,128,40);for(x=1;x<5;++x)vline(screen,x*128,0,200,-1);for(y=1;y<5;++y)\
24hline(screen,0,y*40,640,-1);show_mouse(screen);}for(i=0;i<25;++i)destroy_bitmap
25(b<i>);destroy_bitmap(s);}END_OF_MAIN()/*Thanks for playing! Hope you enjoyed*/

[edit]
I tried the other two... Tareco's crashed (after I set the gfx mode to GFX_AUTODETECT_WINDOWED), and I couldn't get Tobias' to do anything...

[edit]
Well, I tried again and got Tobias' to do something... But how do you win or lose?

Tobias Dammers

OK, didn't include much info...
Goal is to reach bottom-right corner before time elapses. Picking up blue blobs increases explosion radius and gives 1 extra second.
Keys: Cursor keys move, space drops bomb, esc aborts.
Here's the new version; I also included a fade-out at the end, a clock counter and an explosion range display (blue number).

1#include <allegro.h>
2#define L(x) for (x=0; x<60;++x)
3#define I t[y][x]
4typedef int i;typedef void v;i(*k)()=readkey;RGB l[256]={{0,0,0},{48,0,0},{0,32,
563},{16,16,16},{32,32,32},{48,48,48},{0,32,0},{63,63,63}};i h=480,z=60,X=0,Y=0,c
6=0,d=0,g=0,e=1,m=9000;typedef struct{i t;i c;}T;BITMAP* b,*s;T t[60][60];v C(i x
7,i y,i a){circlefill(b,x+4,y+4,a?3:4,a);}i R(){return X*8+((d==1)?c:(d==2)?(-c):
80);}i S(){return Y*8+((d==3)?c:(d==4)?(-c):0);}v p(){i x,y;L(y)L(x){rectfill(b,x
9*8,y*8,x*8+8,y*8+8,(I.t<4)?6:I.t);if(I.t&&(I.t<4)){C(x*8,y*8,0);C(x*8,y*8,I.t);}
10}C(R(),S(),0);C(R(),S(),7);vsync();blit(b,s,0,0,80,0,h,h);textprintf(s,font,0,0,
117,"%3is",m/60);textprintf(s,font,0,10,2,"%i",e);}i E(i,i);v n(i P,i Q){i x=P,y=Q
12;I.t=1;I.c=z;for(x=P+1;(x<=MIN(P+e,59))&& E(x,y);++x);for(x=P-1;(x>=MAX(P-e,0))
13&& E(x,y);--x);x=P;for(y=Q+1;(y<=MIN(Q+e,59))&& E(x,y);++y);for(y=Q-1;(y>=MAX(Q-
14e,0))&& E(x,y);--y);}i E(i x,i y){i f=I.t;if(f==3)n(x,y);if(f==4)return 0;I.t=1;
15I.c=z;return !f;}v u(i x,i y){if(I.c)--I.c;if(!I.c){if(I.t==1)I.t=0;if(I.t==3)n(
16x,y);}}i main(){allegro_init();install_keyboard();srand(time(0));set_gfx_mode(0,
17640,h,0,0);i x,y;s=screen;b=create_bitmap(h,h);set_palette(l);L(y)L(x)I.t=(x&y&1
18)?4:((((x&1)||(y&1))&&(x+y>3)&&!(rand()&1))?5:0);L(x)t[(rand()%z)&~1][(rand()%z)
19&~1].t=2;t[59][59].t=0;do{p();--m;L(y)L(x)u(x,y);if(d)++c;if(!(c&7)){X=R()/8;Y=S
20()/8;if(t[Y][X].t==1)m=0;if(t[Y][X].t==2){++e;m+=120;t[Y][X].t=0;}if((X==59)&&(Y
21==59))g=1;d=0;if(keypressed()){i j=k()>>8;if(j==75){t[Y][X].t=3;t[Y][X].c=180;}
22if(j==59)m=0;}if(key[82])d=2;if(key[83])d=1;if(key[84])d=4;if(key[85])d=3;c=8;if
23((R()>=h)||(R()<0)||(S()>=h)||(S()<0)||(t[S()/8][R()/8].t>2))d=0;c=0;}}while(m
24&& !g);fade_out(1);clear(s);textprintf(s,font,260,240,g?7:1,"You %s! Score:%i",g
25?"win":"lose",m/z);set_palette(l);while(keypressed())k();k();}END_OF_MAIN()

Elias

Also had to try myself in this (disable warnings when compiling :P):

1#include <allegro.h> /*CURSOR LEFT/RIGHT: MOVE, CURSOR DOWN: POOR WATER*/
2#define T(y,c,s,p) (y?textprintf_centre(buf,font,160,y,c,s,p),0:key[KEY_ESC])
3#define R(s,x,y,w,h,c)(s?rectfill(buf,x,y-h,x+w,y,c),0:getpixel(buf,x,240+(y)))
4volatile int t=0;int x[99],y[99],w[99],h[99],X,Y,i,j,ot,d,f,u=0,o=0,s=1,l=1,r,z
5=0;void tick(void){t++;};int main(void){srand(time(NULL));if(allegro_init()||
6set_gfx_mode(GFX_AUTODETECT,320,240,0,0)||install_keyboard ())return-1;BITMAP*
7buf;install_int_ex (tick,BPS_TO_TIMER (60));buf=create_bitmap (320,480);A:clear
8(buf);memset(y,0,sizeof y);x[0]=y[0]=120;w[0]=h[0]=20;hline(buf,0,479,319,42);
9while(T(0,0,0,0));t=0;while(!T(0,0,0,0)){if(o|s)goto R;if(!(t % (30 - l * 2))){
10i=2 * (rand () % 160);d=1+rand()%20;for(j=1;j<50;j++)if(!y[j]){x[j]=i;i=(i+2)%
11320;y[j]=w[j]=1;h[j]=d;}}blit(buf,buf,0,240,0,0,320,240);for(j=0;j<99;j++){X=x[
12j];Y=y[j];if(j<50){if(Y){R(1,X,Y,w[j],h[j],j?76+(Y&15):4);if(j&&X<=x[0]+w[0]&&x
13[0]<=X+w[j]&&Y>=y[0]-h[0]&&y[0]>=Y-h[j])o=1;f=1;d=0;if(!j){if(u)f=-1;if(key[
14KEY_LEFT])d=-1;if(key[KEY_RIGHT])d=1;if(key[KEY_DOWN])for(i=50;i<99;i++)if(!y[i
15]){x<i>=2*(x[j]/2)+10;y<i>=y[j];h<i>=60;break;}u=0;}for(i=0;i<=w[j];i++)if(R(0,
16X+i+d,Y+((i&1)?f:0),0,0,0)>0){if(f>0){if(j){R(1,X,240+Y,w[j],h[j],15);y[j]=0;}
17else u=1;f=0;}if(!(i&1))d=0;}x[j]+=d;y[j]+=f;}}else{if(y[j]){R(1,X,Y,1,0,9);if(
18R(0,X,Y+1,0,0,0)){r=(rand()&1)?2:-2;if(R(0,X+r,Y,0,0,0)){if(R(0,X-r,Y,0,0,0)){h
19[j]=1;}else x[j]-=r;}else x[j]+=r;}else{y[j]++;h[j]++;}if(!--h[j])y[j]=R(1,X,Y+
20240,1,0,11);}}}for(i=0;i<320;i+=2)if(!R(0,i,238,0,0,0))break;if(i==320)blit(buf
21,buf,0,240,0,241,320,238);if(y[0]>240)o=1;T(10,7,"%i SEC",120-t/60);if(t==7200)
22{l++;if(l==11){z=o=1;}else goto A;}R:if(z)T(40,13,"YOU WIN",0);else T(1,15,
23"WAVE %i/10",l);if(o)T(110,12,"GAME OVER",0);if(s){T(80,11,"ICE JUNK",0);}if(s|
24o)T(160,10,"PRESS ESC KEY",0);blit(buf,screen,0,0,0,0,320,240);ot=t;while(t==ot
25)yield_timeslice();}if(s|o){s=o;o=0;goto A;}return 0;}END_OF_MAIN()/*ICE JUNK*/

And here's my breakout clone from the 20 line thread, which also qualifies here, and compiles without warnings and also gcc < 3.x:

#include <allegro.h>
volatile int i,t=0,b=320,f=0,p[]={0,160,320},d[]={0,-1,1,0,0,0};void timer(void)
{t++;}int main(void){if(!(allegro_init()||set_gfx_mode(GFX_AUTODETECT,640,480,0,
0)||install_timer()||install_int_ex(timer,BPS_TO_TIMER(100))||!install_mouse()))
{clear(screen);for(i=0;i<480;i++)rectfill(screen,(i%40)*16,(i/40)*16,(i%40)*16+
14,(i/40)*16+14,makecol(200,200,0));rest(4000);t=0;while(p[1]<400)if(f<t){for(i=
0;i<6;i+=2){if(i!=2)circlefill(screen,p[2],p[1],4,i?makecol(100,100,255):0);if(i
<4)p[i+!i]+=d[i+!i];if(i<4&&getpixel(screen,p[2]+d<i>*5,p[1]+d[i+1]*5)){rectfill
(screen,(p[2]+d<i>*5)&~15,(p[1]+d[i+1]*5)&~15,(p[2]+d<i>*5)|15,(p[1]+d[i+1]*5)|
15,0);d[i+!i]=-d[i+!i];p[i+!i]+=d[i+!i];}if(i)rectfill(screen,b-12,320,b+12,327
,i==2?0:makecol(255,0,b/3));if(i==2)b=mouse_x;}f++;}}return 0;}END_OF_MAIN();

tareco
1#include <allegro.h>
2volatile int sc=0;int gl=0,dx,dy,dd,rl,points=0,lives=2;fixed x,y,ang;void
3sc_add(){sc++;}int re(int m,int a){return rand()%(a+1-m)+m;}void iv(){rl=0;x=
4itofix(re(10,310));y=itofix(re(10,230));dx=re(20,300);dy=re(20,180);dd=re(5,15);
5ang=itofix(re(0,255));}void main(){BITMAP *d;allegro_init();install_keyboard();
6install_timer();set_gfx_mode(GFX_AUTODETECT,320,240,0,0);install_int_ex(sc_add,
7BPS_TO_TIMER(60));d=create_bitmap(320,240);ang=itofix(0);srand(time(0));start:
8text_mode(-1);while(!key[KEY_ENTER]){if(key[KEY_ESC]){fade_out(10);allegro_exit(
9);exit(0);}clear_to_color(d,191);textprintf_centre(d,font,162,122,16,"MiniGolf")
10;textprintf_centre(d,font,160,120,255,"MiniGolf");textprintf_right(d,font,320,
11230,255,"Hiscore: %d",get_config_int("hs","s",20));draw_sprite(screen,d,0,0);}iv
12();gl=0;while(1){while(sc>0){if(key[KEY_ESC]){goto start;}if(!rl){if(key[
13KEY_LEFT]){if(key[KEY_RSHIFT]){ang-=ftofix(0.25);}else{ang-=itofix(1.5);}}if(key
14[KEY_RIGHT]){if(key[KEY_RSHIFT]){ang+=ftofix(0.25);}else{ang+=itofix(1.5);}}if(
15key[KEY_SPACE]){rl=1;}}else{x+=fmul(itofix(2),fcos(ang));y+=fmul(itofix(2),fsin(
16ang));if(fixtoi(x)>=dx-dd/2&&fixtoi(x)<=dx+dd/2&&fixtoi(y)>=dy-dd/2&&fixtoi(y)<=
17dy+dd/2){iv();points+=10;gl++;}if(fixtoi(x)<-5||fixtoi(y)<-5||fixtoi(x)>325||
18fixtoi(y)>245){iv();lives--;if(lives==-1){if(points>get_config_int("hs","s",0)){
19set_config_int("hs","s",points);}lives=2;points=0;goto start;}}}if(gl==10){lives
20++;gl=0;}sc--;}clear_to_color(d,191);circlefill(d,dx,dy,dd,16);if(!rl){line(d,
21fixtoi(x),fixtoi(y),fixtoi(x+30*fcos(ang)),fixtoi(y+30*fsin(ang)),104);}
22circlefill(d,fixtoi(x),fixtoi(y),4,255);textprintf(d,font,0,230,255,
23"Lives: %d Points: %d",lives,points);draw_sprite(screen,d,0,0);}}END_OF_MAIN();

MiniGolf! Well, sorta :)

Niunio

Can I use external files (samples, MIDIs, DAT...)?

I'm writing one, may be I finish it this night.

james_lohr

You're all crazy...

Rash
SonShadowCat

grumbles

Billybob

I worked for a whole trying to squeeze my code into 80x25. Thanks to X-Viila, Marcello, and many others on #allegro I got it sized right.

I worked in MSVC, so I'm not sure if this compiles under GCC, although it should with minimal change.
The MSVC project was a Win32 Console App, using the required AGL libraries in the linking and USE_CONSOLE defined in preproccessors.

This is a simple game. Arrow keys move you around in the random map. You have to collect the yellow thingies. The Blue Block Ghosts will try to eat you, so you have to avoid those. If they do touch you, you lose all your points. Ghosts can go through walls and teleport at edges so becareful. Enjoy! Also, if you can't move at the beginning, restart the program(random maps).

1#include <alleggl.h>
2#include <math.h>
3#define I(a,b) for(b=0;b<a;b++)
4#define R(a,b) V(D<i>.x+a,b,-(D<i>.y+P));
5typedef int N;void A(N a,N b){allegro_gl_set(a,b);}void V(float a,float b,float
6c){glVertex3f(a,b,c);}struct{unsigned x,y;}D[3];N M[10][10],C=1200,S=0,i,v=0,y,r
7;float X=5,Z=-5,Y,n,l,O,P=.5,Q=.75;volatile N T=0;void F(){T++;}void main(){all\
8egro_init();install_allegro_gl();install_keyboard();A(1024,1);A(131072,1);A(-1,
9140320);set_gfx_mode(GFX_OPENGL_WINDOWED,800,600,0,0);glEnable(2929);glMatrixMo\
10de(5889);glFrustum(-.09,.09,-.07,.07,.1,300);glMatrixMode(5888);install_int(F,17
11);srand(time(0));I(100,i)M[i%10][i/10]=1;I(85,i)M[rand()%8+1][rand()%8+1]=0;I(3,
12i)D<i>.x=D<i>.y=rand()%10;while(!key[59]){while(T){v-=!!v;T--;C++;n=X;l=Z;Y-=key
13[83]*3;Y+=key[82]*3;X-=sin(O=Y*.0174)*.05*key[84];Z+=cos(O)*.05*key[84];X+=sin(O
14)*.05*key[85];Z-=cos(O)*.05*key[85];if(M[(N)X][(N)-Z]==1){X=n;Z=l;}if(M[(N)X][(N
15)-Z]==2){S++;M[(N)X][(N)-Z]=0;}if(C>1200){I(100,i){if(M[r=i%10][i/10]>1)M[r][i/
1610]=0;if(!M[r][i/10])M[r][i/10]=rand()&1+1;}C=0;}if(!(C%60))I(3,i){D<i>.x=(D<i>.
17x+(rand()%3-1))%10;D<i>.y=(D<i>.y+(rand()%3-1))%10;}I(3,i){if(D<i>.x==(N)X&&D<i>
18.y==-(N)Z&&!v){allegro_message("GHOST! Score: %i",S);S=T=0;v=120;}}}glLoadIdent\
19ity();glClear(16640);glRotatef(Y,0,1,0);glTranslatef(-X,-P,-Z);glBegin(7);I(10,y
20)I(10,i){if(M<i>[y]==1){glColor3f(P,P,P);y=-y-1;V(i+1,0,y);V(i+1,1,y);V(i,1,y);V
21(i,0,y);y=y+1;V(i+1,0,y);V(i+1,1,y);V(i,1,y);V(i,0,y);y=-y;V(i+1,0,-y-1);V(i+1,1
22,-y-1);V(i+1,1,-y);V(i+1,0,-y);V(i,0,-y-1);V(i,1,-y-1);V(i,1,-y);V(i,0,-y);}if(M
23<i>[y]==2){glColor3f(P,P,0);V(i+P,Q,-y-P);V(i+Q,O=.25,-y-Q);V(i+O,O,-y-O);V(i+Q,
24O,-y-O);}}I(3,i){glColor3f(0,0,1);R(0,0)R(O,2)R(Q,2)R(1,0)}glEnd();allegro_gl_f\
25lip();}}END_OF_MAIN()

http://www.cljy.com/~billy/80_25_chase_pic.PNG
EDIT_FINAL: Updated entire post.
EDIT: Code updated to latest version.

Krzysztof Kluczek

Well, I have just finished very similar game, but without enemies and running without AGL on my own ray-trace engine. I wanted to add some enemies (red circles) and player ability to shoot them (using smaller green circles for instance), but it won`t fit in 80x25. As a result, circle particle system is incorporated into engine and used for displaying coins.

Your task here is to collect all gold coins left in the dungeon of the castle Bartenstein and avoid pits. Use arrow keys to move and ESC to exit. You are equipped with gold-coin-counter(TM) and a compass. The game is quite hard to beat, so good luck! :)
(there really are 150 coins and all of them are accessible, really :) )

The code was developed under DJGPP and it generates a bunch of double->int conversion warnings, which can make compilation under other compilers harder. If you are forced to make some modifications in the source, make sure to replace the modified source with the original one before running the game, because otherwise some of the coins can be unaccessible (the game uses it`s source code, which is also prepared to act as a map).

btw. this castle really existed in my home city, but I don`t think there were gold coins, pits and fancy-painted floors. :)

1#include <allegro.h>/* Bartenstein 3D! by Krzysztof Kluczek (c) 2004 */
2#include <math.h>/*-- A complete 3D engine on one 80x25 screen */
3typedef int i;i x,y,n,l,Q=0,j[90][90],s;char m[90][90]={},*g=(char*)m,*h=g,*k=g
4,*p=g+1,c;float b,u,v,a,d,z[320],A=0,X=1.5,Y=1.5,q[999][9]={},*t;BITMAP*w;RGB r;
5void cl(){ d=atan((x-160)/200.);u=cos(A+d);v=sin(A+d);b=50/cos(d)+10;for(l=y=1\
600;y>0;){c=y>9?m[i(b/y*u+X)][i(b/y*v+Y)]+2*(y&~3):0;c++&7?c&7?vline(w,x,99+y,99+
7l,c),0:0,putpixel(w,x,100-y,c),0:(z[x]=b/y,vline(w,x,99+l,100-y,c),y=0);y--;l=c&
87?y:l;}}void sq(){u=cos( A);v=sin(A);for(l=0;l<Q;l++)t=q[l],a=t[2]-X,b=t[3]-Y,t[
90]=a*u+b*v,t[1]=b*u-a*v;u=1E9;while(1){v=0;for(x=0;x<Q;x++)a=q[x][0],v<a&&a<u?l=
10x,v=a:0;if(v<.1)break;u=v;t=q[l];d=160+200*t[1]/t[0];a=16/t[0];for(n=-a;x=d+n,n\
11<=a;n++)if(x>=0&&x<320&&z[x]>t[0]+.3)y=sqrt(a*a-n*n),vline(w,x,100-y,100+y,251-8
12*i(t[0]*4));}}i cc(){d=0.4;return m[i(X-d)][i(Y-d)]&&m[i(X-d)][i(Y+d)]&&m[i(X+d)
13][i(Y-d)]&&m[i(X+d)][i(Y+d)];}void mv(){X+=(u=a*cos(A));if(!cc())X-=u;Y+=(v=a*s\
14in(A));if(!cc())Y-=v;}i main(){allegro_init();install_keyboard();set_gfx_mode(G\
15FX_VGA,320,200,0,0);w=create_bitmap(320,200);PACKFILE *f=pack_fopen(__FILE__ ,\
16"r");while(pack_fgets(p+=90,88,f));pack_fclose(f);for(;g<h+8100;g++)(*g&=7)==2?j
17[i(q[Q][2]=(g-k)/90+.5)][i(q[Q][3]=(g-k)%90+.5)]=Q++:0;for(y=0;y<256;y++){x=y/4;
18r.r=y&1?x:0;r.g=y&2?x:0;r.b=y&4?x:0;set_color(y,&r);} s=Q;while(s&&!key[KEY_ESC]
19){g=m[i(X)]+i(Y);if(*g==7){for(y=198;y+1;y--){if(!(y%30))vsync();blit(screen,sc\
20reen,0,y+1,0,y,320,1);}for(;y<50;y++)vsync();break;}if(*g==2){*g=3;s--;q[j[i(X)]
21[i(Y)]][2]=-9;}for(x=0;x<320;x++)cl();sq();a=0.07;if(key[KEY_LEFT])A-=a;if(key[\
22KEY_RIGHT])A+=a;if(key[KEY_UP])mv();if(key[KEY_DOWN]){a=-a;mv();}u=300;v=20;line
23(w,u,v,u+9*cos(A),v+9*sin(A),254);putpixel(w,u,v,255);textprintf(w,font,0,0,255,
24"%d",s);vsync();blit(w,screen,0,0,0,0,320,200);}clear(screen);textout(screen,fo\
25nt,s?"Game Over":"You win!",124,96,255);while(!key[KEY_ESC]);}END_OF_MAIN();/**/

I think somebody better in english than me should write a news on Allegro.cc about this contest - some people may not visit the off-topic forum but may be interested in it.

Thomas Fjellstrom

Krzysztof: Unfortunetly it crashed under linux.. maybe youve got a memory bug lurking in there somewhere?

Krzysztof Kluczek

Thanks for the info. :) I`ll check this tomorrow. It`s 5:26 am in my time zone now. :P

btw. Does entries with unclean exit count? Mine have one destroy_bitmap() missed. :P

Marcello

Here is will's code in 25 lines...

1#include <alleggl.h>
2#include <math.h>
3#define I(a) for(i=0;i<a;i++)
4#define A(a,b) allegro_gl_set((a),(b));
5#define V(a,b,c) glVertex3f((a),(b),(c));
6#define R(a,b) V(D<i>.x+a,b,-(D<i>.y+.5))
7struct{unsigned x,y;}D[3];volatile int T=0;float X=5,Z=-5,Y,w,z,O,P;int M[10][10
8],g=1200,S=0,i,v=0;void F(){T++;}int main(){allegro_init();install_allegro_gl();
9install_keyboard();A(1024,1)A(8192,32)A(131072,1)A(-1,140320)set_gfx_mode(
100x4F474C57,800,600,0,0);glEnable(2929);glMatrixMode(5889);glFrustum(-.09,.09,
11-.07,.07,.1,300);glMatrixMode(5888);install_int(F,17);srand(time(0));I(100)M[i%
1210][i/10]=1;I(85)M[rand()%8+1][rand()%8+1]=0;I(3)D<i>.x=D<i>.y=rand()%10;while(!
13key[59]){while(T){v-=!!v;T--;g++;w=X;z=Z;Y-=key[83]*3;Y+=key[82]*3;X+=sin(O=Y*
14.0174)*(P=-.05*key[84]);Z-=cos(O)*P;X+=sin(O)*.05*key[85];Z-=cos(O)*.05*key[85];
15if(M[(int)X][(int)-Z]==1)X=w,Z=z;if(M[(int)X][(int)-Z]==2)S++,M[(int)X][(int)-Z]
16=0,printf("Score:%i\n",S);if(g>1200){I(100){if(M[i%10][i/10]>1)M[i%10][i/10]=0;
17if(!M[i%10][i/10])M[i%10][i/10]=rand()&1+1;}g=0;}if(!(g%60))I(3){D<i>.x=(D<i>.x+
18(rand()%3-1))%10;D<i>.y=(D<i>.y+(rand()%3-1))%10;}I(3)if(D<i>.x==(int)X&&D<i>.y
19==-(int)Z&&!v)S=0,v=120,printf("\a");}glLoadIdentity();glClear(16640);glRotatef(
20Y,0,1,0);glTranslatef(-X,-.5,-Z);glBegin(7);for(int y=0;y<10;y++)I(10){P=.5;if(M
21<i>[y]==1){glColor3f(P,P,P);y=-y-1;V(i+1,0,y)V(i+1,1,y)V(i,1,y)V(i,0,y)y=y+1;V(i
22+1,0,y)V(i+1,1,y)V(i,1,y)V(i,0,y)y=-y;V(i+1,0,-y-1)V(i+1,1,-y-1)V(i+1,1,-y)V(i+1
23,0,-y)V(i,0,-y-1)V(i,1,-y-1)V(i,1,-y)V(i,0,-y)}if(M<i>[y]==2){glColor3f(P,P,0);V
24(i+P,.75,-y-P)V(i+.75,O=.25,-y-.75)V(i+O,O,-y-O)V(i+.75,O,-y-O)}}I(3){glColor3f(
250,0,1);R(0,0)R(O,2)R(.75,2)R(1,0)}glEnd();allegro_gl_flip();}}END_OF_MAIN()

Marcello

Zaphos

Marcello: I still needed to #include <stdio.h> on that one, so it was 26 lines :(
Krzysztof Kluczek: Runs for me -- quite cool :)
Minigolf is kinda silly ... Elias's new entry is an interesting concept ...

Niunio

Here you have my entry. It's the first time I've finished an entry for an Allegro anythingHack and I'm very happy!:)

I've hacked some ideas from Tobias' entry (Hey, this is a Hack competition, isn't it?;))

It is the classic cannon game, where the two players are at opposite sides of a mountain/wall and shoots one against the other. Both players uses the same controls:
[list][*]Up/down cursors: change the shoot angle.
[*]Left/right cursors: change the shoot distance.
[*]Space: shoot.
[*]Esc: get out.
[/list]
Here you have the source (it do not need more headers since the rand, srand & time functions use and return integers, so they don't need prototipes, just as K&R said:P[edit]Or Allegro includes it for me????[/edit]):
[edit2]I've attached a Win32 binary if you can't compile it[/edit2]

#SelectExpand
1#include<allegro.h> /* CAÑÓN: Ñuño's ScreenHack 2004 entry (c)2004. Is GPL. */ 2typedef int i;typedef float f;typedef void v;i x1,y1,a1,f1,x2,y2,a2,f2,k;BITMAP* 3s;v bp(c){clear_to_color(s,c);}gk(v){return readkey()>>8;}v kb(v){clear_keybuf() 4;}rn(x){return rand()%x;}f cx(a,l){return(fixcos(a<<16)*l)>>16;}f cy(a,l){return 5(fixsin(a<<16)*l)>>16;}v ct(char*S,i y,i c){textout_centre(s,font,S,160,y,c);}ui 6(i*x,i*y,i*a,i*F,i p){i r,h;f bx,by,vx,vy;circle(s,*x,210,10,15);line(s,*x,210,* 7x+cx(*a,8),210+cy(*a,8),7);rectfill(s,*x-25,230,*x+25,235,15);rectfill(s,*x-25, 8230,*x-25+(*F/2),235,7);kb();while((k=gk())!=59&&k!=75){*F+=((k==83)-(k==82));if 9(*F<0)*F=0;if(*F>100)*F=100;rectfill(s,*x-25,230,*x+25,235,15);rectfill(s,*x-25, 10230,*x-25+(*F/2),235,7);line(s,*x,210,*x+cx(*a,8),210+cy(*a,8),10);*a=(*a+(((k== 1185)-(k==84))*p))&0xFFFFFL;line(s,*x,210,*x+cx(*a,8),210+cy(*a,8),7);}if(k==75){ 12by=*y-2+(vy=cy(*a,*F/10));bx=*x+(vx=cx(*a,*F/10));while(getpixel(s,bx+2,by+2)== 1311&&getpixel(s,bx-1,by+2)==11){if((bx+=(vx*=.99))<0||bx>318)return 0;if((by+=vy 14+=.2)>238)return 0;rectfill(s,bx,by,bx+1,by+1,15);rest(100);rectfill(s,bx,by,bx+ 151,by+1,11);}for(h=r=0;r<15;r++){circlefill(s,bx,by,r,12);h=(getpixel(s,x1,y1)== 1612||getpixel(s,x2,y2)==12);rest(100);}for(r=0;r<15;r++){circlefill(s,bx,by,r,11) 17;rest(100);}return h;}return k==59;}main(v){set_uformat(U_ASCII);allegro_init(); 18install_timer();install_keyboard();if(set_gfx_mode(GFX_SAFE,320,240,0,0)<0) 19return-1;s=screen;for(;;){bp(0);ct("CAÑÓN",100,2);ct("SPACE or ESC",120,15);ct( 20"(c)Ñuño,2004",220,9);kb();while((k=gk())!=59&&k!=75);if(k==59)return 0;srand( 21time(0));bp(11);rectfill(s,0,180,320,240,10);ellipsefill(s,160,180,rn(50)+20,rn( 22120)+30,10);x2=320-(x1=rn(50)+10);y1=y2=178;a1=f1=f2=0;a2=128;line(s,x1-1,y1+1, 23x1+1,y1-1,7);putpixel(s,x1+1,y1+1,7);line(s,x2+1,y2+1,x2-1,y2-1,7);putpixel(s,x2 24-1,y2+1,7);for(;;){if(ui(&x1,&y1,&a1,&f1,1))break;if(ui(&x2,&y2,&a2,&f2,-1)) 25break;}rest(1500);}return 0;}END_OF_MAIN(); /* I did it! */

8-);D

This other is the uncompressed and commented version. It's exactly the same than the previous one, but it is indented and full of comments (more than 100 lines:o... How I'd put them in only 25? ???)

#SelectExpand
1/* CAÑÓN: Ñuño's ScreenHack 2004 entry (c)2004. Is GPL. */ 2 3/* This is the 'uncompressed' commented version. */ 4 5#include<allegro.h> /* I'll use the Allegro library only. */ 6 7/* No more headers needed. The std functions used (rand, srand & time) 8 uses and return integer, so they don't need prototipes. */ 9 10/* Some typedefs. This is to reduce the number of characters needed. */ 11typedef int i; 12typedef float f; 13typedef void v; 14 15i x1, y1, a1, f1, /* Position, angle and 'force' of player one. */ 16 x2, y2, a2, f2; /* Position, angle and 'force' of player two. */ 17BITMAP* s; /* Alias for screen. Only one character! */ 18 19/* Next functions are used often, so it reduces the number of characters. */ 20 21/* bp: 22 * Clear screen. (from 'borrar pantalla', in Spanish. */ 23v bp (c) 24{ 25 clear_to_color(s,c); 26} 27 28/* gk: 29 * Get a key as scan code. */ 30gk (v) 31{ 32 return readkey()>>8; 33} 34 35/* Clean the keyboard buffer. */ 36v kb(v) 37{ 38 clear_keybuf(); 39} 40 41/* rn: 42 * Generates a random number. */ 43rn (x) 44{ 45 return rand()%x; 46} 47 48/* cx: 49 * cy: 50 * Calculates the cartesian factor for the given vector (angle and length). */ 51f cx (a, l) 52{ 53 return (fixcos (a<<16) * l)>>16; 54} 55 56f cy (a, l) 57{ 58 return (fixsin (a<<16) * l)>>16; 59} 60 61/* ct: 62 * Writes a centered text. */ 63v ct (char *S, i y, i c) 64{ 65 textout_centre (s, font, S, 160, y, c); 66} 67 68/* ui: 69 * User input and his response. Returns TRUE if the game finishes or FALSE if 70 * game continues. */ 71ui (i *x, i *y, i *a, i *F, i p) 72{ 73 i k=0, r, h; /* Key, explosion radius and hit flag. */ 74 f bx, by, vx, vy; /* Bullet position and velocity. */ 75 76/* References circle for the angle. */ 77 circle (s, *x, 210, 10, 15); 78 line (s, *x, 210, *x+cx(*a,8), 210+cy(*a,8), 7); 79 rectfill (s, *x-25, 230, *x+25, 235, 15); 80 rectfill (s, *x-25, 230, *x-25+(*F/2), 235, 7); 81/* Process user input. */ 82 kb (); 83 while ((k=gk())!=59&&k!=75) { /* KEY_ESC = 59. KEY_SPACE = 75.*/ 84 /* 'Force'. (I learnt the key input in old MSX games. 8^) */ 85 *F += ((k==83)-(k==82)); /* KEY_LEFT = 82. KEY_RIGHT = 83. */ 86 if (*F < 0) 87 *F = 0; 88 if (*F>100) 89 *F = 100; 90 /* Draw the 'Force'. */ 91 rectfill (s, *x-25, 230, *x+25, 235, 15); 92 rectfill (s, *x-25, 230, *x-25+(*F/2), 235, 7); 93 /* Angle. First, erase the arrow. */ 94 line (s, *x, 210, *x+cx(*a,8), 210+cy(*a,8), 10); 95 *a = (*a + (((k==85) - (k==84)) * p))&0xFFFFFL; /* KEY_UP = 84. KEY_DOWN = 85. */ 96 /* Draw the arrow. */ 97 line (s, *x, 210, *x+cx(*a,8), 210+cy(*a,8), 7); 98 } 99/* If shoot: */ 100 if(k==75) { /* KEY_SPACE = 75. */ 101 /* Setup the bullet state. */ 102 by = *y - 2 + (vy=cy(*a,*F/10)); 103 bx = *x + (vx=cx(*a,*F/10)); 104 /* Animate, while the bullet is on the air. */ 105 while (getpixel (s, bx+2, by+2)==11 && getpixel (s, bx-1, by+2)==11) { 106 /* Moves the bullet and check if it goes out the screen. */ 107 if ((bx+=(vx*=.99))<0 || bx>318) /* The '.99' is the Gravity factor. */ 108 return 0; 109 if ((by+=vy+=.2)>238) /* The '.2' is the Gravity factor. */ 110 return 0; 111 /* Animation. */ 112 rectfill (s, bx, by, bx+1, by+1, 15); 113 rest (100); 114 rectfill (s, bx, by, bx+1, by+1, 11); 115 } 116 /* Explosion. */ 117 for (h=r=0; r<15; r++) { 118 circlefill (s, bx, by, r, 12); 119 h = (getpixel (s, x1, y1)==12 || getpixel (s, x2, y2)==12); 120 rest (100); 121 } 122 for (r=0; r<15; r++) { 123 circlefill (s, bx, by, r, 11); 124 rest (100); 125 } 126 return h; 127 } 128 return k == 59; /* KEY_ESC = 59. */ 129} 130 131/* main: 132 * The main function and loop. */ 133main(v) { 134/* Game startup. */ 135 set_uformat (U_ASCII); allegro_init (); install_timer (); install_keyboard (); 136 if (set_gfx_mode (GFX_SAFE, 320, 240, 0, 0)<0) 137 return -1; 138 s=screen; 139/* Main loop. */ 140 for(;;) { 141 i k=0; /* The key. */ 142 143 /* A kind of introduction. It has, also, the main menu. */ 144 bp (0); 145 ct ("TANK", 100, 2); 146 ct ("SPACE or ESC", 120, 15); 147 ct ("(c)Ñuño,2004", 220, 9); 148 kb (); 149 /* Get the key and chek it. */ 150 while ((k=gk())!=59&&k!=75); /* KEY_ESC = 59. KEY_SPACE = 75.*/ 151 if (k==59) /* KEY_ESC = 59 */ 152 return 0; 153 srand (time (0)); 154 /* Draw the scenary. */ 155 bp (11); 156 rectfill (s, 0, 180, 320, 240, 10); 157 ellipsefill (s, 160, 180, rn(50)+20, rn(120)+30, 10); 158 /* Set and draw thanks. */ 159 x2 = 320 - (x1=rn(50)+10); 160 y1 = y2 = 178; 161 a1 = f1 = f2 = 0; a2=128; 162 line (s, x1-1, y1+1, x1+1, y1-1, 7); putpixel (s, x1+1, y1+1, 7); 163 line (s, x2+1, y2+1, x2-1, y2-1, 7); putpixel (s, x2-1, y2+1, 7); 164 /* Game loop. */ 165 for (;;) { 166 if (ui (&x1, &y1, &a1, &f1, 1)) 167 break; 168 if (ui (&x2, &y2, &a2, &f2, -1)) 169 break; 170 } 171 /* Pause, to see the screen. */ 172 rest(1500); 173 } 174 return 0; 175} 176END_OF_MAIN(); /* Needed by Allegro. */

BTW, I've seen that someones did a 3D demo. They're cool.

If anybody is interested, my [url http://www.burdjia.com/descarga/libreria/M3D/]UnOptimised Voxel Landscape Renderer (UOVLR.zip)[/url] has only 17 executable lines, and I think it would be packed in 6 or less lines of 80 characters whide (changing some variable names, of course;)). Today, I'm too lazy, but if anybody wants a small landscape renderer for his entry...::)

Ryan Broomfield

http://www.shippysite.com/screen.gif

Did mine in 22 lines :D It's a clone of Kaboom! and it has little bomb explosions, lighted fuses, etc. It's pretty fun :)

*UPDATE - my code is also the smallest 80x25 entry at a mere 1699 bytes :)

CONTROLS: USE THE MOUSE TO CATCH THE BOMBS, THE GAME PICKS UP THE PACE THE LONGER YOU PLAY. IF A BOMB PASSES, YOU LOSE A PLATFORM. WHEN ALL 3 PLATFORMS ARE GONE, GAME OVER!
**********

1#include <allegro.h>
2struct B{int x,u;double y;}z[150];main(int d,char**b){memset(z,0,sizeof(struct B
3)*150);double q=160,bm=.5;int s=0,r=200,Q=60,C=30,P=160,p=3,f=0;allegro_init();
4install_keyboard();install_mouse();set_gfx_mode(GFX_AUTODETECT,320,200,0,0);
5rectfill(screen,0,0,319,199,0);textprintf(screen,font,0,100,15,"BLIGGITY BLAM! H
6IT SPACE!");while(key[KEY_SPACE]){} while(!key[KEY_SPACE]){}while(!key[KEY_ESC])
7{rectfill(screen,0,0,319,40,10);rectfill(screen,0,40,319,199,9);textprintf(
8screen,font,0,0,15,"%i",s);if((int)q<r-bm) q+=bm;else if((int)q>r+bm)q-=bm;else
9r=rand()%320;bm+=.0005;Q=(int)((double)(60/bm));rectfill(screen,q-6,12,q+6,36,0)
10;circlefill(screen,q,16,8,15);circlefill(screen,q-3,16,2,0);circlefill(screen,q+
113,16,2,0);rectfill(screen,q-10,8,q+10,12,0);rectfill(screen,q-5,4,q+5,8,0);for(d
12=0;d<p;++d)rectfill(screen,P-10,175-(d*10),P+9,180-(d*10),15);P=mouse_x;if(P<10)
13P=10;if(P>310) P=310;for(d=0;d<150;++d){if(z[d].u>0){z[d].y+=bm/2;circlefill(
14screen,z[d].x,z[d].y,4,0);circle(screen,z[d].x,z[d].y,4,15);line(screen,z[d].x+3
15,z[d].y-3,z[d].x+5,z[d].y-5,15);line(screen,z[d].x+5,z[d].y-5,z[d].x+5+((rand()%
164)-2),z[d].y-5+((rand()%4)-2),14);if(z[d].y>199){z[d].u=0;--p;q=160;bm=.5;r=200;
17Q=60;C=30;f=0;P=160;memset(z,0,sizeof(struct B)*150);}else if(z[d].y>=178-p*10&&
18z[d].y<=182&&z[d].x>=P-12&&z[d].x<=P+12){z[d].u=-5;s+=50;}}else{if(z[d].u<0){
19circlefill(screen,z[d].x,z[d].y,-z[d].u,12);++z[d].u;}else if(f>=Q+C){z[d].u=1;z
20[d].x=q;z[d].y=16;f=0;C=rand()%Q;}}}if(p<1)break;vsync();++f;}rectfill(screen,0,
210,319,199,0);textprintf(screen,font,0,100,15,"FINAL SCORE: %i.PRESS ESC!",s);
22while(key[KEY_ESC]){}while(!key[KEY_ESC]){}}END_OF_MAIN()

GullRaDriel

Krzysztof Kluczek, either your source code is buggy and cannot be compiled or i am a donkey using gcc, but i can't be able to compile it, even when i turn off all access checking and warning.

After testing all source code except allegro gl and Krzysztof one, i give my voice to Ryan game.

23yrold3yrold
Quote:

It's a clone of Kablam!

I think you mean "Kaboom!" ...

Ryan Broomfield

yeah, kaboom. My bad :D

Krzysztof Kluczek

Strange, I compiled it under Linux Slackware 9 without problems and got it running smoothly.

Here is my "makefile" (providing test.cpp is a source file):

#! /bin/sh
g++ `allegro-config --cflags` -c test.cpp
g++ -o test test.o -lalleg -lpthread -s -lm -ldl -export-dynamic

I tried other ways to compile it and yes, I didn`t manage to compile it using Linux gcc and I tried both .c and .cpp extensions.

I guess, the reason it may crash is using GFX_VGA 320x200 8-bit mode. I guess it isn`t using SVGA-Lib under Linux, so it might have failed on some systems (I was running as a root on my system since I was too lazy to configure Allegro properly and X-Windows aren`t properly set on my system). Since game has no failure checks, it can crash this way.

Also I don`t know, if all compilers will understand definition of m[90][90]={} and clear entire array at startup, since I don`t know if such behavior is ANSI standard.

Well, if the reason is GFX_VGA, I`ll try to switch to GFX_AUTODETECT and 320x240x8, so it should run.

And thanks everybody for opinions and testing. :)

Thomas Fjellstrom

Krzysztof: the X11 driver is default on my system, modes that the XWFS driver (does full screen X11 modes) can't handle get done by the XWIN driver (does windowed X11 modes).
and heres how I compiled: g++ file.cpp -o file `allegro-config --libs`. That resulted in an instant crash when run. (SIGSEGV)

edit: ouch, yeah, not checking set_gfx_mode for failure will result in a nice crash... maybe set to GFX_AUTODETECT...

Krzysztof Kluczek
Quote:

ouch, yeah, not checking set_gfx_mode for failure will result in a nice crash...

Especially when using GFX_VGA, which is described in help as a DOS/Linux console mode and probably isn`t supposed to run under X. :P

Ok, I squeezed pit-falling routine a bit and managed to insert GFX_AUTODETECT. It should run now.

Of course the level has also changed a bit, but there are still 150 coins and all of them are available.

1#include <allegro.h>/* Bartenstein 3D! by Krzysztof Kluczek (c) 2004 */
2#include <math.h>/*-- A complete 3D engine on one 80x25 screen */
3typedef int i;i x,y,n,l,Q=0,j[90][90],s;char m[90][90]={},*g=(char*)m,*h=g,*k=g
4,*p=g+1,c;float b,u,v,a,d,z[320],A=0,X=1.5,Y=1.5,q[999][9]={},*t;BITMAP*w;RGB r;
5void cl(){d=atan((x-160)/200.);u=cos(A+d);v=sin(A+d);b=50/cos(d)+10;for(l=y=100;
6y>0;){c=y>9?m[i(b/y*u+X)][i(b/y*v+Y)]+2*(y&~3):0;c++&7?c&7?vline(w,x,99+y,99+l,c
7),0:0,putpixel(w,x,100-y,c),0:(z[x]=b/y,vline(w,x,99+l,100-y,c),y=0);y--;l=c&7?y
8:l;}}void sq(){u=cos( A);v=sin(A);for(l=0;l<Q;l++)t=q[l],a=t[2]-X,b=t[3]-Y,t[0]=
9a*u+b*v,t[1]=b*u-a*v;u=1E9;while(1){v=0;for(x=0;x<Q;x++)a=q[x][0],v<a&&a<u?l=x,v
10=a:0;if(v<.1)break;u=v;t=q[l];d=160+200*t[1]/t[0];a=16/t[0];for(n=-a;x=d+n,n<=a;
11n++)if(x>=0&&x<320&&z[x]>t[0]+.3)y=sqrt(a*a-n*n),vline(w,x,99-y,100+y,251-8*i(t[
120]*4));}}i cc(){d=0.4;return m[i(X-d)][i(Y-d)]&&m[i(X-d)][i(Y+d)]&&m[i(X+d)][i(Y
13-d)]&&m[i(X+d)][i(Y+d)];}void mv(){X+=(u=a*cos(A));if(!cc())X-=u;Y+=(v=a*sin(A))
14;if(!cc())Y-=v;}i main(){allegro_init();install_keyboard();set_gfx_mode(GFX_AUT\
15ODETECT,320,200,0,0);w=create_bitmap(320,200);PACKFILE *f=pack_fopen(__FILE__,"\
16r");while(pack_fgets(p+=90,88,f));pack_fclose(f);for(;g<h+8100;g++)(*g&=7)==2?j[
17i(q[Q][2]=(g-k)/90+.5)][i(q[Q][3]=(g-k)%90+.5)]=Q++:0;for(y=0;y<256;y++){x=y/4;r
18.r=y&1?x:0;r.g=y&2?x:0;r.b=y&4?x:0;set_color(y,&r);} s=Q;while(s&&!key[KEY_ESC])
19{g=m[i(X)]+i(Y);if(*g==7){for(y=0;y<1740;y++){if(!(y%30))vsync(); blit(w,screen,
200,199,0,199-y,320,1);}break;}if(*g==2){*g=3;s--;q[j[i(X)][i(Y)]][2]=-9;}for(x=0;
21x<320;x++)cl();sq();a=0.07;if(key[KEY_LEFT])A-=a;if(key[KEY_RIGHT])A+=a;if(key[\
22KEY_UP])mv();if(key[KEY_DOWN]){a=-a;mv();}u=300;v=20;line(w,u,v,u+9*cos(A),v+9*\
23sin(A),254);putpixel(w,u,v,255);textprintf(w,font,0,0,255,"%d",s);vsync();blit(w
24,screen,0,0,0,0,320,200);}clear(screen);textout(screen,font,s?"Game Over":"You \
25win!",124,96,255);while(!key[KEY_ESC]);}END_OF_MAIN();/* * * -----------------*/

Thomas Fjellstrom
Quote:

which is described in help as a DOS/Linux console mode and probably isn`t supposed to run under X.

A linux console program "can" be launched from inside X... AFAIK. I just don't have any of the console drivers setup ;)

Krzysztof Kluczek

I don`t think, console drivers would expect the program changing graphics mode to VGA. :P

Anyway, is it running now? :)

Billybob

Ok, I've squeezed my code even more and I was able to make some major improvements! I took some tips from marcello's code(replacing decimal numbers with variables). I replaced a non-portable number with it's proper GFX_OPENGL_WINDOWED. That means this code can now probably run under Linux, although I haven't tested. I'll test as soon as I can for all you Linux people, so expect more news. I also added END_OF_MAIN() for more comptablitiy and the types to a variable and main. The code now compiles under MinGW and MSVC. Attached is the entire package. The source for the 80x25 version, the source for the original source code(before squeezing), the batch file for building under MinGW(probably DJGPP as well), and an already built exe.

I hope this update will allow more people to play my game, especially Linux users, since Linux rules.

CGamesPlay

Ryan: Take out my comments and mine is smaller :)

Billybob

Krzysztof Kluczek: Awesome game. I was able to compile it just fine(MinGW32). Very interesting how you used your own sourcecode as the map, heh. I wouldn't have imagined a raycaster would fit in 80x25, but I guess it does!

Goodbytes

Well, the competition is progressing nicely :)
A clarification to the rules: You can't use external data. Apparently K.K has used his source code as the map? I'll allow that.

My own entry is currently being worked on... i.e. not started yet :)

Krzysztof Kluczek

Well, my program is a bit hacky raycaster since it only draws floors using base/y*cos() and base/y*sin() to determine tile position. If a tile contains a wall the rendering is ended and if it contains a pit rendering floor is delayed. As a result, rendering walls isn`t very much accurate especially at edges (it is possible to look through walls that have one common point, which true raycaster won`t allow).

Pit-falling routine is even more hacky since I`m just copying bottom screen line up the screen using such a speed, that it`s possible to see that something is moving but impossible to see how it is done. :)

And I used source as a map since it`s the easiest way to be sure that all coins can be reached.

I think I`ll start working over my next 80x25 game. Multiple entries are allowed AFAIK. :)

btw. Goodbytes, have you posted a news about this contest on Allegro.cc?

Radagar

Krzysztof Kluczek,

I get all types of Syntax errors when I try to compile your program in MSVC. It complains about a ton of stuff...

Complains about missing semicolons and newlines in constant strings, etc.

Krzysztof Kluczek

Probably MSVC doesn`t understand escapes at the end of some lines (the only explain for unterminated string). Missing semicolons etc. could be results of error recovery after hitting that backslashes. I`ll try to fix that. This program compiles under gcc with only double->int conversion warnings.

(still you could change the file manually and join these escaped lines, just let it read from the old source)

edit: here`s the code without those backslashes:

1#include <allegro.h>/* Bartenstein 3D! by Krzysztof Kluczek (c) 2004 */
2#include <math.h>/*-- A complete 3D engine on one 80x25 screen */
3typedef int i; i x,y,n,l,Q=0,j[90][90],s;char m[90][90]={},*g=(char*)m,*h=g,*k=g
4,*p=g+1,c; float b,u,v,a,d,z[320],A=0,X=1.5,Y=1.5,q[999][9]={},*t;BITMAP*w;RGB r
5;void cl(){d=atan((x -160)/200.);u=cos(A+d);v=sin(A+d);b=50/cos(d)+10;for(l=y=
6100;y>0;){c=y>9?m[i(b/y*u+X)][i(b/y*v+Y)]+2*(y&~3):0;c++&7?c&7?vline(w,x,99+y,99
7+l,c),0:0,putpixel(w,x,100-y,c),0:(z[x]=b/y,vline(w,x,99+l,100-y,c),y=0);y--;l=c
8&7?y:l;}}void sq(){u=cos(A);v= sin(A);for(l=0;l<Q;l++)t=q[l],a=t[2]-X,b=t[3]-Y,t
9[0]=a*u+b*v,t[1]=b*u-a*v;u=1E9;while(1){v=0;for(x=0;x<Q;x++)a=q[x][0],v<a&&a<u?l
10=x,v=a:0;if(v<.1)break;u=v;t=q[l];d=160+200*t[1]/t[0];a=16/t[0];for(n=-a;x=d+n,n
11<=a;n++)if(x>=0&&x<320&&z[x]>t[0]+.3)y=sqrt(a*a-n*n),vline(w,x,99-y,100+y,251-8*
12i(t[0]*4));}}i cc(){d=0.4;return m[i(X-d)][i(Y-d)]&&m[i(X-d)][i(Y+d)]&&m[i(X+d)]
13[i(Y-d)]&&m[i(X+d)][i(Y+d)];}void mv(){X+=(u=a*cos(A));if(!cc())X-=u;Y+=(v=a*sin
14(A));if(!cc())Y-=v;}i main(){allegro_init();install_keyboard();set_gfx_mode(/**/
15GFX_AUTODETECT,320,200,0,0);w=create_bitmap(320,200);PACKFILE *f=pack_fopen(/**/
16__FILE__,"r");while(pack_fgets(p+=90,88,f));pack_fclose(f);for(;g<h+8100;g++)(*g
17&=7)==2?j[i(q[Q][2]=(g-k)/90+.5)][i(q[Q][3]=(g-k)%90+.5)]=Q++:0;for(y=0;y<256 ;y
18++){x=y/4;r.r=y&1?x:0;r.g=y&2?x:0;r.b=y&4?x:0;set_color(y,&r);}s=Q;while(s&&!key
19[KEY_ESC]){g=m[i(X)]+i(Y);if(*g==7){for(y=0;y<1740;y++){if(!(y%30))vsync();blit(
20w,screen,0,199,0,199-y,320,1);}break;}if(*g==2){*g=3;s--;q[j[i(X)][i(Y)]][2]=-9;
21}for(x=0;x<320;x++)cl();sq();a=0.07;if(key[KEY_LEFT])A-=a;if(key[KEY_RIGHT])A+=a
22;if(key[KEY_UP])mv();if(key[KEY_DOWN]){a=-a;mv();}u=300;v=20;line(w,u,v,u+9*cos(
23A),v+9*sin(A),254);putpixel(w,u,v,255);textprintf(w,font,0,0,255,"%d",s);vsync()
24;blit(w,screen,0,0,0,0,320,200);}clear(screen);textout(screen,font,s?"Game Over"
25:"You win!",124,96,255);while(!key[KEY_ESC]);}END_OF_MAIN();//------------------

Billybob

I use backslashes in my most recent code, and that compiled under MSVC & MinGW32...so not sure why your code wouldn't compile.

LSd016

Nothing special.

1#include <allegro.h> /* this be made by lsd */
2#include <mem.h>
3bool IsAround(int x1, int y1, int x2, int y2, int tol)
4{if((x1+tol>x2 && x1-tol<x2) && (y1+tol>y2 && y1-tol<y2)) return true;
5return false;}void main(void)
6{allegro_init();set_color_depth(16);install_keyboard();install_timer();
7install_mouse();
8set_gfx_mode(GFX_AUTODETECT, 640, 480,0,0);alert("Kill the circles",
9"don't let them go off-screen", "'kay?","OK",0,'o',0);
10int posx[16]; int posy[16];
11for(int i=0;i<16;i++){posx<i>=320;posy<i>=240;}int score=0;
12BITMAP *buf=create_bitmap(640,480);while(!key[KEY_ESC]){clear(buf);
13for(int i=0;i<16;i++)
14circle(buf, posx<i>, posy<i>, 8+(rand()%4), makecol(100,rand()%230,rand()%78));
15triangle(buf, mouse_x, mouse_y, mouse_x+10,
16mouse_y, mouse_x, mouse_y+20, makecol(255,0,0));
17textprintf(buf, font, 0,0, makecol(0,255,255),"Score: %d", score);vsync();
18blit(buf, screen, 0,0,0,0,640, 480);for(int i=0;i<16;i++){
19if(posx<i>>640 || posx<i><0 || posy<i>>480 || posy<i><0)
20{alert(0,"Game over, man, game over!",
21"http://inercia.dcc.online.pt/scene.org/parties/1999/antiq99/mmul/gover99.zip",
22"OK",0,'o',0);return;}posx<i>+=(rand()%10)-5;posy<i>+=(rand()%10)-5;}
23if(mouse_b&1)for(int i=0;i<16;i++){
24if(IsAround(posx<i>, posy<i>, mouse_x, mouse_y, 10)){posx<i>=320; posy<i>=240;
25score++;}}}}END_OF_MAIN();

you only need to hold the mouse button, it's better that way.

Freke

LSd016: It complained about the mem.h not being found, but when that include was removed it compiled fine.

Krzysztof Kluczek
Quote:

you only need to hold the mouse button, it's better that way.

Especially if your mouse pointer is in the middle of the screen. I`ve got 5107 that way. :P

I compiled it under DJGPP and it complained about return without a value. I fixed it and everything else is ok. :)

LSd016

Freke: You got a strange compiler, I thought mem* functions had always been in mem.h.

[edit]

Quote:

Especially if your mouse pointer is in the middle of the screen. I`ve got 5107 that way.

But you can't go with this forever. Anyway, maybe I'll make something better tomorrow.

Krzysztof Kluczek

DJGPP libc help says, mem* are in <string.h>
(mem.h still works fine on my compiler)

Ryan Broomfield

http://www.shippysite.com/screen2.gif
YES! I got bliggity blam down to 1337 bytes (would be a little bit less on linux).
OH AND BY THE WYA CGAMESPLAY, my code is now way smaller than yours (without comments) :D

UPDATE I just realized that this game is only 20 lines, so it would qualify for that 20 line compo too.

1#include <allegro.h>
2#define C circlefill(screen
3#define R rectfill(screen
4#define F textprintf(screen,font,0
5struct B{int x,u;double y;}z[150];main(int d,char**b){memset(z,0,sizeof(struct
6B)*150);double q=160,Z=1;int s=0,r=200,Q=40,D=20,P=160,p=3,f=0;allegro_init();
7install_keyboard();install_mouse();set_gfx_mode(GFX_AUTODETECT,320,200,0,0);
8while(!key[KEY_ESC]){R,0,0,319,40,8);R,0,40,319,199,2);F,0,15,"%i",s);if((int)q<
9r-Z)q+=Z;else if((int)q>r+Z)q-=Z;else r=rand()%320;Z+=.0005;Q=(int)((double)(60/
10Z));R,q-6,12,q+6,36,0);C,q,16,8,15);C,q-3,16,2,0);C,q+3,16,2,0);R,q-10,8,q+10,12
11,0);R,q-5,4,q+5,8,0);for(d=0;d<p;++d)R,P-10,175-(d*10),P+9,180-(d*10),15);P=
12mouse_x;if(P<10)P=10;if(P>310)P=310;for(d=0;d<150;++d){if(z[d].u>0){z[d].y+=Z/2;
13C,z[d].x,z[d].y,4,0);line(screen,z[d].x+3,z[d].y-3,z[d].x+5,z[d].y-5,15);line(
14screen,z[d].x+5,z[d].y-5,z[d].x+5+((rand()%4)-2),z[d].y-5+((rand()%4)-2),14);if(
15z[d].y>199){z[d].u=0;--p;q=160;Z=1;r=200;Q=40;D=20;f=0;P=160;memset(z,0,sizeof(
16struct B)*150);}else if(z[d].y>=178-p*10&&z[d].y<=182&&z[d].x>=P-12&&z[d].x<=P+
1712){z[d].u=-5;s+=50;}}else{if(z[d].u<0){C,z[d].x,z[d].y,-z[d].u,12);++z[d].u;}
18else if(f>=Q+D){z[d].u=1;z[d].x=q;z[d].y=16;f=0;D=rand()%Q;}}}if(p<1)break;++f;
19vsync();}F,99,15,"FINAL: %i! PRESS SPACE!",s);while(readkey()>>8!=KEY_SPACE){}}
20END_OF_MAIN()

Carrus85

The only thing I can say, is if you are still running into size problems, couldn't you make your code smaller (on the screen, anyway) by preresolving all of the constants? Also, why not add the comma in your circlefill, rectfill, and text printf functions up above? That way you are only using one comma, instead of one occurance of a comma every function call... (besides, you have tons of room up above by your compiler command things (sorry, can't remember exact term right now, oy...))... heck, you could even through in a semicolon to the beginning of you compiler define, so it looks like...

#define C ;circlefill(screen,

Think of all that wonderful space you are saving! (True, this wouldn't necessaryily work, but it should in theory.)

EDIT--- heck, if compiler defines worked that way, you could do something like

#define db double
#define el else
#define f if (
#define ei else if

but then again, you would be lengthening the program by doing that... too bad you can't stack preprocessor commands...

I'm dumb!... this could get real interesting

gnolam

Carrus: It would work better with macros, but since #defines waste a whole line each I'd use function pointers instead :)

Elias

You don't have to waste a full line with #defines. Just see how I used them, both #defines are about 80 characters.

It worked like this:

#define A(x,y,z) z?long_func_1(x,y):long_func_2(x,y)

Of course, the extra z param wastes some space, but for me I saved quite some lines with it :)

Tobias Dammers

OK, how about an "official" compo? Someone should put up a website with the rules, and some way (e-mail or upload) to submit entries...

Marcello

I think by the time that is done, everyone will be bored of this. Why need an official compo to something that really only takes a few hours?

Marcello

Niunio

Well, I have a lot of things to do (I'm so lazy::)) but if nobody else wants, I can do a 'ScreenHack site'.

It won't be a compo as SpeedHack or TINS or BlithzHack, but it will be a site with lots of multi-platform games that fits in a 25x80 characters screen.

I'll get the better games from this thread and put him in to the site with links to the websites and mails of the authors and compile them in zip files. And I'll put an e-mail so anybody can send me his creations.

[edit]Uh... 'ScreenHack' wouldn't be a cool name for this site, since it will not be a compo.

  • ScreenHack

  • Screen-games

  • MicroGames

  • AlleScreen

  • Micro-screen Games

  • ...

Most of them has a lot of Google/Yahoo/Lycos/Terra entries...
Any other sugestion?
Please?
[/edit]

Billybob

I don't see the problem with naming it screenhack.

Niunio

Well, I was wondering that somebody would confuse the names:

ScreenHack-SpeedHack...

Ok, ok, forget it. The name will be ScreenHack.

I'll start just now.

Ben Jacobs

I actually have no idea if this program works.
I'm at work and I can't build it, I know there aren't any errors though!.

1#include <allegro.h>
2#define maxEnemies 5
3int psRand=1;
4class enemy{public:int x,y;};
5int main(void){
6allegro_init();install_keyboard();
7set_color_depth(16);set_gfx_mode(GFX_AUTODETECT, 320,240,0,0);
8int myX=160, myY=120,score=0;enemy en[maxEnemies]; bool end = false;
9for(int w=0;w<maxEnemies;w++){en[w].x=psRand;en[w].y=psRand;psRand*=2;}
10while(!key[KEY_ESC]){
11if(key[KEY_LEFT]) myX--;else if(key[KEY_RIGHT]) myX++;
12if(key[KEY_UP]) myY--;else if(key[KEY_DOWN]) myY++;
13clear_bitmap(screen);
14putpixel(screen, myX, myY, 5);
15for(int q=0;q<maxEnemies;q++){putpixel(screen,en[q].x,en[q].y,100);
16if(myX>en[q].x)en[q].x++;else en[q].x--;
17if(myY>en[q].y)en[q].y++;else en[q].y--;
18if(myX == en[q].x && myY == en[q].y) end=true;
19score++;}
20}while(!key[KEY_ESC] && !end && myX>0 && myY>0&&myX<320&myY<240);
21allegro_message("%i",score);
22return 0;}END_OF_MAIN();

Marcello
Quote:

allegro_message(""+score);

It ain't java, ya know.

Try ("%i",score).

Marcello

Ben Jacobs

Oh crap, you're right.
I program JAVA at work so...: (

Niunio

Here you have: The ScreenHack web site.

I know it isn't the best web ever, but it's late (19:49pm at local time) and I'm tired. I'll try to do something better this week-end.

note: I've called the site ScreenHack2004 because somebody has a Yahoo! ID named ScreenHack but no web...

Goodbytes

Way to steal my competition, Niunio. ;) I was going to put up a webpage with the winners myself, in case, say, I want to bolster any university applications with a sampling of my programming experience. But I guess your site wouldn't really interfere with my (figurative) site, except for the slight issue of redundancy... meh.

So, anyway... are you now administering the competition and judging, or just doing the web site?

Billybob

/me wipes sweat off forehead.
My submission (80_25_Chase) compiled successfully on linux(Gentoo, gcc 3.2.3). I've attached the resulting binary program. I wasn't able to fully test the program, however. My linux machine can't run any AGL apps yet, and it's also flaky on some Allegro apps, but oh well. I hope this binary works.

BTW, when I ran it, I got a segmentation fault. I discovered that the problem was that, set_gfx_mode was failing(obviously, since I mentioned the machine can't run AGL apps) and the next allegro calls or something caused a crash(segfault). So if you get a seg-fault, it's only because there's no error checking on set_gfx_mode ;)

Long Live Linux! Power to Cross-Comptability!

Zaphos

GB: I don't think he was thinking of it as a competition, just as a directory of nifty source files.

Everyone: I think GB should have dibs on the speedhack site / processes -- after all, he did start it, and he did kinda indicate from the start that he intended to run it and such. Also, I'd prefer a compo site run off GB's paid host instead of geocities :)
Of course, if GB doesn't actually set anything up, then I have no problem with Niunio's site.

Krzysztof Kluczek

OK, here`s a little question about the rules:

Can I use values instead of some Allegro defines like 0 for GFX_AUTODETECT?

Marcello

Dammit, the source of webpage should be 80x25! And if you want to do even better, make it formatted so what you see is 80x25...

Marcello

Billybob

Krzysztof Kluczek: I'm pretty sure you can...cause I did! heh. does GFX_AUTODETECT resolve to a constant number? I know that GFX_OPENGL_WINDOWED doesn't, it's platform specific. I resolved all my KEY_* though.

Goodbytes

Yes, Krzystof, you are allowed to do such things. If the program doesn't work on other people's computers, it's on your head, though...

Krzysztof Kluczek
gfx.h said:

#define GFX_AUTODETECT 0

I guess it`s rather platform independent.

As for the KEY_* constants I was quite surprised when moving form Allegro 3.* to 4.* since their values changed! In previous versions they were equal to raw keyboard scancodes and now they are more logically assigned (eg. KEY_A was 30, now it is 1, KEY_B is 2 and so on... ).

Anyway I`ll wait for Goodbytes opinion. :)

edit: I got this opinion when was writing this post. ;D

ImLeftFooted

Ok, finally got it done :). its really simple but challenging too, 5 levels. use the arrow keys/esc/right control.

(22 lines)

#SelectExpand
1#include <allegro.h> 2#define C(x,y,col,s) if(s)circlefill(bf,x,y,15,col); 3class P{public:int x,y,c,s,d;};P p,b[5],k;bool q=0;void j(BITMAP *b,int x,int y 4,int d){if(getpixel(b,x,y)!=d && getpixel(b,x,y)!=k.c)q=1;}void u(BITMAP *b,int 5x,int y,int d){if(getpixel(b,x,y)==d)q=1;}BITMAP *bf;int main(){int l=1; 6allegro_init();bf = create_bitmap(480,320);St:;if(set_gfx_mode(0,480,320,0,0)) 7goto Ls;install_keyboard();clear_to_color(bf,1);p.x=p.y=15;p.c=10;p.s=1;p.d=-1; 8for(int y=0; y<5; y++){b[y].x=(y*19)+120;b[y].y=(y*19)+250;b[y].c=12+(3*y);y<l? 9b[y].s=1:b[y].s=0;b[y].d=y;}k.c=11;k.s=0;k.d=-1;while(!key[59]){clear_to_color( 10bf,1);C(k.x,k.y,k.c,k.s)for(int y=0;y<5;y++){do_circle(bf,b[y].x,b[y].y,15,k.c, 11u);if(q)b[y].s=k.s=0,q=0;C(b[y].x,b[y].y,b[y].c,b[y].s)if(b[y].d==0){b[y].x-=7, 12b[y].y-=7;if(b[y].x<0)b[y].d=1;else if(b[y].y<0)b[y].d=3;}if(b[y].d==1){b[y].x 13+=7,b[y].y-=7;if(b[y].x>480)b[y].d=0;else if(b[y].y<0)b[y].d=2;}if(b[y].d==2){ 14b[y].x+=7,b[y].y+=7;if(b[y].x>480)b[y].d=3;else if(b[y].y>320)b[y].d=1;}if(b[y] 15.d>=3){b[y].x-=7,b[y].y+=7;if(b[y].x<0)b[y].d=2;else if(b[y].y>320)b[y].d=0;}} 16do_circle(bf,p.x,p.y,15,1,j);if(q){goto Ls;q=0;}C(p.x,p.y,p.c,p.s)if(key[82])p. 17x-=3;if(key[83])p.x+=3;if(key[84])p.y-=3;if(key[85])p.y+=3;if(key[110])k.s=1,k. 18x=p.x,k.y=p.y;for(int y=0;y<5;y++)if(b[y].s==1)goto Ji;goto Wn;Ji:;blit(bf, 19screen,0,0,0,0,bf->w,bf->h);}Ed:;destroy_bitmap(bf);return 0;Wn:; 20allegro_message("You win!(lvl%d)\n",l);rest(1000);clear_keybuf();readkey();if(l 21<6){l++;goto St;}goto Ed;Ls:;allegro_message("You Lose. (or error)\n");goto Ed; 22}END_OF_MAIN()

compiled on gcc/linux

edit:
oh i almost forgot, dont go off the screen.
and heres my 'uncompressed' version(108 lines):

#SelectExpand
1#include <allegro.h> 2#define C(x,y,col,s) if(s)circlefill(bf,x,y,15,col); 3 4class P{ 5public: 6 int x,y,c,s,d; 7}; 8 9P p; 10P b[5]; 11P k; 12 13bool q=0; 14void j(BITMAP *b,int x,int y,int d){ 15 if(getpixel(b,x,y)!=d && getpixel(b,x,y)!=k.c)q=1; 16} 17void u(BITMAP *b,int x,int y,int d){ 18 if(getpixel(b,x,y)==d)q=1; 19} 20 21BITMAP *bf; 22 23int main(){ 24 int l=1; 25 allegro_init(); 26 bf = create_bitmap(480,320); 27 St:; 28 if(set_gfx_mode(GFX_AUTODETECT, 480, 320, 0, 0))goto Ls; 29 install_keyboard(); 30 clear_to_color(bf,1); 31 p.x=15; 32 p.y=15; 33 p.c=10; 34 p.s=1; 35 p.d=-1; 36 for(int y=0; y<5; y++){ 37 b[y].x=(y*19)+120; 38 b[y].y=(y*19)+250; 39 b[y].c=12+(3*y); 40 y<l?b[y].s=1:b[y].s=0; 41 b[y].d=y; 42 } 43 k.c=11; 44 k.s=0; 45 k.d=-1; 46 47 48 while(!key[KEY_ESC]){ 49 clear_to_color(bf,1); 50 C(k.x,k.y,k.c,k.s) 51 for(int y=0;y<5;y++){ 52 do_circle(bf,b[y].x,b[y].y,15,k.c,u); 53 if(q)b[y].s=k.s=0,q=0; 54 C(b[y].x,b[y].y,b[y].c,b[y].s) 55 56 if(b[y].d==0){ 57 b[y].x-=7,b[y].y-=7; 58 if(b[y].x<0)b[y].d=1; 59 else if(b[y].y<0)b[y].d=3; 60 } 61 if(b[y].d==1){ 62 b[y].x+=7,b[y].y-=7; 63 if(b[y].x>SCREEN_W)b[y].d=0; 64 else if(b[y].y<0)b[y].d=2; 65 } 66 if(b[y].d==2){ 67 b[y].x+=7,b[y].y+=7; 68 if(b[y].x>SCREEN_W)b[y].d=3; 69 else if(b[y].y>SCREEN_H)b[y].d=1; 70 } 71 if(b[y].d>=3){ 72 b[y].x-=7,b[y].y+=7; 73 if(b[y].x<0)b[y].d=2; 74 else if(b[y].y>SCREEN_H)b[y].d=0; 75 } 76 } 77 do_circle(bf,p.x,p.y,15,1,j); 78 if(q){goto Ls;q=0;} 79 80 C(p.x,p.y,p.c,p.s) 81 82 if(key[KEY_LEFT])p.x-=3; 83 if(key[KEY_RIGHT])p.x+=3; 84 if(key[KEY_UP])p.y-=3; 85 if(key[KEY_DOWN])p.y+=3; 86 if(key[KEY_RCONTROL])k.s=1,k.x=p.x,k.y=p.y; 87 88 for(int y=0;y<5;y++) 89 if(b[y].s==1)goto Ji; 90 goto Wn; 91 Ji:; 92 blit(bf,screen,0,0,0,0,bf->w,bf->h); 93 } 94 Ed:; 95 destroy_bitmap(bf); 96 return 0; 97 Wn:; 98 allegro_message("You win!(lvl%d)\n",l); 99 rest(1000); 100 clear_keybuf(); 101 readkey(); 102 if(l<6){l++;goto St;} 103 goto Ed; 104 Ls:; 105 allegro_message("You Lose. (or error)\n"); 106 goto Ed; 107} 108END_OF_MAIN()

Krzysztof Kluczek

Nice game. :)

I had to change two things before I got it running under DJGPP:

1. Change graphics mode and backbuffer size. In DOS there is no windowed mode and you have to use screen resolutions (I changed to 640x480).
2. I had to add vsync() before blit() since it was really too fast (I think 0.1s was enough to travel through entire screen).

(consider changing it in your source to make it portable) :)

OK, I`ll return to play. :)

edit: I found there is way to cheat - just hold control key pressed and everything that touches you gets killed. Consider making player bigger/the bomb smaller or swapping collision checking order.

Oh, and rest() requires install_timer to work properly.

Marcello

Hehe, I want to see a 80x25 game in java... now that would be difficult.

Marcello

ImLeftFooted

okay, i fixed some stuff, made it (hopefully) cross compatible, and added a lifetime to the mine. Tell me what u think

edit: hold 1/2/3 when its loading to slow it down if its too fast.

1#include <allegro.h>
2#define C(x,y,col,s) if(s)circlefill(bf,x,y,15,col);
3class P{public:int x,y,c,s,d;};P p,b[8],k;int s=0;bool q=0;void j(BITMAP *b,int
4x,int y,int d){if(getpixel(b,x,y)!=d && getpixel(b,x,y)!=k.c)q=1;}void u(BITMAP
5*b,int x,int y,int d){if(getpixel(b,x,y)==d)q=1;}BITMAP *bf;int main(){int l=1;
6allegro_init();bf = create_bitmap(480,320);if(set_gfx_mode(0,640,480,0,0))goto
7Ls;install_keyboard();rest(1500);key[KEY_1]?s=1:key[KEY_2]?s=2:key[KEY_3]?s=3:s
8=0;St:;clear_to_color(bf,1);p.x=p.y=15;p.c=10;p.s=1;p.d=-1;for(int y=0; y<8;
9y++){b[y].x=(y*9)+120;b[y].y=(y*9)+250;b[y].c=12+(3*y);y<l?b[y].s=1:b[y].s=0;b[
10y].d=y<4?y:y<5?0:y<6?1:y<7?2:3;}k.c=11;k.s=0;k.d=-1;while(!key[KEY_ESC]){if(k.s
11)k.d>-85?k.d--:k.s=0;clear_to_color(bf,1);C(k.x,k.y,k.c,k.s)for(int y=0;y<8;y++
12){do_circle(bf,b[y].x,b[y].y,8,k.c,u);if(q)b[y].s=k.s=0,q=0;C(b[y].x,b[y].y,b[y
13].c,b[y].s)if(b[y].d==0){b[y].x-=7,b[y].y-=7;if(b[y].x<0)b[y].d=1;else if(b[y].
14y<0)b[y].d=3;}if(b[y].d==1){b[y].x+=7,b[y].y-=7;if(b[y].x>480)b[y].d=0;else if(
15b[y].y<0)b[y].d=2;}if(b[y].d==2){b[y].x+=7,b[y].y+=7;if(b[y].x>480)b[y].d=3;
16else if(b[y].y>320)b[y].d=1;}if(b[y].d>=3){b[y].x-=7,b[y].y+=7;if(b[y].x<0)b[y]
17.d=2;else if(b[y].y>320)b[y].d=0;}}do_circle(bf,p.x,p.y,15,1,j);if(q){goto Ls;q
18=0;}C(p.x,p.y,p.c,p.s)if(key[KEY_LEFT])p.x-=4;if(key[KEY_RIGHT])p.x+=4;if(key[
19KEY_UP])p.y-=4;if(key[KEY_DOWN])p.y+=4;if(key[KEY_RCONTROL])k.s=1,k.x=p.x,k.y=p
20.y,k.d=-1;for(int y=0;y<8;y++)if(b[y].s==1)goto Ji;goto Wn;Ji:;for(int x=0;x<s;
21x++)vsync(),rest(100);blit(bf,screen,0,0,80,80,bf->w,bf->h);}Ed:;destroy_bitmap
22(bf);return 0;Wn:;allegro_message("You win!(lvl%d)\n",l);rest(1000);
23clear_keybuf();readkey();if(l<9){l++;goto St;}goto Ed;Ls:;allegro_message(
24"You Lose. (or error)\n");goto Ed;}END_OF_MAIN()

edit:
My beautiful screenshot :P
http://www.mize.org/screenshot.png

edit2:
I was thinking that this game probably makes no sense::), so ima explain it a little. The object is to destroy all the bad circles by dropping your mine in their path(Right Control). But dont let them touch you either, cause then u gotta start all over. After a certain amount of time, the mine expires and you have reset it. Also, leaving the ring automaticaly starts you over. there are 9 levels to beat. and...well, I hope that its fun. Its my kind of game anyway, the kind that is near impossible to beat but you try for hours and hours:P

if the game runs too fast, press and hold 1, 2, or 3 while the game loades (3 being the slowest). the default is 0.

attached is a linux binary

Paul Pridham

How about some screenshots?

Mark Hall

Gravitational dot swarm by Mark Hall!
Move the mouse to avoid the swarm of killer dots that are gravitationally attracted to you. Your circle becomes redder the closer you are to death. Press ESC to quit prematurely.

#include <allegro.h>
int main(){int dx[256];int dy[256];double vx[256];double vy[256];int x;int hp=
255;int ht;allegro_init();BITMAP*bu=create_bitmap(640,480);set_gfx_mode(
GFX_AUTODETECT,640,480,0,0);install_keyboard();install_mouse();install_timer();
for(x=0;x<256;x++){dx[x]=rand()%640;dy[x]=rand()%480;vx[x]=0;vy[x]=0;}do{ht=0;
for(x=0;x<256;x++){circlefill(bu,mouse_x,mouse_y,5,makecol(255,hp,hp));putpixel(
bu,dx[x],dy[x],makecol(255,x,x));if(mouse_x<dx[x])vx[x]--;else if(mouse_x==dx[x]
)ht=1;else vx[x]++;if(mouse_y<dy[x])vy[x]--;else if(mouse_y==dy[x])ht=1;else vy[
x]++;dx[x]+=vx[x];dy[x]+=vy[x];vx[x]*=0.99;vy[x]*=0.99;}if(ht)hp--;blit(bu,
screen,0,0,0,0,640,480);rest(30);clear(bu);}while(!key[KEY_ESC]&&hp>0);
destroy_bitmap(bu);}END_OF_MAIN()

ImLeftFooted

I finally got around to looking at all the entries, and thought i might as well throw it into a zip(attatched), so here it is. I also included linux binaries for the non gl ones that would compile. Are we going to have a vote or anything?

edit: I couldnt resist ::) ClickIt

edit2: updated zip for dot swarm 2

Eric Love

I'm most impressed by Krzysztof's game - there were a few compiling issues (djgpp) and editing it messed the map up a bit. Eventually I had to use two diferent version of the code, one for the map. I'll be trying some of the recent ones now...

Mark Hall

Okay, I fixed up the game and added some new stuff. Now you have a weapon to fight back with! The bar on the top is how much energy you have. Left-click to activate your repulsor, which will push the gravitational dots away from you. However, you have a limited amount of fuel. I also fixed the dot collision detection.

#include <allegro.h>
int main(){double dx[256];double dy[256];double vx[256];double vy[256];int x;int
hp=255;int ht;double fx=1;int pw=320;allegro_init();BITMAP*bu=create_bitmap(640,
480);set_gfx_mode(GFX_AUTODETECT,640,480,0,0);install_keyboard();install_mouse()
;install_timer();for(x=0;x<256;x++){dx[x]=rand()%640;dy[x]=rand()%480;vx[x]=0;vy
[x]=0;}do{if((mouse_b&1)&&pw-->0)fx=-0.01;else fx=1;ht=0;rectfill(bu,0,0,pw*2,2,
makecol(255,0,0));circlefill(bu,mouse_x,mouse_y,5,makecol(255,hp,hp));for(x=0;x<
256;x++){putpixel(bu,dx[x],dy[x],makecol(255,x,x));if(mouse_x<dx[x])vx[x]-=fx;
else vx[x]+=fx;if(mouse_y<dy[x])vy[x]-=fx;else vy[x]+=fx;dx[x]+=vx[x];dy[x]+=vy[
x];vx[x]*=0.98;vy[x]*=0.98;if(abs(mouse_x-dx[x])<3&&abs(mouse_y-dy[x]<3))ht=1;}
if(ht)hp-=2;blit(bu,screen,0,0,0,0,640,480);rest(30);clear(bu);}while(!key[
KEY_ESC]&&hp>0);destroy_bitmap(bu);}END_OF_MAIN()

Krzysztof Kluczek
Quote:

there were a few compiling issues (djgpp)

Eric: I`m quite surprised with this, since I developed this using DJGPP. Maybe you just have named the file as *.c? I compiled this with .cpp and it worked. And it also generates a bunch of conversion warnings and missing return in main() which you should ignore. Please PM me if you have any further problems. :)

Niunio
GoodBytes said:

Way to steal my competition, Niunio.

Yea, it was!;D

GoodBytes (again) said:

But I guess your site wouldn't really interfere with my (figurative) site, except for the slight issue of redundancy... meh.

So, anyway... are you now administering the competition and judging, or just doing the web site?

I'm just doing a web site, without judging.

Zaphos said:

GB: I don't think he was thinking of it as a competition, just as a directory of nifty source files.

Me also

Zaphos (again) said:

Everyone: I think GB should have dibs on the speedhack site / processes -- after all, he did start it, and he did kinda indicate from the start that he intended to run it and such. Also, I'd prefer a compo site run off GB's paid host instead of geocities
Of course, if GB doesn't actually set anything up, then I have no problem with Niunio's site.

If anybody has a problem with my site, let me know. I'll cancel my site if you (specially GoodBytes) don't agree with it.

LSd016
1#include <allegro.h>
2#include <stdlib.h>
3#define CS (rand()%10)-5
4void main(void)
5{allegro_init();set_color_depth(16);set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
6install_keyboard();
7BITMAP *b=create_bitmap(640, 480);
8st:int bx=320,by=240,incx=10,incy=5,pp=320,ln=40,score=0;
9while(!key[KEY_ENTER])textprintf(screen,font,100,240,makecol(0,255,255),
10"wtf!?! yet another arkanoid!?! [PRESS ENTER]");
11while(!key[KEY_ESC])
12{clear(b);if(bx>640)incx = -5; if(bx<0)incx = 5;
13if(by>460){incy=-5;incx=CS; if(bx<pp || bx>pp+ln)goto gover;score++;ln-=2;}
14bx+=incx;by+=incy; if(by<0){incy=5;incx=CS;}
15if(key[KEY_RIGHT])pp+=10;if(key[KEY_LEFT])pp-=10;
16rect(b, pp,460,pp+ln,470,makecol(200,200,120));
17circle(b, bx, by, 5, makecol(255,255,255));
18textprintf(b,font,0,0,makecol(0,255,255),"SCORE: %d",score);
19vsync();blit(b,screen,0,0,0,0,640,480);} return;
20gover: alert(0,"GAME OVER",0,"OK",0,'o',0);goto st;
21}END_OF_MAIN();

#include <windows.h>
#include <stdio.h>

void main(void)
{
char *ct_dir="C:\\Program Files\\Crazy Taxi\\";
char ct_exe[256]; sprintf(ct_exe, "%sCrazy_Taxi_PC.exe",ct_dir);

ShellExecute(0,"open",ct_exe, 0, ct_dir, SW_NORMAL);
}

;D

Breakman79

Here is my entry. This is my first C project in around three years, it felt good stretch my gaming legs again. Let me know if you find any problems. Left and Right to move, Space to fire, ESC to quit. You've got three lives, but it doesn't automatically exit once you're dead.

1#include <allegro.h> /*BLASTER 2004-2-8 Brian Glenn (Breakman79)*/
2#include <time.h>
3BITMAP *B;int A=304,C,D=-1,E=0,F=0,G,H=3,I,J[99],K[99],L[99],M[99],N[99],O[99],P
4[99];float Q=4;void dh(int X){if(H>=3)I=31;if(H==2)I=65504;if(H==1)I=64512;
5rectfill(B,X+16,456,X+32,468,I);rectfill(B,X,468,X+48,480,I);}void de(int X, int
6Y){rectfill(B,X,Y,X+16,Y+12,45270);rectfill(B,X+32,Y,X+48,Y+12,45270);rectfill(B
7,X+16,Y+12,X+32,Y+24,45270);}void db(int X,int Y,int I){rectfill(B,X,Y,X+16,Y+12
8,I);}void se(){F++;Q+=.5;for(E=0;E<F;E++){J[E]=0;K[E]=rand()%591;L[E]=rand()%350
9;P[E]=500;}}int main(){srand(time(NULL));se();allegro_init();install_keyboard();
10set_color_depth(16);B=create_bitmap(640,480);if(!set_gfx_mode(GFX_AUTODETECT,640
11,480,0,0)){while(!key[KEY_ESC]){if(key[KEY_RIGHT]&&A<591)A+=8;if(key[KEY_LEFT]&&
12A>0)A-=8;if(key[KEY_SPACE]){C=A+16;D=456;}if(G==5*F)se();G=0;for(E=0;E<F;E++){if
13(J[E]<5&&C<K[E]+48&&C+16>K[E]&&D<L[E]+12&&D+12>L[E]){J[E]=5;D=-12;}if(J[E]==0){J
14[E]=1+rand()%2;if(J[E]==2&&H<1)J[E]=1;if(J[E]==1){M[E]=rand()%591;N[E]=rand()%
15350;}}switch(J[E]){case 1:if(K[E]==M[E]&&L[E]==N[E]){J[E]=0;break;}if(K[E]>M[E])
16{if(K[E]-Q>M[E]){K[E]-=Q;}else{K[E]=M[E];}}else{if(K[E]+Q<M[E]){K[E]+=Q;}else{K[
17E]=M[E];}}if(L[E]>N[E]){if(L[E]-Q>=N[E]){L[E]-=Q;}else{L[E]=N[E];}}else{if(L[E]+
18Q<=N[E]){L[E]+=Q;}else{L[E]=N[E];}}break;case 2:if(P[E]>492){if(K[E]>A+24){K[E]
19-=Q;}else if(K[E]<A-16){K[E]+=Q;}else{O[E]=K[E]+16;P[E]=L[E]+12;}}else{P[E]+=12;
20db(O[E],P[E],2016);if(P[E]>492)J[E]=0;if(O[E]<A+48&&O[E]+16>A&&P[E]<480&&P[E]+12
21>468){H--;P[E]=500;J[E]=0;}}}if(J[E]<5)de(K[E],L[E]);G+=J[E];}if(D>-12){D-=12;db
22(C,D,63488);}if(H>0)dh(A);vsync();blit(B,screen,0,0,0,0,640,480);clear_bitmap(B)
23;}}destroy_bitmap(B);return 0;}END_OF_MAIN()

Krzysztof Kluczek

Nice game with nice gameplay! :) Could you add a score/level indicator? ;D

edit: err.. funny bug: you can still shoot when you are dead. ;D

Billybob

Breakman79: To shrink the code more, possibly add a function that replaces rectfill, but give it a one letter name. That may or may not shrink your code. Also replace GFX_AUTODETECT with it's number equivilent. Then maybe you can fit in some game features.

EDIT: and replace NULL with 0
EDIT2: and replace the KEY_* with their number equivilents. You got loads of space!

Breakman79

Ok, guys, I'll try out some your suggestions and see if I can get a level and score indicator going.

Quote:

err.. funny bug: you can still shoot when you are dead.

Oops, forgot to put a check on the fire button. Thanks.

Karadoc ~~

I made a simple tank sort of game. control with WADS and Q to shoot. I think the crappest thing about it is that nothing cool happens if someone gets shot... they just reappear in the middle of the screen.
The computer's tank can move without turning it's turret, but the player's tank moves a little bit faster, and can move diagonally. So I can say that each player has it's own unique abilities. ;) Also, I put a few racing strips in the code, so it should run pretty fast ;D. It makes the code look slightly less like a blob of rubbish. very slightly...
I call it "Didn't your mother ever tell you not to play with macros?"

1#include <allegro.h>
2struct{ int x, y, dx, dy;} a[9], b[9]; int ca=1, cb=1,i,aic=0;
3volatile int click=0; void Click(void) {click++;} END_OF_FUNCTION(Click)
4#define shoot(p) {p[c##p] = p[0]; p[c##p].x +=4;p[c##p].y+=4;\
5 p[c##p] .dx*=5; p[c##p].dy*=5; c##p= (c##p < 7)?c##p+1:1; }
6#define bet(x, l, u) (x < u && x >= l)
7#define con(b,mx,my) if(key<b>){a[0].dx =mx;a[0].dy =my;a[0].x+=mx;a[0].y+=my;}
8main(){ allegro_init ();install_keyboard ();install_timer();if(set_gfx_mode
9(GFX_AUTODETECT_FULLSCREEN,640,480,0,0)) return 1;LOCK_FUNCTION(Click)
10LOCK_VARIABLE(click) install_int(Click, 15);memset(a,0,sizeof(a));memset(b,0,
11sizeof(b));a[0].x=a[0].y=10;b[0].x=b[0].y =470;while(!key[KEY_ESC]){while(click)
12{click--;aic++;if(key[KEY_Q]){shoot(a)}con (KEY_W,0,-1)con(KEY_A,-1,0)con(KEY_D
13,1,0)con(KEY_S,0,1)if(aic%7){if(bet ((b[0] .x-a[0] .x),0, 4)){b[0].dx =0;b[0]
14.dy= (b[0].y > a[0].y)?-1:1;if(!(b[cb].dx+b [cb].dy)) shoot(b); } else if (bet(
15(b[0].y - a[0].y), 0, 4)){b[0].dx = (b[0].x >a[0].x)?-1:1; b[0].dy=0;if(!(b[cb]
16.dx+b[cb].dy))shoot(b);}else{if(abs(b[0].x- a[0].x)<abs(b[0].y - a[0].y)){b[0].
17x+=(b[0].x>a[0].x)?-1:1;}else{b[0].y+=(b[0] .y>a[0].y)?-1:1;}}}
18#define move(p,e,o)if(bet(640-p[o].x,1,640 )&&bet (480-p[o].y,1,480)){p[o]\
19.x+=p[o]. dx;p[o].y+=p[o].dy;if(bet (p[o] .x-e[0] .x,0,10)&&bet(p[o].y-e[0]\
20.y,0,10)) {e[0].x=300; e[0].y=200;}}else {p[o].dx=p [o].dy=0;p[o].x=-9;}
21for(i=1; i<9;i++) {move(b,a,i) move(a,b,i) }clear(screen);
22#define draw(p,o,s,c)rectfill(screen, p[o].x,p[o] .y,p[o].x+s,p[o].y+s,c);line(\
23screen, p[o].x+s/2,p[o].y+s/2,p[o]. x+s*(.5+p[o].dx),p[o].y+s*(.5+p[o].dy),c);
24draw(a, 0,10,2)draw (b,0,10,4)for (i=1; i<9;i++){ draw(a,i,1,15)
25draw(b, i,1,15) }}}} END_OF_MAIN ()

[edit]
I decided I would make and post my game before I looked at anyone else's.
Now that I've posted my game, and looked at the others, I'm beginning to think that I should take out those silly strips and fix my game up a bit!
I reckon Elias has the best so far.

Zaphos

Nuinio: I don't have any problems with your site if gb doesn't, I was just saying he should probably get dibs. Anyway, I like your layout an all; some nitpicks about it, though:

1) You offer the entries as zipfile downloads -- is that really necessary? I mean, they are very small single text files, no datafiles allowed. It would be much more convenient if they were just .c or .cpp files, or even if they were inserted inline.
2) A short description of each game would be nice, and easy to include since most entries have explanations by the author posted alongside.
3) It would be nice if there were more games there than just your own ;)

Niunio
Quote:

1) You offer the entries as zipfile downloads -- is that really necessary? I mean, they are very small single text files, no datafiles allowed. It would be much more convenient if they were just .c or .cpp files, or even if they were inserted inline.

2) A short description of each game would be nice, and easy to include since most entries have explanations by the author posted alongside.

That was the initial idea. Well, I think I'll do it both ways: 'inline' .C and .CPP files with a screen shot the game description, and two (or more) ZIP files with all sources or binaries for DOS and Window$ (I'm not sure if I can also Linux)

Quote:

3) It would be nice if there were more games there than just your own ;)

Hey! It's my web site! I can do whatever I want!

Just kidding...

When I'd finished the definitive web design it was late (22:00pm at local time) and today I must get up early (now, I'm at office, 'working';)) and I didn't test all entries of this thread yet...

Harpreet Singh

Here is my entry..."Swat The BugZ". Use the mouse to swat the bugs!!

It's pretty trivial and lame and... Earlier I was getting hardly 16 lines. So I made a title screen...nothing much really.

Hope you like it...(ALthough i know its far from the level of other entries)Do send me suggestions and comments...
I'm just 15, so try not to be too harsh with your comments!!;)

Breakman79

Ok, here's my new and improved version. Fixed the bug where you could still fire after game over. Added Score, Level, and Game Over indicators. Have fun!

1#include <allegro.h> /*BLASTER Destroy the enemy bombers before they get you.*/
2#include <time.h> /*Controls: Left-Right to move, Space to fire, ESC to quit*/
3BITMAP *a;int b=304,c,d=-1,e=0,f=0,g,h=3,i,j=0,k[99],l[99],m[99],n[99],o[99],p[
499],q[99];float r=4;void rf(int s,int t,int u,int v,int i){rectfill(a,s,t,u,v,i)
5;}void dh(int x){if(h>=3)i=31;else if(h==2)i=65504;else i=64512;rf(x+16,456,x+32
6,468,i);rf(x,468,x+48,480,i);}void de(int x,int y){rf(x,y,x+16,y+12,45270);rf(x
7+32,y,x+48,y+12,45270);rf(x+16,y+12,x+32,y+24,45270);}void db(int x,int y,int i)
8{rf(x,y,x+16,y+12,i);}void se(){f++;r+=.5;for(e=0;e<f;e++){k[e]=0;l[e]=rand()%
9591;m[e]=rand()%350;q[e]=500;}}int main(){srand(time(NULL));se();allegro_init();
10install_keyboard();set_color_depth(16);a=create_bitmap(640,480);if(!set_gfx_mode
11(0,640,480,0,0)){while(!key[KEY_ESC]){if(key[KEY_RIGHT]&&b<591)b+=8;if(key[
12KEY_LEFT]&&b>0)b-=8;if(key[KEY_SPACE]&&h>0){c=b+16;d=456;}if(g==5*f)se();g=0;for
13(e=0;e<f;e++){if(k[e]<5&&c<l[e]+48&&c+16>l[e]&&d<m[e]+12&&d+12>m[e]){k[e]=5;d=-
1412;j+=5;}if(k[e]==0){k[e]=1+rand()%2;if(k[e]==2&&h<1)k[e]=1;if(k[e]==1){n[e]=
15rand()%591;o[e]=rand()%350;}}switch(k[e]){case 1:if(l[e]==n[e]&&m[e]==o[e]){k[e]
16=0;break;}if(l[e]>n[e]){if(l[e]-r>n[e])l[e]-=r;else l[e]=n[e];}else{if(l[e]+r<n[
17e])l[e]+=r;else l[e]=n[e];}if(m[e]>o[e]){if(m[e]-r>=o[e])m[e]-=r;else m[e]=o[e];
18}else{if(m[e]+r<=o[e])m[e]+=r;else m[e]=o[e];}break;case 2:if(q[e]>492){if(l[e]>
19b+24)l[e]-=r;else if(l[e]<b-16)l[e]+=r;else{p[e]=l[e]+16;q[e]=m[e]+12;}}else{q[e
20]+=12;db(p[e],q[e],2016);if(q[e]>492)k[e]= 0;if(p[e]<b+48&&p[e]+16>b&&q[e]<480&&
21q[e]+12>468){h--;q[e]=500;k[e]=0;}}}if(k[e]<5)de(l[e],m[e]);g+=k[e];}if(d>-12){d
22-=12;db(c,d,63488);}if(h>0)dh(b);else textprintf(a,font,280,240,65535,
23"GAME OVER");textprintf(a,font,10,10,65535,"Score: %d",j);textprintf(a,font,560,
2410,65535,"Level: %d",e);vsync();blit(a,screen,0,0,0,0,640,480);clear_bitmap(a);}
25}destroy_bitmap(a);return 0;}END_OF_MAIN()/*2004-2-9 Brian Glenn (Breakman79)*/

CGamesPlay
Quote:

I'm just 15, so try not to be too harsh with your comments!!

You've been coding 15 years? Dang! Your entry should easily beat everybody else's! But seriously, it's not age, it's time. I've been coding since I was about 8 (I'm 15 now), so you don't see me telling people not to be too harsh (even though my entry is pretty pathetic compared to some of the others, like that raycaster :)).

Niunio

Yes, time...

And not only the time you're coding (I've been coding since I was about 12, I'm 27 now;)), also the time you have to coding each day. My entry was done only in 2/3 hours because I haven't much more free time.

Krzysztof Kluczek

Ok, I squished my code a bit and managed to add some stuff improving the gameplay nicely. :) Watch out for the big red spheres bouncing here and there which aren`t much fond of your idea to pick all the coins (175 coins now). :)

William: I really didn`t mean to make a clone of your game. Enemies were supposed to be there even before coins were and of course before I`ve seen your entry.

Here`s the code. In case not to spam forum anymore any further updates will be done by changing this post. It should be compiled using C++ compiler (eg. g++) and linked with allegro and math libraries. It can complain about things like double->int conversions, missing return in main() and wrong type of main() but you should ignore this. If you find any problems compiling it, please PM me. I`d like to make it portable. :)

edit: code changed a bit: added missing F sqrt(F); (thanks Breakman79) :)

1#include <allegro.h>/**** Bartenstein 3D! by Krzysztof Kluczek (c) 2004 ****/
2#define D(p,q)(1 p 0?m[i(X p d)][i(Y q d)]:t[4]?i(t[0]*4)|i(t[1]*4)?0: s=-1:0)&&
3typedef double F;extern"C"{F sin(F);F cos(F);F atan(F);F sqrt(F);}typedef int i;
4i x,y,n,l,Q=0,j[90][90],s;char m[90][90]={},*g=(char*)m,*h=g,*k=g,*p=g+1,c;F b,u
5,v,a,d,z[320],A=0,X=1.5,Y=1.5,q[999][9]={},*t;BITMAP*w;RGB r;i cc(){d=.4 ;return
6D(-,-)D(-,+)D(+,-)D(+,+)1;}i main(){allegro_init();install_keyboard();PACKFILE*f
7=pack_fopen(__FILE__,"r");set_gfx_mode(0,320,200,0,0);w=create_bitmap(320,200) ;
8while(pack_fgets(p+=90,88,f));pack_fclose(f);for(y=0;y<256;y++)x=y/4,r.r=(y&1)*x
9,r.g=y&2?x:0,r.b=y&4?x:0,t=q[y],t[3]=y-173.5,t[2]=9,t[4]=(y>174)*.02,set_color(y
10,&r); for(;g<h+8100;g++)(*g&=7)^2?0:j[i(q[Q][2]=(g-k)/90+.5)][i(q[Q][3]=(g-k)%90
11+.5)]=Q++;s=Q;Q+=80;while(s>0&&!key[59]){g=m[i(X)]+i(Y);if(*g==7){for(y=0;y<1740
12;y++){if(!(y%30))vsync();blit(w,screen,0,199,0,199-y,320,1);}break;}*g==2?*g=3,s
13--,q[j[i(X)][i(Y)]][2]=-9:0;for(x=0;x<320;x++){t=q[x];m[i(t[2])][i(t[3])]?0:t[4]
14=-t[4];t[2]+=t[4];d= atan((x-160)/200.);u=cos(A+d);v=sin(A+d);b=50.0/cos(d)+10 ;
15for(l=y=100;y>0;)c=y>9?m[i(b/y*u+X)][i(b/y*v+Y)]+2*(y&~3):0,c++&7?c&7?vline(w,x,
1699+y,99+l,c),0:0,putpixel(w,x,100-y,c),0:(z[x]=b/y,vline(w,x,99+l,100-y,c),y=0),
17y--,l=c&7?y:l;}u=cos(A);v=sin(A);for(l=0;l<Q;l++)t=q[l],a=t[2]-X,b=t[3]-Y,t[0]=a
18*u+b*v,t[1]=b*u-a*v,D(*,*)1;u=9;while(1){v=0;for(x=0;x<Q;x++)a=q[x][0],v<a&&a<u?
19l=x,v=a:0;if(v<.1)break;u=v;t=q[l];d=160+200*t[1]/t[0];a=(16<<(l>174))/t[0];for(
20n=-a;x=d+n,n<=a;n++)if(x>=0&&x<320&&z[x]>t[0]+.3)y=sqrt(a *a-n*n),vline(w,x,99-y
21,100+y,251-8*i(t[0]*4)-2*(l>174));}a=0.07;key[82]?A-=a:key[83]?A+=a:0;key[84]?0:
22a=key[85]?-a:0;X+=(u=a*cos(A));cc()?0:X-=u;Y+=(v=a*sin(A));cc()?0:Y-=v;u=300;v =
2320;line(w,u,v,u+9*cos(A),v+9*sin(A),254);putpixel(w,u,v,255);textprintf(w,font,0
24,0,255,"%d",s);vsync();blit(w,screen,0,0,0,0,320,200);}clear(screen);textout(///
25screen,font,s?"Game Over":"You win!",124,96,255);while(!key[59]);}END_OF_MAIN();

And guess how the D macro works. ;D

ImLeftFooted
Niunio said:

(I'm not sure if I can also Linux)

I already compiled the non gl ones for linux. check the attatchment of my last post

Goodbytes

Niunio: Nah, don't worry, keep the site up. I just misunderstood/overreacted.

Now, just wait for my entry... it'll blow you guys away! Blow you away in the sense that it will probably underwhelm you. But it has some nice gfx effects so far.

Wetimer

The question is, could a program be written that compresses code like this? It would add define, typedefs to reduce code. Any varible created by the user code would have there names changed to something very short. How big a program could this compressor compress?

Billybob
Quote:

could a program be written that compresses code like this?

yeah, why not? Seems pretty easy to do. Just have it look for multiple occurances of a certain function call, try to define it, and if the define shrinks the program, keep it and then find another function to shrink. Change variables, use variables for long repeated values, and then cut out newlines and fit into 80 character lines. Simple enough.

Carrus85

That would be an interesting project. What would also be interesting is to write a program that decompresses this code to a readable form as well... (Although much easier to implement.)

CGamesPlay

Carrus: It's called indent, and it ships with linux (I believe).

Billybob

Actually the reverse is harder, because a program doesn't know what to rename the variables to! You'd have to tell it what each variable should be renamed to, and then after that I think it's pretty easy sailing...

Krzysztof Kluczek
Quote:

It's called indent, and it ships with linux (I believe).

Does this program indent long ?: phrases? If not, the source can be still unreadable.

btw. I fixed small bug in my game which prevented it from compiling on some compilers - last post with code is updated.

Breakman79

Wow, Krzysztof, your game is awesome. I'm completely flabbergasted that something of that complexity could be made in such a small amount of code. Great job! ;D

Billybob

I updated my first post so that it has my latest code. I squeezed it even more by replacing two defines with functions. I got a goodly amount of room to maybe put another small feature in...but I'm not sure what to put in?

zaphire

Wow... this was strangely amusing, in a very disturbing way. Anyways, here's my mini version of NiM.

1#include <allegro.h>/* MiniNiM 2004 - http://zaphire.ca */
2#include <math.h>/*Damn you for taking up another line, math.h*/
3typedef int i;typedef void v;typedef float f;BITMAP *b,*l;f ox,oy;struct W;
4struct B{f x,y,a;W *w;v ud(){x+=cos(a)*4;y+=sin(a)*4;}v re(){
5circlefill (b,x,y,2,4);}};B bs[2];struct W{W(){o=0;h=10;j=0;r=0;a=-3.14;m=0
6;}i x,y,h,j,r,m,D,J,S,L,kr,u,T,o;f a;v dig(){circlefill(l,x+cos(a)*2,y-5+
7sin(a)*2,4,0);};v sh(){if(m<0){B b;b.x=x;b.y=y-5;b.a=a;b.w=this;bs[o]=b;m=20
8;}}v ud(){m--;ox=x;oy=y;y++;if(key[T])dig();else if(key[S])sh();if(key<u>)a+=
9r?-.08:.08;if(key[D])a+=r?.08:-.08;if(key[J]){if(j>0){y-=10;j--;}}
10else if(j<10)j++;if(key[L]){x--;if(r){a=3.14f-a;}r=0;}if(key[kr]){x++;if(!r){a
11=3.14-a;}r=1;}while(getpixel(l,x,y)!=0){y--;if(y-oy<-5){x=ox;y=oy;break;}}if(h>
120){ellipsefill(b,x,y-4,8,4,2);circlefill(b,x-6+(12*r),y-10,4,2);line(b,x+(r?5:-
135),y-5,x+(r?5:-5)+cos(a)*10,y-5+sin(a)*10,5);line(b,x-5,y-18,x-5+h,y-18,7);}}
14};W z[2];main(){z[0].x=100;z[0].y=100;z[1].x=200;z[1].y=100;z[0].u=84;z[0].L=
1582;z[0].D=85;z[0].kr=83;z[0].J=108;z[0].S=106;z[0].T=104;z[1].u=23;z[1].L=1;z[1
16].D=19;z[1].kr=4;z[1].J=107;z[1].S=105;z[1].T=103;z[1].o=1;allegro_init();
17install_keyboard();set_gfx_mode(GFX_AUTODETECT,320,200,0,0);b=create_bitmap(320
18,200);l=create_bitmap(320,200);clear_to_color(l,1);i c;while (!key[59]){vsync()
19;clear_bitmap(b);draw_sprite(b,l,0,0);for(c=0;c<2;c++){z[c].ud();}for(c=0;c
20<2;c++){bs[c].ud();bs[c].re();for(i d=0;d<2;d++){if(getpixel(l,bs[c].x,
21bs[c].y)!=0){circlefill(l,bs[c].x,bs[c].y,3,0);bs[c].y=-100;}else if((abs(bs[c]
22.x-z[d].x)<10)&&(abs(bs[c].y-z[d].y)<10)&&(&z[d]!=bs[c].w)){bs[c].y=-100;bs[c].
23a=0;z[d].h--;if(z[d].h<1)goto E;}}}blit(b,screen,0,0,0,0,320,200);}E:if(z[0].h>
240)textout(b,font,"P1Win",140,80,4);else textout(b,font,"P2Win",140,80,4);blit(b
25,screen,0,0,0,0,320,200);while (!key[KEY_ESC]);}END_OF_MAIN();

Player1
-------
Move - arrow keys
Dig - hold shift
Jump - alt
Shoot - control

Player2
-------
Move - ASDW
Dig - other shift
Jump - other alt
Shoot - other control

This was built with MSVC6, so I may be benefiting from M$'s lack of compliance with ANSI standards in the scoping department.
This hack has been quite bad for my coding practices. I tried to use OPP as much as possible, but it was better to use structs than classes because I didn't have to add "public:", and using std::vectors took up way too much space.:'(
Well now that that's over, back to my precious OOP-oriented jobs. Thank goodness for hard drives larger than 2kb. ^^;;

CGamesPlay

What, you think making it a struct suddenly means it's not OO? You think a struct can not have polymorphism, static members, or anything a class can't? You're the second person to have done that in this thread. You people are weird.

zaphire

Structs in C++ are just wrappers to public classes; but it still feels gross to use them. The point I was making was that there just wasn't enough room for the OOP hierarchy I had in mind. (a base positional object, a particle class and a class for moving on a bitmap derived from that, derive Bullet and Worm classes from the movement class, derive Human and AI control classes from that etc) The lack of space forced me to use non-OOP solutions which I wouldn't have used otherwise. Yes, I could have derived to my heart's content, if there had been room to do so while still being able to implement the basic things that I wanted to have in there.

So yeah, it was fun coming up with the smallest solutions, rather than the fastest/easiest to develop.

Fladimir da Gorf

I figured out I may not have time to continue my screenhack until next week. Well, the code's 26.2 lines now (about 25 if you don't count the damned first line :P), but I'll figure out eventually how to compress the code even further. And no, I won't strip out any graphics. ;)

1#include <allegro.h> /* -- TUNNEL B0.001 -- by "Fladimir da Gorf" */
2#define o(v,end)for(int v=0;v<end;v++) /* Arrow keys to move, space to fire */
3typedef int I;BITMAP *b,*m,*pl;I hp,v,k,W=320,H=200,pc=0x3C4AB4,e[99],r[99],h[99
4],n,l=1,Q;float x,y,xs,ys,t[99],w[99],ts[99],ws[99],E,T,ES,TS,CT;void D(BITMAP*b,
5I cx,I cy,I d){if(!v)v=(d=((I*)m->line[I(y)+cy-100])[I(x)+cx-160])?d:0;else((I*)
6b->line[cy])[cx]=v;}I L(I x,I y){v=0;do_line(b,160,100,x,y,0,D);}I M(){o(x,W){L(
7x,0);L(x,199);}o(y,H){L(0,y);L(W-1,y);}}I R(I x,I y,I r,I l){if(l){circlefill(m,
8x,y,r,0);I a=(rand()%100)?1:2;o(i,a)R(x+rand()%(2*r)-r,y+rand()%(2*r)-r,(r+rand(
9)%10-5)>?10<?40,i?l/2:l-1);}}I G(){o(y,m->h){o(x,m->w){I c=(2*x+y)&127;putpixel(
10m,x,y,makecol(c+9,c+5,c));}}x=500;y=500;R(x,y,20+rand()%50,2500);rect(m,0,0,999,
11999,0x1C1A17);o(u,3*l)while(getpixel(m,e<u>,r<u>)){e<u>=rand()%m->w;r<u>=rand()%
12m->h;h<u>=1;}hp=10;}float M(I a){return fixtof(a);}I tr=0x40000,am=0xFFFFFF;I F(
13float f){xs+=f*M(fcos(k));ys+=f*M(fsin(k));}I main(){srand(time(0));allegro_init
14();install_keyboard();set_color_depth(32);set_gfx_mode(0,W,H,0,0);b=create_bitm\
15ap(W,H);m=create_bitmap(999,999);pl=create_bitmap(14,10);clear_to_color(pl,0xFF\
1600FF);triangle(pl,0,0,14,5,0,10,pc);G();while(!key[59]){clear_to_color(b,0x201B\
1715);if(key[84])F(.4);if(key[85])F(-.25);if(key[82])k=(k-tr)&am;if(key[83])k=(k+
18tr)&am;x+=xs;y+=ys;if(getpixel(m,x,y)){x-=xs;y-=ys;xs=ys=0;}n=0;o(u,99){if(h<u>)
19{n++;float N=x-e<u>,M=y-r<u>,L=sqrt(N*N+M*M)/5;if(!(Q%(9*(u+4)))){t<u>=e<u>;w<u>
20=r<u>;ts<u>=N/L;ws<u>=M/L;}circlefill(b,e<u>-x+160,r<u>-y+100,9,0xA24D1A);if(t[u
21]){t<u>+=ts<u>;w<u>+=ws<u>;if(getpixel(m,t<u>,w<u>))t<u>=0;circle(b,t<u>-x+160,w
22<u>-y+100,2,0xFDFDDA);}}}Q++;if(!n){l++;G();}M();if(--CT>0){E+=ES;T+=TS;o(u,99)
23if(h<u>&&(E-e<u>)*(E-e<u>)+(T-r<u>)*(T-r<u>)<85){CT=0;--h<u>;}if(getpixel(m,E,T)
24)CT=0;circle(b,E-x+160,T-y+100,2,0x000000);}else if(key[75]){E=x;T=y;ES=M(fcos(k
25))*9;TS=M(fsin(k))*9;CT=30;}Q++;rotate_sprite(b,pl,153,95,k);o(u,99){if(getpixel
26(b,t<u>-x+160,w<u>-y+99)==pc){t<u>=0;if(!--hp){exit(0);}}}blit(b,screen,0,0,0,0,
27320,200);}}END_OF_MAIN()

Gameplay:
Use left and right arrows to turn, up arrow to accelete, down arrow for inverse acceleration. Use space to fire the orange circular turrets. Dodge the turret fire, you'll resist only 10 of their bullets. You'll advance to a new level after all turrets are destroyed.

Hints:
The ship will accelerate quite fast, so don't press up for too long at once. Flying circles around the enemy turrets may help to dodge their fire. Never stay still! ;)

Issues:
There's no way to know how much hull you have left or what level you're playing. The game just quits if you die. The game may run too fast in high-end PCs (if that's an issue, just add a rest(something) -function before the second last '}'-character). And sometimes the game may just crash. Hopefully it doesn't happen too often. There are some minor graphical issues that can't be fixed, as that adds extra code. You may pass through the wall if you fly far too fast, and if you happen to fly out of the map this way, it's crash 'n' burn. The speed of the enemy bullets seems to increase if you fly too far from the enemies.

Chris Katko
Quote:

What, you think making it a struct suddenly means it's not OO? You think a struct can not have polymorphism, static members, or anything a class can't?

Private and protected members? Perhaps?

Zaphos

Etwinox: In C++ they a struct is allowed to have private and protected members. It just defaults to public.

Goodbytes

zaphire: Man, is it just me, or have you not posted here in like... either forever or a really long time? Keep up the Canadian gamedev bit! :)

Here's another "looks like the compo is progressing nicely" bit. I suppose I'll have to eventually draw the line somewhere...

So let's say that the deadline for a completed entry is Monday, February 16 2004. I realize that with time zones, that's a bit nonspecific, so... just try to have your entries in by around then, because that's probably about when we'll start the judging process. If you delay it past that time, you might run into some problems wherein I'll already have made the archive and can't be arsed to add your entry to it. :)

Fladimir: but maybe I'll give you some extra time if you need it. (unable to finish until next week you said?)

zaphire

No... I haven't posted here in ages...
...but believe, me I've been very busy with the Canadian gamedev bit; more specifically the Winnipeg gamedev bit! I'm currently working for three Winnipeg gamedev start-up companies, one of them being my own. ;) Check out my site below for more info.

Thomas Fjellstrom

I like that.. Extream Curling. Deffinitly a Canadian company ;)

23yrold3yrold

zaphire: Sweet. We'll get Josh Bolduc back and make Winnipeg the next Silicon Valley. 8-)

zaphire

I'm dumb!...
It was funny, I was talking to one of my girlfriend's friends... he was trying to convince me to move all operations to Vancouver. :P I was like.. No! There's something about being able to develop in an environment in which you can freeze to death on any given day that just makes it magical.

Fladimir da Gorf
Goodbytes said:

Fladimir: but maybe I'll give you some extra time if you need it. (unable to finish until next week you said?)

Yeah, that's true... :( I'm busy during the week and away most of the weekend. How about the next Wednesday?

lillo

Hi all, nice entries here!

I finally found the time and finished my own one... Here it is:

1#include <allegro.h>//Monospace Shooter 80x25 lines, in memory of Milo Sedlacek
2BITMAP *b[5],*r;int i,j,x,y,L,p,f,*l,W=320,H=200;volatile int t;int D[]={10,648
3,15,657,26,717,35,165,36,322,-1021313012,-2122071033,1597440,25149544,67100736,
48192,103284803,-1032834184,-2121207582,1644691152,133308448,-288325278,-103281\
50256,3373058,1124075048,8192,3145728,871893760,272880001,360844072,1217207235,\
6-1444069639,805047120,7356545,8384526,22511061,955345};void T(){t++;}BITMAP*G(\
7int*g,int s){int b=0,z=s&31;s>>=5;r=create_bitmap(s,z);z*=s;char*d=r->dat;for(;
8z;z--,d++){if(*g&(1<<b))*d=11;else*d=0;if(++b>31){b=0;g++;}}return r;}void main
9(){struct{int t;float x,y,vx,h;}e[W],*m=e+100,*o=e+H,*C,*M,*X,N={0,};allegro_i\
10nit();install_keyboard();install_int(T,15);set_gfx_mode(0,W,H,0,0);for(i=0,l=D;
11i<5;i++)b<i>=G(D+*l++,*l++);l=D;r=create_bitmap(W,H);t=x=f=p=0;y=L=96;memset(e,
120,sizeof(N)*W);for(;;){clear(r);for(i=99,C=o,M=m;i;i--,C++,M++){if(!C->t&&!(ra\
13nd()%50)){C->t=1;C->x=W;C->y=rand()%H;C->vx=-(rand()%9)/6.-1;}if(C->t==1){putp\
14ixel(r,C->x,C->y,11);if(C->x<0)*C=N;}if(C->t&2){circlefill(r,C->x+5,C->y+5,MIN(
15C->h,15),11);if(C->h>15)circlefill(r,C->x+5,C->y+5,C->h-15,0);C->h++;if(C->h>30
16)*C=N;}C->x+=C->vx;if(M->t==0&&key[75]&&!f){f=15;*M=N;M->t=1;M->x=x+20;M->y=y+3
17;M->vx=3;}if(M->t){if(M->x>W)M->t=0;draw_sprite(r,b[4],M->x,M->y);for(j=99,X=e;
18j;j--,X++){if(X->t&&M->x+9>X->x&&M->x<X->x+21&&M->y+2>X->y&&M->y<X->y+15){X->t=
192;X->h=0;*(X+H)=*X;*M=*X=N;break;}}}M->x+=M->vx;}for(i=99,C=e;i;i--,C++){if(C->
20t)draw_sprite(r,b[C->t],C->x,C->y);if(C->t==2)C->y+=sin(C->h);C->h+=.03;C->x+=C
21->vx;if(C->x<-20)*C=N;}draw_sprite(r,*b,x,y);blit(r,screen,0,0,0,0,W,H);while(!
22t);t=0;L--;if(!L){L=*l;C=e+p;for(i=0;i<16;i++,L/=4,C++){*C=N;C->t=L&3;C->x=W+(i
23%4)*24;C->y=((i/4)*50+C->t*25)%200;C->vx=-2./C->t;C->h=p;p++;if(p>99)p=0;}L=96;
24l++;if(l>D+36)l=D;}if(f>0)f--;if(key[82]&&x>0)x--;if(key[83]&&x<300)x++;if(key[
2584]&&y>0)y--;if(key[85]&&y<192)y++;if(key[59])break;}}END_OF_MAIN()// Finished!

Yes, it's a (very) stripped down version of the old Monospace Shooter (for those who don't know it, it's a QB game by Milo Sedlacek, who passed away some years ago).

Arrow keys to move, space to fire, ESC to exit.
It features three enemies, but none of them fires at you... Not enough space to handle enemy fire. Also not enough space to handle more complex enemy movements, nor enemy/player collisions... But you get 5 hardcoded sprites, scrolling starfield, multiple player bullets, explosions, static level data that repeats forever and fun!

Feedback is welcome!

23yrold3yrold
Quote:

There's something about being able to develop in an environment in which you can freeze to death on any given day that just makes it magical.

"Magical" ... that's not exactly the word that went through my mind when I woke up to -54C 2 weeks ago :P

Mind you, I imagine my Win98 box freezes in any given environment anyway ;)

Thomas Fjellstrom
Quote:

"Magical" ... that's not exactly the word that went through my mind when I woke up to -54C 2 weeks ago

And I thought the -38c we got a couple weeks ago was bad... Sure with windchill it was -50c... The entire week it was -50c with windchill.. Damn cold :)

23yrold3yrold

Yeah, that -54C is with the windchill. Before then, I'd never seen it go past -44C in Winnipeg. Then it hit -48C, then -50C (couldn't believe it; halfway to double digits), then -54C (#@&%!!) ... oy.

Anyway, enough OT :P ...

zaphire

Winnipeggers are just bred tougher because of the harsh conditions; henceforth we can survive through equally harsh crunch times.

Matthew Leverton

This was written for 20 semi's or less, so it doesn't fit in 25 lines. (Only 16 semi's, and no cheating using commas to execute multiple functions...)

#SelectExpand
1#include <allegro.h> 2#define B(x,y) b->line[x][y] 3#define P (B(22,7)) 4#define R (B(22,8)) 5int p[7][4][4][2]={{{{0,0},{0,1},{1,0},{1,1}},{{0,0},{0,1},{1,0},{1,1}},{{0,0},{ 60,1},{1,0},{1,1}},{{0,0},{0,1},{1,0},{1,1}}},{{{0,0},{1,0},{2,0},{3,0}},{{0,0},{ 70,1},{0,2},{0,3}},{{0,0},{1,0},{2,0},{3,0}},{{0,0},{0,1},{0,2},{0,3}}},{{{1,0},{ 80,1},{1,1},{2,1}},{{0,0},{0,1},{1,1},{0,2}},{{0,0},{1,0},{2,0},{1,1}},{{1,0},{0, 91},{1,1},{1,2}}},{{{2,0},{0,1},{1,1},{2,1}},{{0,0},{0,1},{0,2},{1,2}},{{0,0},{1, 100},{2,0},{0,1}},{{0,0},{1,0},{1,1},{1,2}}},{{{0,0},{0,1},{1,1},{2,1}},{{0,0},{1, 110},{0,1},{0,2}},{{0,0},{1,0},{2,0},{2,1}},{{1,0},{1,1},{0,2},{1,2}}},{{{0,0},{1, 120},{1,1},{2,1}},{{1,0},{0,1},{1,1},{0,2}},{{0,0},{1,0},{1,1},{2,1}},{{1,0},{0,1} 13,{1,1},{0,2}}},{{{1,0},{2,0},{0,1},{1,1}},{{0,0},{0,1},{1,1},{1,2}},{{1,0},{2,0} 14,{0,1},{1,1}},{{0,0},{0,1},{1,1},{1,2}}}};int main(void){BITMAP *b;if( 15allegro_init()?1:set_gfx_mode(GFX_AUTODETECT_WINDOWED,192,352,0,0)<0?1: 16install_timer()<0?1:install_keyboard()<0?1:!(b=create_bitmap_ex(8,SCREEN_W, 17SCREEN_H+50))?1:0)return 1;clear(b);rect(b,0,0,11,21,makecol(255,0,0));B(22,8)=( 18B(22,7)=(time(NULL)+(B(22,1)=(B(22,2)=1)+4))%7)*0;while(!key[KEY_ESC]&&B(22,0)== 190){while(retrace_count){if((B(22,1)+=(key[KEY_LEFT]&&!(B(22,4)%4)&&!(B(B(22,2)+p 20[P][R][0][1],B(22,1)+p[P][R][0][0]-1)+B(B(22,2)+p[P][R][1][1],B(22,1)+p[P][R][1] 21[0]-1)+B(B(22,2)+p[P][R][2][1],B(22,1)+p[P][R][2][0]-1)+B(B(22,2)+p[P][R][3][1], 22B(22,1)+p[P][R][3][0]-1))?-1:key[KEY_RIGHT]&&!(B(22,4)%4)&&!(B(B(22,2)+p[P][R][0 23][1],B(22,1)+p[P][R][0][0]+1)+B(B(22,2)+p[P][R][1][1],B(22,1)+p[P][R][1][0]+1)+B 24(B(22,2)+p[P][R][2][1],B(22,1)+p[P][R][2][0]+1)+B(B(22,2)+p[P][R][3][1],B(22,1)+ 25p[P][R][3][0]+1))?1:0))&&(B(22,2)+=((!(B(22,4)++%32)||key[KEY_DOWN])&&!(B(B(22,2 26)+p[P][R][0][1]+1,B(22,1)+p[P][R][0][0])+B(B(22,2)+p[P][R][1][1]+1,B(22,1)+p[P][ 27R][1][0])+B(B(22,2)+p[P][R][2][1]+1,B(22,1)+p[P][R][2][0])+B(B(22,2)+p[P][R][3][ 281]+1,B(22,1)+p[P][R][3][0]))?1:0))&&(1+(B(22,8)=(B(22,8)+((key[KEY_UP]&&!(B(22,4 29)%4)&&!(B(B(22,2)+p[P][(B(22,8)+1)%4][0][1]+1,B(22,1)+p[P][(B(22,8)+1)%4][0][0]) 30+B(B(22,2)+p[P][(B(22,8)+1)%4][1][1]+1,B(22,1)+p[P][(B(22,8)+1)%4][1][0])+B(B(22 31,2)+p[P][(B(22,8)+1)%4][2][1]+1,B(22,1)+p[P][(B(22,8)+1)%4][2][0])+B(B(22,2)+p[P 32][(B(22,8)+1)%4][3][1]+1,B(22,1)+p[P][(B(22,8)+1)%4][3][0]))?1:0)))%4))&&(!(B(22 33,4)%32)&&(B(B(22,2)+p[P][R][0][1]+1,B(22,1)+p[P][R][0][0])+B(B(22,2)+p[P][R][1][ 341]+1,B(22,1)+p[P][R][1][0])+B(B(22,2)+p[P][R][2][1]+1,B(22,1)+p[P][R][2][0])+B(B 35(22,2)+p[P][R][3][1]+1,B(22,1)+p[P][R][3][0])))){B(22,3)=B(B(22,2)+p[P][R][0][1] 36,B(22,1)+p[P][R][0][0])=B(B(22,2)+p[P][R][1][1],B(22,1)+p[P][R][1][0])=B(B(22,2) 37+p[P][R][2][1],B(22,1)+p[P][R][2][0])=B(B(22,2)+p[P][R][3][1],B(22,1)+p[P][R][3] 38[0])=1;while(++B(22,3)<21)if(B(B(22,3),1)+B(B(22,3),2)+B(B(22,3),3)+B(B(22,3),4) 39+B(B(22,3),5)+B(B(22,3),6)+B(B(22,3),7)+B(B(22,3),8)+B(B(22,3),9)+B(B(22,3),10)\ 40==10)blit(b,b,1,1,1,2,10,B(22,3)-1);if(1+(B(22,8)=(B(22,7)=(time(NULL)+(B(22,1)= 41(B(22,2)=1)+4))%7)*0)&&(B(B(22,2)+p[P][R][0][1],B(22,1)+p[P][R][0][0])+B(B(22,2) 42+p[P][R][1][1],B(22,1)+p[P][R][1][0])+B(B(22,2)+p[P][R][2][1],B(22,1)+p[P][R][2] 43[0])+B(B(22,2)+p[P][R][3][1],B(22,1)+p[P][R][3][0])))B(22,0)=1;}retrace_count=0; 44}rectfill(b,50,SCREEN_W,50+SCREEN_H,SCREEN_W,0);stretch_blit(b,b,(B(22,3)=0),0,\ 4512,22,0,50,192,352);while(B(22,3)++<4){rectfill(b,(B(22,1)+p[P][R][B(22,3)-1][0] 46)*16,50+(B(22,2)+p[P][R][B(22,3)-1][1])*16,14+(B(22,1)+p[P][R][B(22,3)-1][0])*16 47,50+14+(B(22,2)+p[P][R][B(22,3)-1][1])*16,makecol(255,255,255));}blit(b,screen,0 48,50,0,0,SCREEN_W,SCREEN_H);}destroy_bitmap(b);return 0;}END_OF_MAIN()

Fladimir da Gorf

Lillo, I tried your game, but all I could see was a starfield, and if I pressed space, also explosions here and there. :/ Oh, and does your starfield really have a motion blur effect, or is it just my monitor doing tricks?

Thomas Fjellstrom
Quote:

Lillo, I tried your game, but all I could see was a starfield, and if I pressed space, also explosions here and there. :/ Oh, and does your starfield really have a motion blur effect, or is it just my monitor doing tricks?

Thats unfortunetly all I got as well :( no sprites, just a star field, bullets, and explosions.

zaphire
Quote:

Thats unfortunetly all I got as well no sprites, just a star field, bullets, and explosions.

That's way more features than some commercial games.

Billybob

zaphire: your link is a little broken, I had to type it in manually. Anyway, that's funny stuff. What was going through that company's mind when they released that game? I guess maybe they thought people would buy it just so they could have a good laugh.

Marcello

Matt: could you compress that even more by grouping all those arrays into single numbers using bits?

Marcello

Matthew Leverton

I know - the original restriction was just line numbers (semicolons), so I didn't bother with anything like that. It still contains a lot of other things that could be redone for char count. All I did above was use a couple #defines to shorten the code.

I'm sure one could get an allegro tetris game in 25x80, but I don't have the time to waste at the moment...

Karadoc ~~

Krzysztof, that is truely an impressive piece of coding.

zaphire

William: Yeah.. its hilarious. Not sure why the link isn't working, might have something to do with gamespot trying to kill Allegro.cc's frame code. For more information (like how the company hired russian programmers to do the coding - because they claim its cheaper) check out this thread: http://www.complexgames.com/forum/viewtopic.php?t=307

Thomas Fjellstrom

zaphire, uh no, its because you have the format for allegro.cc's links wrong :P its [URL addr]title[/URL] not [URL="addr"]title[/URL] (all lower case of course).

zaphire

Foiled again. ^_^ Maybe I should start getting some sleep soon... :\

Derezo

heheheh. That was well worth the read. Absolutely hilarious. Almost hard to believe they could do that bad.. like, no sound? No collisions? No racing in a racing game? No level boundaries? Geez. Unless it's included in a 99 cent bundle of 10 similar games, I just don't understand how something like that could ever get published ::)

zaphire

I love the reader reviews...the guy who examines its possible artist interpretations is right on.

"What is the point of even trying? comes a plaintive cry from Big Rigs. The answer is apparent. There is no point.

Time to lay down and die. This comment on society is driven home (or in fact, not driven at all) even further by the computer AI. It doesn't even leave the starting gate. Much like the dreams and aspirations we harbour as youth, reving our engines on a starting line where the crack of the pistol never comes. Meanwhile, those of privledge cruise to easy victory, unconcerned over such mundane things as rent or grocery bills or collideable landscapes. The societal implications here in the game are staggering."

Yet further proof that Video Games = Art. (not that I needed any)
:P

Billybob

Funny, yet my brain has left my head and is now eating itself over trying to understand why this was ever released as a game? It's worse than looking at the Windows code(which will corrupt anything you code from that point on). Just...just...horrible...

This isn't art, this is pure agony.

zaphire

It can't not be art... but it can be bad art.

Zaphos

zaphire: You'd probably enjoy lucky wander boy -- it's a book in which the main character reviews old video games in that style (as well as doing many other things, but the video game reviews are central to the plot). For example, in the midst of a Donkey Kong review, we get lines like: "It is difficult to ignore the similarities between Donkey Kong (the creature) and the demiurge of the Gnotic heresies." ... great wtf factor, there.
(And aside from that, it's just a good book)
(Oh, and it's by d. b. weiss)

And yeah, that review (the truck one you pointed out) is awesome.

lillo

Sorry for the delay... I checked this thread the day after I posted my entry, and found no feedback, and I checked it again only yesterday. So since then I've hacked my code a bit to make it work on Windows too (I coded it under MacOS X and it worked fine under it; it was a matter of a D+*l++ expression that under Win didn't work as it was meant to... weird), and as I was there I also improved the "packing" of the code, allowing me to add proper collision detection between enemies and player... so the player can now die and the game end :)
No space to add proper score keeping though :(

Anyway, here it is (again):

1#include <allegro.h>//Monospace Shooter 80x25 lines, in memory of Milo Sedlacek
2BITMAP*b[5],*r;char*d;volatile int t,E,i,j=0,x,y,L,p,f,*l,W=320,H=200,D[]={10,\
3648,15,657,26,717,35,165,36,322,-1021313012,-2122071033,1597440,25149544,67100\
4736,8192,103284803,-1032834184,-2121207582,1644691152,133308448,-288325278,-10\
532810256,3373058,1124075048,8192,3145728,871893760,272880001,360844072,1217207\
6235,-1444069639,805047120,7356545,8384526,22511061,955345};void T(){t++;}BITMAP
7*G(int*g,int s){j=0;x=s&31;s/=32;r=create_bitmap(s,x);x*=s;d=r->dat;for(;x;x--,
8d++){*d=0;if(*g&(1<<j))*d=11;++j>31?j=0,g++:0;}return r;}void main(){struct{int
9t;float x,y,v,h;}e[W],*m=e+100,*o=e+H,*C,*M,*X,N={0,};allegro_init();install_k\
10eyboard();install_int(T,15);set_gfx_mode(0,W,H,0,0);for(i=0,l=D;i<5;i++,l++)b[i
11]=G(D+*l,*(++l));l=D;r=create_bitmap(W,H);t=x=f=p=0;y=L=E=96;memset(e,0,sizeof(
12e));while(E){clear(r);for(i=99,C=o,M=m;i;i--,C++,M++){j=rand();if(!C->t&&i<80)C
13->t=1,C->x=W,C->y=j%H,C->v=-(j%9)/6.-1;if(C->t&1)putpixel(r,C->x,C->y,11);if(C\
14->x<0)*C=N;if(C->t&2){circlefill(r,C->x+5,C->y+5,MIN(C->h,15),11);C->h>15?circ\
15lefill(r,C->x+5,C->y+5,C->h-15,0):0;C->h++;if(C->h>30)*C=N;}C->x+=C->v;if(!M->t
16&&key[75]&&!f)f=15,*M=N,M->t=1,M->x=x+f,M->y=y+3,M->v=3;if(M->t){M->x>W?M->t=0:
170;draw_sprite(r,b[4],M->x,M->y);for(j=99,X=e;j;j--,X++)if(X->t&&M->x+9>X->x&&M\
18->x<X->x+21&&M->y>X->y&&M->y<X->y+16)X->t=2,X->h=0,*(X+H)=*X,*M=*X=N;}M->x+=M->
19v;}for(i=99,C=e;i;i--,C++){C->t?draw_sprite(r,b[C->t],C->x,C->y):0;C->t==2?C->y
20+=sin(C->h):0;C->h+=.02;C->x+=C->v;if(C->x<-20)*C=N;if(E>0&&x+15>C->x&&x-15<C->
21x&&y+9>C->y&&y-9<C->y)o->t=2,o->h=0,o->x=x,o->y=y,E=-E;}E>0?draw_sprite(r,*b,x,
22y):0;blit(r,screen,0,0,0,0,W,H);for(t=0;!t;);L--;if(!L){L=*l;C=e+p;for(i=16;i;i
23--,L/=4,C++){*C=N;C->t=L&3;C->x=W+(i%4)*24;C->y=((i/4)*50+C->t*25)%H;C->v=-3./C
24->t;C->h=p;p++;p>99?p=0:0;}L=E;l++;l>D+36?l=D:0;}f?f--:0;E<0?E++:0;if(key[82]&&
25x)x--;if(key[83]&&x<W)x++;if(key[84]&&y)y--;if(key[85]&&y<H)y++;}}END_OF_MAIN()

Arrows to move, space to fire. To end the game, you must die ;)

Zaphos

lillo: I can't see my avatar in the game; the starfield and enemies seems to work fine, as do collision and firing as I can make stuff exploded and can die myself, but I have no idea where my guy is.

lillo

humm, it works fine under WinXP... I compiled the code with
gcc -s -O3 mono.c -o mono.exe -lalleg
and apart from two warnings it's ok. My gcc is 2.95.3-5 from an old MingW32 version.

Anyone else experimenting problems with my entry?

Zaphos

With those options I get:
gcc -s -03 blah.c -o blah `allegro-config --libs`
gcc: unrecognized option `-03'
blah.c: In function `_mangled_main':
blah.c:11: warning: passing arg 1 of `G' discards qualifiers from pointer target type

And the same bug regarding the player not appearing.
I can't actually see the player's shots either; I only presume they exist 'cause enemies blow up when I hold space.

I'm using "gcc version 3.3.3 20040125 (prerelease) (Debian)" and (of course) Debian linux.

Billybob

Zaphos:
-O3
as in, Oh Three. Not Zero Three.

Krzysztof Kluczek

lillo: Works fine on DJGPP. :) The only bug I`ve found is that player go outside the screen at bottom a bit and some score system could be great. Anyway, nice game with nice graphics. :)

Zaphos

WH: Ooop! :-[
It seems that when I compile with -O3 the program works perfectly! But when I compile without optimizations the sprites are garbled and there are no player / player bullets. Weird ... lillo is clearly doing something crazy in there ...
Good game, though! Nice gfx!
Edit: If one goes up at the very beginning, one seems to spontaneously combust ...

Billybob

lillo: Well I tried to compile it myself and got nothin but a load of errors. invalid conversions from void * to char*, memset undeclared, etc... Big list of errors. I'm using MinGW32 3.2.3 and the compiler options you specified.

EDIT: nm, changed filename to mono.c and compiled with gcc.

EDIT: wow, that's a great game for 80x25.

lillo

Attached is a new (the last, I promise!) version of my entry. I'm not inlining it as code not to bloat this thread even more than it already is... Anyway, I've had an idea on how to pack the source even more; my sprites data was stored as integer numbers... that take much space. So I converted them all to a big string and modified the sprite generation algorithm. The result is I saved 1 line and a half, and with some clever coding I used them to add score keeping, hi-score and game restart after you die. Oh, and mines now chase you :)
Have fun, and press ESC to quit at any time!

Ryan Broomfield

JEBUS! I <3 THIS ENTRY LILLO. You've got my vote unless i can vote for myself <3

Billybob

Is the compition over now? It's the 17th, didn't it end the 16th... I wanna know who wins ;D

Goodbytes

Nah, it's not over. Cause I'm not done my own entry.

Yeah, I'm taking advantage of my position. :)

CGamesPlay

Hehe. I have some syntax coloring code for my entry, but MSVC's debugger is offsetting everything in my code by 18 lines, so it's rather hard to debug it :)

Krzysztof Kluczek
Quote:

but MSVC's debugger is offsetting everything in my code by 18 lines

You could use #line macro.
#line <next-line-no> "<file-name>"

Well, maybe I`ll manage to finish my second entry. :)

lillo

ok, I promised not to post a new version again, but I discovered some bugs, and I had to fix them, you know ;D And on the way I also compressed the thing a bit more, to add a start and game over text... I could save another 2-3 characters but no way to use them, so I wasted them for alignment purposes 8-)

So I'm attaching it here; I feel authorized as the competition still has no deadline set... GoodBytes, are you still there?

Krzysztof Kluczek

Well, I don`t want to nitpick, but third line has 81 chars in it so I guess you`ll have to post again. :P

Anyway, still very nice game (but I think I liked teal color more). :)

lillo

D'oh!!

Under my IDE on OSX that line was shown to be 80 characters... This is a side effect of using a binary string for data... even if I only used characters 96-223 (7 bit) exactly to avoid this!

Anyway, it's now fixed. And I also fixed another little bug with mines :)
BTW, also changed color back to cyan; I also liked it more, but the use of white was not random: I needed the constant "15" on other places of the code too, so... But now I optimized things a bit and made it possible to use cyan again. Actually you can change the color to whatever you like without other consequences: just modify the "c" variable, declared at line 2.

Krzysztof Kluczek
Quote:

And I also fixed another little bug with mines

I thought that was a feature. They had really cool movement (although a bit illogical). :)

lillo

The bug was their vertical speed was not limited while it should have been. Now they still chase you, but when you approach them their speed will be high instead of very high. And maybe now they're more deadly as their horizontal speed is a bit higher than the player's one, so you can't step back easily to destroy them if they're near you...

Marcello

My highscore on this version was 481, while ~340 on the previous.

For some reason my keyboard doesn't like up+left at the same time, that really cramps my style. Any chance on a non 80x25 version with either key config, or gamepad support?

Marcello

Krzysztof Kluczek

I played it a bit too and got 1719. ;D

lillo: maybe you could replace space key with a Ctrl or Alt? Keyboards should behave better with eg. Ctrl still held down than with space (on mine space key wasn`t any problem). :)

[edit: new highscore: 2751 ;D]

Goodbytes

I'm still here! Just bogged down with work. I'm not going to disappear into a black hole or anything. I am currently both
(a) very busy, and
(b) very not finished my entry and deciding to unfairly extend the competition until I'm done
But I'll try to finish it up. Basically I just have to compress the thing. And it's really nothing overly special, so don't expect something logical, like it being a good entry since I had lots of time.

Anyway this thing will be wrapping up soon.

Billybob

post code and we'll compress it. ;D

Krzysztof Kluczek

Could I post my new project for a little compression? ;)

I think I`ll manage to do it myself since I need only few bytes. I`m writing a Rogue-like Hack`n`Slash RPG with experience, spells, items, monsters, dynamically generated dungeons and everything what RPG should have. :) I have a beta written but it still needs a lot of balancing. Any beta-testers? ;D

I think, we should make 4096 bytes code competition someday. Nice game engine can be fit in 2k and there will be another 2k for really nice gameplay. This could be very interesting. :)

Pyykkö

I wrote this about two weeks ago, try to escape from The Dungeon Of Infinitum ;)

1#include "allegro.h"
2#define a(z){px+=cos(pa)*z;py+=sin(pa)*z;}
3#define b blit(dblbuf,screen,0,0,0,0,320,240)
4#define c pa+((float)(sx-160)/160.0)
5#define d 6.283185
6#define e(y,x,w) for(y=0;y<x;y+=w)
7#define f clear_bitmap(dblbuf)
8#define g(u,v) textprintf_ex(dblbuf,font,u,v,255,0,
9static volatile int t;static void tmr(void){t++;}END_OF_FUNCTION(tmr);int main(
10void){float px,py,px2,py2,pa;int sx,tx,ty;float vx,vy,vd;float vdm;BITMAP*dblbuf
11;char map[4096];allegro_init();install_keyboard();install_timer();set_color_dep\
12th(32);set_gfx_mode(GFX_AUTODETECT,320,240,0,0);LOCK_VARIABLE(t);LOCK_FUNCTION(\
13tmr);install_int_ex(tmr,23863);dblbuf=create_bitmap(320,240);e(sx,4096,1){map[s\
14x]=(rand()*sx)&15;if(map[sx]<9)map[sx]=0;}f;g(100,8)"Lichtenstein 3D 2");g(0,24)
15"You woke up in a cave without any idea");g(0,32)"who you are or where you are.\
16");g(0,40)"All you know is that you have to escape.");g(70,64)"Press EnTER to c\
17ontinue");b;while((readkey()>>8)!=KEY_ENTER);px=py=pa=0;while(!key[KEY_ESC]){if(
18key[KEY_LEFT])pa-=0.05;if(key[KEY_RIGHT])pa+=0.05;if(pa<0)pa=d+pa;if(pa>d)pa=pa-
19d;px2=px;py2=py;if(key[KEY_UP])a(0.1);if(key[KEY_DOWN])a(-0.1);tx=(int)px&63;ty=
20(int)py&63;if(map[ty*64+tx]){px=px2;py=py2;}t--;while(t<0);if (t<1){clear_bitmap
21(dblbuf);e(sx,320,4){vd=0;vdm=0.5;vx=cos(c)*vdm;vy=sin(c)*vdm;while(vd<128&&vd>=
220){vd+=vdm;tx=(int)(px+vx*vd)&63;ty=(int)(py+vy*vd)&63;if (map[ty*64+tx]){if (v\
23dm!=0.125){vd-=vdm;vx/=2;vy/=2;vdm/=2;}else vd=-vd;}}if (vd<0){vd=-vd;rectfill(
24dblbuf,sx,120-240/vd,sx+3,120+240/vd,(map[ty*64+tx]*17)*(1-(vd/128)));}}b;}}ret\
25urn(0);}END_OF_MAIN();

CGamesPlay

KK: Call it 100h and allow people that many bytes in their source. I almost did that, but it evolved into ACG.

Billybob

Don't you mean 1000h? Not sure you can do much of anything in 100h.

Krzysztof Kluczek

I meant 1000h of course (4096b). :) Maybe I`ll think about organizing it (unless Goodbytes would like to do it - he has much more experience in this) but not too soon since we have ScreenHack now. :)

btw. I`ll check and I`ll try to fit some thing into 100h. :) Anyway I made <100h (248b exactly) .com dos demo which was animated Julia set (but it was in asm and I put restriction on executable so I had more space).

LSd016
Quote:

Not sure you can do much of anything in 100h.

I've seen a wolf-like 3d engine in 100h. I don't have it anymore though.

Billybob

100h of source code, or a 100h executable? 100h executable, that seems alright, but 100h of source is only 80x3.2, heh.

LSd016

obviously it was a headerles executable for dos - .com

Niunio
Krzysztof Kluczek said:

I think, we should make 4096 bytes code competition someday. Nice game engine can be fit in 2k and there will be another 2k for really nice gameplay.

Videopac G7000 game executables have 2Kb wide...

And for those that are waiting for the ScreenHack collection, I am too busy now, but I was test all entries of the first page and selected some of them. I'll try to upload it this week-end.

Krzysztof Kluczek

Actually, I was thinking about 4kb limit for source code size. :)

Niunio

...80x25=2000...

4kb would be cool too.

[side note]Wow, this tread is pretty big...

GB, finish you entry soon, before Matthew close this madness!

CGamesPlay

Niunio: That's what pages are for. Actually, I hated pages until I decided to split up threads on the 100 marks, because it was taking so long to render.

Marcello
Quote:

Videopac G7000 game executables have 2Kb wide...

That's some mad image compression.

Marcello

Niunio

Marcello: What? Image compression?

VG7K was a video-game console from late '70. I have some original cartridges that announces Memory Extended 4Kb:o

Billybob

Wow, this combo has almost gone on for an entire month :P

Ryan Broomfield

please end it so we can vote ;)

Krzysztof Kluczek

I think this competition is taking a bit too long too. :P

Well, maybe I`ll manage to finish my 80x25 RPG (some balancing left) although I`m not working on it too hard (read: recently not at all). :P

btw. I wonder if I was writing multiplayer game would I be allowed do make two apps: 80x25 server and 80x25 client for it? ;D

Goodbytes

Sorry guys, I know we should be done the voting by now, but I got really swamped with schoolwork coupled with extracurricular activities and everything... I'm almost done putting everything together.

So, anyway, no new entries.

Thread #331094. Printed from Allegro.cc