|
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
|
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
|
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 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
Member #3,561
May 2003
|
#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); }
____________________________________________ |
Breakman79
Member #1,236
April 2001
|
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.
|
Krzysztof Kluczek
Member #4,191
January 2004
|
Nice game with nice gameplay! Could you add a score/level indicator? edit: err.. funny bug: you can still shoot when you are dead. ________ |
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
|
Breakman79
Member #1,236
April 2001
|
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
|
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.
[edit] ----------- |
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.
|
Niunio
Member #1,975
March 2002
|
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
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... |
Breakman79
Member #1,236
April 2001
|
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!
|
CGamesPlay
Member #2,559
July 2002
|
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 ). -- Ryan Patterson - <http://cgamesplay.com/> |
Niunio
Member #1,975
March 2002
|
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
Member #4,191
January 2004
|
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)
And guess how the D macro works. ________ |
ImLeftFooted
Member #3,935
October 2003
|
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
|
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
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
|
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
|
Carrus: It's called indent, and it ships with linux (I believe). -- 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
|
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
|
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!
|
|
|