Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » The 2004 Allegro ScreenHack

This thread is locked; no one can reply to it. rss feed Print
The 2004 Allegro ScreenHack
Mark Hall
Member #4,002
November 2003

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
Member #4,191
January 2004
avatar

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
Member #1,975
March 2002
avatar

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.

-----------------
Current projects: Allegro.pas | MinGRo

LSd016
Member #3,561
May 2003

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

____________________________________________
[update soon]

Breakman79
Member #1,236
April 2001
avatar

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
Member #4,191
January 2004
avatar

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
Member #3,136
January 2003

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
Member #1,236
April 2001
avatar

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 ~~
Member #2,749
September 2002
avatar

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
Member #1,468
August 2001

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
Member #1,975
March 2002
avatar

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...

-----------------
Current projects: Allegro.pas | MinGRo

Harpreet Singh
Member #4,269
January 2004

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
Member #1,236
April 2001
avatar

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
Member #2,559
July 2002
avatar

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 :)).

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Niunio
Member #1,975
March 2002
avatar

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.

-----------------
Current projects: Allegro.pas | MinGRo

Krzysztof Kluczek
Member #4,191
January 2004
avatar

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

Dustin Dettmer
Member #3,935
October 2003
avatar

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
Member #448
June 2000
avatar

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.


--
~Goodbytes

Wetimer
Member #1,622
November 2001

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?

<code>if(Windows.State = Crash) Computer.halt();</code>

Billybob
Member #3,136
January 2003

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
Member #2,633
August 2002
avatar

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
Member #2,559
July 2002
avatar

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

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Billybob
Member #3,136
January 2003

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
Member #4,191
January 2004
avatar

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
Member #1,236
April 2001
avatar

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



Go to: