|
2007 Allegro ScreenHack, 80x25 compo |
Kikaru
Member #7,616
August 2006
|
At last! My entry is done. Use left and right to move, press up to flap. If you hit the boxes or leave the screen, it's game over. I may add highscore records later.
|
Neil Black
Member #7,867
October 2006
|
I can fly right through the boxes on yours Kikaru. EDIT: I made one! Left and right turn, space fires. As you can see, there is a lot of room for improvement (both in adding more code and improving gameplay).
|
kenmasters1976
Member #8,794
July 2007
|
<quote name=""Næssén""> <quote name=""Ted Steen""> Matthew Leverton's Tetris is only 17 lines long!. There must be something really wrong with mine. I might try to steal something from his code... Now, today I watched a Saint Seiya marathon on TV, that means no activity today and no time to check the new entries. I'll get up to date tomorrow.
|
Matthew Leverton
Supreme Loser
January 1999
|
Quote: Those of you making Tetris should figure out a way to use more color . Mine uses all 16 colors from the classic CGA palette. Quote: Matthew Leverton's Tetris is only 17 lines long!. There must be something really wrong with mine. I might try to steal something from his code... Mine is pretty minimalistic, although there are a couple things that I need to change up to save some space. To make Tetris, all you need to do per frame is:
[/list] It's just about storing the data in as compact of a way without sacrificing ease of access. I used a bit field; I think with some creativity, it could be a lot simpler. You never really need random access to the data. It's always done in a 4x4 loop, so I think one should optimize with that in mind. |
Arvidsson
Member #4,603
May 2004
|
Kikaru: I can fly through the boxes and sometimes when I go offscreen I can continue flying even though it's game over. Nice idea though! Neil: Hmm, when the game starts it's all black. When I press a key it says lose and when I shoot, the bullets seem to only update when I hold a key. And I don't see anything to shoot at.
|
Matthew Leverton
Supreme Loser
January 1999
|
Slightly more compact than my first version. I removed duplicate positions in the s[] array (e.g., the square only has one "angle"). But obviously that made the logic a bit more complex. Thus, I introduced j[] to point to the first position in s[] per block and to declare how many angles each piece has. j[q+7] just equals j[q+1]-j[q], but it was slightly more compact to expand it since it simplified the math and let me store the square piece as 2 bytes. I also created a F() shortcut for rectfill and replaced retrace_count with just a simple rest(). |
Arvidsson
Member #4,603
May 2004
|
Sokoban Clone! You are the greyish block. Move and push with arrowkeys. Press R to restart level. Your goal is to push the orange blocks into the red ones. There are 5 levels. I hope they are beatable The levels were made by Yoshio Murase
This will be my last entry. Life called.
|
Kikaru
Member #7,616
August 2006
|
The problem would be if you go through the boxes without triggering game over. Otherwise, it's just because I was low on codespace, and if I tried to stop movement when you die, it crashes. I'll figure it out a little later. [EDIT]Grr... It's not working. Something seems to be wrong with H(), my collision function. It doesn't seem to be recognising collisions most of the time. Also, as of now, the "leaving the screen" code doesn't work either, but that should be easy to fix.
New code, which still doesn't work. |
Trezker
Member #1,739
December 2001
|
#define W makecol(255, 255, 255)/////////////////////////////////////////////// Now that's what I call a huge waste... You can also replace GFX_AUTODETECT_WINDOWED with 2. |
Kikaru
Member #7,616
August 2006
|
oh, nice. I'll probably do another game, as I really didn't like this one very much. Probably a shooter of some kind. I'm pretty good at making those. |
Matthew Leverton
Supreme Loser
January 1999
|
Macros are a waste of space unless they take up the entire line. Using functions is generally better if possible: #define W makecol(255, 255, 255)/////////////////////////////////////////////// #define G makecol(255, 255, 0)///////////////////////////////////////////////// W(){return makecol(255,255,255);}G(){return makecol(255,255,0);} // but it's just as easy to do this in your main routine: int W=0xffffff,G=makecol(255,255,0); Use global variables to avoid passing function parameters. Also, this is an evil way to save some space: void a(){int A=1;} a(){int A=1;} a(A){A=1;} Stuff like this can really add up, giving you that extra line. |
Kikaru
Member #7,616
August 2006
|
I think almost all of my functions were int, but I'll use that for my void functions. |
Arthur Kalliokoski
Second in Command
February 2005
|
Quote: Mine uses all 16 colors from the classic CGA palette. CGA only had 4 colors in 320 x 200, 2 colors in 640 x 200. Maybe you meant EGA? They all watch too much MSNBC... they get ideas. |
Trezker
Member #1,739
December 2001
|
I cooked up this today. It's ugliest piece of code I've made in years, and I haven't even tried to opimize space yet since there's plenty left. Hmm, I wonder.. Isn't this the first time ever that I've participated in a coding event?!
|
Matthew Leverton
Supreme Loser
January 1999
|
Quote: I think almost all of my functions were int, but I'll use that for my void functions. The functions default to int, but you can use them as if they were void. Best of both worlds. Quote: CGA only had 4 colors in 320 x 200, 2 colors in 640 x 200. Maybe you meant EGA? I meant CGA. It has a 16 color palette; it's just that they aren't all simultaneously usable in graphics mode. |
CGamesPlay
Member #2,559
July 2002
|
int W=-1; -- Ryan Patterson - <http://cgamesplay.com/> |
Kikaru
Member #7,616
August 2006
|
Trezker: I can't get your code to compile. b isn't given a type, and you don't convert float to fix. Also, my compiler won't let you declare functions without types. |
LennyLen
Member #5,313
December 2004
|
Quote: Trezker: I can't get your code to compile. b isn't given a type, and you don't convert float to fix. Also, my compiler won't let you declare functions without types. Try a C compiler instead of a C++ compiler.
|
Mokkan
Member #4,355
February 2004
|
Here's my entry. I wrote it before I saw Matthew's comment on using functions over macros for the color. I still ended up saving space with the macro though. Player 1 Controls: Player 2 Controls: (if you have a player 2) PONG, 1 or 2 players
Uses every available character .
|
BAF
Member #2,981
December 2002
|
Quote: LOCK_VARIABLE(t);LOCK_FUNCTION(T);main(){ Those should be in the main function, not after the end of the timer function. They only really apply to DOS anyway (IIRC). |
kenmasters1976
Member #8,794
July 2007
|
Some more tweaking due to applying almost every Ted Steen's suggestion. The underlying code remains the same. To improve it beyond this, I would need to fully revamp the logic to something more ala Matthew Leverton. I don't know if I have the will to do it. What's new?, score counter at last and a new presentation. Also added a somewhat forced game over handling (the game will just rest() for 2 seconds and then exit).
{"name":"595211","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/4\/f46ce186f9ea72a810719bde12796964.gif","w":264,"h":432,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/4\/f46ce186f9ea72a810719bde12796964"}
|
netcat
Member #6,097
August 2005
|
Another entry, a space invaderish game where you can only destroy the enemies the same colour as yourself. The player colour cycles through seven different, changing with each shot (Z to fire, space resets if you die).
{"name":"595212","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/4\/34a98388b07634a25219a3d39043895e.png","w":319,"h":262,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/4\/34a98388b07634a25219a3d39043895e"} |
HardTranceFan
Member #7,317
June 2006
|
[edited] - Added the minimum number of moves possible in finished message, and added penalty moves for viewing the maze. Here's my entry. The objective is to find your way out of a randomly generated maze.
http://www.allegro.cc/files/attachment/595219 -- |
Trezker
Member #1,739
December 2001
|
New version of my Crimson game. Color changes, weapon pickups (machine gun and laser), bullet speed no longer (mouse-player)/100.
Ah, and enemies come from all edges. I think that's all I did. Hmm, enemy health higher too and they spawn at a fixed rate. I still have some lines left, what should I do now... #include <allegro.h> // Crimson by Anders Andersson int i,j,*b,a,r=10,e,k=0,h[100],t,d;char u;float x[100],y[100],v[100],w[100],X,Y; T(){++t;}C(N,S,C){circle(b,x[N],y[N],S,C);}main(){srand(time(0));x[0]=400;y[0]= 300;h[0]=99;for(i=1;i<100;++i)h[i]=0;allegro_init();install_keyboard(); install_timer();install_mouse();install_int(T,50);set_gfx_mode(2,800,600,0,0);b= create_bitmap(800,600);while(!key[59]){rest(1);if(h[0]>0){if(!--t)continue;if( key[83])x[0]++;if(key[82])x[0]--;if(key[85])y[0]++;if(key[84])y[0]--;++a;++e;for (i=1;i<99;++i){if(h[i]<=0){if(i<50&&e>99){e-=99;y[i]=rand()%2?-10:610;x[i]=rand( )%2?-10:810;if(rand()%2)x[i]=rand()%800;else y[i]=rand()%600;h[i]=10;}else if(i> 50&&mouse_b&&a>r){a-=r;x[i]=x[0];y[i]=y[0];float a=atan2(mouse_y-y[0],mouse_x- x[0]);v[i]=cos(a);w[i]=sin(a);h[i]=1;}}else{if(i<50){float a=atan2(y[0]-y[i], x[0]-x[i]);x[i]+=cos(a);y[i]+=sin(a);C(i,5,4);for(j=50;j<99;++j){X=x[i]-x[j];Y= y[i]-y[j];if(X*X+Y*Y<99&&h[j]>0){h[j]=0;if(--h[i]<=0){++k;u=rand()%2?'M':'L'; x[99]=x[i];y[99]=y[i];h[99]=1;}break;}}X=x[i]-x[0];Y=y[i]-y[0];if(X*X+Y*Y<99) --h[0];}else{if(x[i]<0||x[i]>800||y[i]<0||y[i]>600)h[i]=0;x[i]+=v[i];y[i]+=w[i]; C(i,1,7);}}}if(h[99]){X=x[99]-x[0];Y=y[99]-y[0];if(X*X+Y*Y<99){if(u=='L'){h[99]= 0;r=2;}if(u=='M'){h[99]=0;r=10;}}textprintf(b,font,x[99],y[99],15,"%c",u);}C(0,5 ,3);circle(b,mouse_x,mouse_y,3,9);textprintf(b,font,8,580,15, "Kills: %d Health: %d",k,h[0]);}else{textprintf(b,font,300,300,15, "Game over: %d kills",k);if(key[KEY_ENTER]){x[0]=400;y[0]=300;h[0]=99;for(i=1;i< 100;++i)h[i]=0;}}blit(b,screen,0,0,0,0,800,600);clear(b);}}END_OF_MAIN() |
Jeff Bernard
Member #6,698
December 2005
|
Here's my first draft, it should compile without any warnings/errors:
http://www.allegro.cc/files/attachment/595221http://www.allegro.cc/files/attachment/595223 Some parts are really unoptimized, because I realized that Centipede wasn't as complex as I had originally thought, so it can definitely be slimmed down. Sometime this weekend I'll probably add a reset (so you don't have to exit the game when you lose) and make it so you can still see the board after you lose. Oh, and I may have to do something about the timing. Hopefully it'll run roughly the same on every computer, I just used a rest to slow it down. Maybe I'll put in an Allegro timer with all the extra space I've got... HardTranceFan: I really like the lighting effect, but it's kinda too easy, I think, since you view the entire maze. Also, it'd be nice if it would generate another maze after get out. Trezker: netcat: Cool twist to Space Invaders. kenmasters1976: Very nice, the current version is a vast improvement from the first on you posted. Arvidsson (Sokoban): I can't beat level 2. Matthew Leverton: Tetris?... I already played a Tetris entry... oh, and you can keep getting points by holding down, even after the piece has hit the bottom, I assume it's a glitch? If I didn't comment on yours it's because I already have/will later or it didn't compile for me (exclusively C at the moment). I'll try the ones that didn't compile with another compiler later on. -- |
|
|