Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

simple Allegro example (Announce)

posted by DOS386, 09.05.2008, 07:33

> Allegro. It's a quite nice library.

#include <allegro.h>//Monospace 80x25, in memory of Milo Sedlacek, by EC++ 2004
volatile int t,E,i=0,j=6,x,y,L,p,f,S,h,W=320,H=200,A=96,c=11;char*d,*g,*D="l``"
"yÜ`Ñ¡aa`£a`zÀßb`bÞß``?``xd`jcØÆ s?|?¨aÛ??lhpÒohkhº?ØpÁiv`Ïl`?l`xd`h```l``vÀ"
"sÔp°?p¸ÂÐmmqÅ׳??kØ?ihh|`nÀßc´Î×ÊÈs}",*I="thtqvmeejb";BITMAP*b[5],*r;void T
(){t++;}int main(){struct{int t;float x,y,v,h;}e[W],*m=e+A,*o=e+H,*C,*M,*X,N={0
,};g=D;allegro_init();install_keyboard();install_int(T,15);set_gfx_mode(0,W,H,0
,0);for(;i<5;i++){x=*I++-A;f=*I++-A;r=b[i]=create_bitmap(x,f);d=r->dat;for(x*=f
;x;x--){++j>6?y=*g++-A,j=h=0:0;*d++=y&(1<<j)?c:0;}}r=create_bitmap(W,H);for(;!E
;){text_mode(-1);g=D;t=x=f=p=S=0;y=L=A;E=H;memset(e,0,sizeof(e));while(E&&!key[
59]){clear(r);for(i=A,C=o,M=m;i;i--,C++,M++){j=rand();if(!C->t&&j&1)C->t=1,C->x
=W,C->y=j%H,C->v=-j%9/6.-1;if((C->x+=C->v)<0)*C=N;if(C->t&2){circlefill(r,C->x+
5,C->y+5,MIN(C->h,15),c);C->h>15?circlefill(r,C->x+5,C->y+5,C->h-15,0):0;if(C->
h++>30)*C=N;}C->t&1?putpixel(r,C->x,C->y,c):0;if(!M->t&&key[109]&&!f)f=9,*M=N,M
->t=1,M->x=x+16,M->y=y+3,M->v=4;if(M->t){M->t*=(M->x+=M->v)<W;draw_sprite(r,b[4
],M->x,M->y);for(j=A,X=e;j;j--,X++)if(X->t&&M->x+9>X->x&&M->x<X->x+c&&M->y>X->y
&&M->y<X->y+15)S+=X->t,X->t=X->h=2,*(X+H)=*X,*M=*X=N;h=S>h?S:h;}}draw_sprite(r,
*b,x,y);for(i=A,C=e;i;i--,C++){C->t?draw_sprite(r,b[C->t],C->x,C->y):0;C->y+=(C
->t==2)*sin(C->h)+(C->t==3)*MIN(3/(abs(C->x-x)/8.),2)*(C->y<y?1:-1);C->h+=44;if
((C->x+=C->v)<-A)*C=N;if(E>0&&C->t&&x+c>C->x&&x-c<C->x&&y+9>C->y&&y-9<C->y)o->t
=2,o->h=o->v=0,o->x=x,o->y=y,f=E=-E*3,x=-W;}d=E<0?"Game Over":E>A?" Start!!":I;
for(;!t;);if(!--L){L=*(int*)g;C=e+p;for(i=16;i;L/=4,C++){*C=N;C->t=L&3;C->x=W+i
%4*24;C->y=(i--/2*A+C->t*25)%H;C->v=-3.5/C->t;C->h=p++;p&=63;}L=E;g=g>D+115?D:g
+4;}textout(r,font,d,124,A,c);textprintf(r,font,t=0,0,c,"SC %04d   HI %04d",S,h
);blit(r,screen,0,0,0,0,W,H);E<0?E++:E>A?E--:0;if(E>0){if(key[82]&&x)x--;if(key
[83]&&x<W)x++;if(key[84]&&y)y--;if(key[85]&&y<H-8)y++;}f?f--:0;}}}END_OF_MAIN()


Your preferred coding style ? :lol:

[image]

It's impressive ... in many aspects:

- Tiny source :-)
- Works :-) ... but very "cheap" example only: no VESA, no mouse, no sound, no file I/O, very little RAM, ... :-|
- Can't play it, get assassinated within 10 seconds at most :crying:
- Extremely bloated - 540 KiB for such a simple game ... same size as DUGL PLAYER hogs, including MPEG-1 and MPEG-2 codec, VESA, GUI, mouse, and, DUGL still uses D compiler ... a DUGL PLAYER in ASM could be even much smaller. Such a simple game written in ASM would fit into 2 KiB and work on 8086 with MGA card :-) ... maybe some experts would push it even into 256 bytes ? :hungry:

---
This is a LOGITECH mouse driver, but some software expect here
the following string:*** This is Copyright 1983 Microsoft ***

 

Complete thread:

Back to the forum
Board view  Mix view
22632 Postings in 2109 Threads, 402 registered users, 536 users online (0 registered, 536 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum