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
Tobias Dammers
Member #2,604
August 2002
avatar

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

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Marcello
Member #1,860
January 2002
avatar

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

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]

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

Billybob
Member #3,136
January 2003

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

Niunio
Member #1,975
March 2002
avatar

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.

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

Ben Jacobs
Member #3,207
February 2003

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
Member #1,860
January 2002
avatar

Quote:

allegro_message(""+score);

It ain't java, ya know.

Try ("%i",score).

Marcello

Ben Jacobs
Member #3,207
February 2003

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

Niunio
Member #1,975
March 2002
avatar

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

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

Goodbytes
Member #448
June 2000
avatar

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?


--
~Goodbytes

Billybob
Member #3,136
January 2003

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

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

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

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

Marcello
Member #1,860
January 2002
avatar

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

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

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


--
~Goodbytes

Krzysztof Kluczek
Member #4,191
January 2004
avatar

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
Member #3,935
October 2003
avatar

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

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
Member #1,860
January 2002
avatar

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

Marcello

ImLeftFooted
Member #3,935
October 2003
avatar

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
Member #250
April 2000
avatar

How about some screenshots?

Mark Hall
Member #4,002
November 2003

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
Member #3,935
October 2003
avatar

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
Member #846
December 2000

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



Go to: