Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » MinorHack Attack!

This thread is locked; no one can reply to it. rss feed Print
MinorHack Attack!
Zaphos
Member #1,468
August 2001

Quote:

Though one in pure C would be nice as well

That one compiles in gcc -- I'm not sure what I'd have to do to make it pure C?

Quote:

If you leave out error checking, 15-bit fall back, closing callback and timers (use timeGetTime()/gettimeofday()) you don't really need much time do create the framework.

But I want error checking, programs that work, programs that close nicely, and programs that use a portable timer. And I wouldn't want to worry about the idiosyncrasies of a delta timing system in an hour-long hack ...

Quote:

Retyping it takes almost no thinking and just about 3 minutes of coding, which is really small price for the fact that you can state that your game is 100% coded during one hour.

Is retyping from memory any different from a stupid version of copy-paste? Personally I get no pride from that at all.

Derezo
Member #1,666
April 2001
avatar

Woops. I was suppose to participate last sunday! :o
I completely forgot about it, was very busy. I'll try and participate this sunday :D

"He who controls the stuffing controls the Universe"

CGamesPlay
Member #2,559
July 2002
avatar

The next one is Saturday :P

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

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

Kikaru
Member #7,616
August 2006
avatar

I agree, a simple code base to initialize allegro in the main loop, include allegro, and standard C/C++ libraries would be nice.

Evert
Member #794
November 2000
avatar

Quote:

That one compiles in gcc

C and C++ both compile with gcc. Hell, even Pascal and FORTRAN compile with gcc if it's been configured for those languages.

Quote:

I'm not sure what I'd have to do to make it pure C?

Not use C++'s standard bool type.

Since I'm not planning on joining any programming competition anytime soon the following is probably not very useful, but the only game template I'd consider using is my own, because that corresponds to my coding style and way of thinking...

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

Since I'm not planning on joining any programming competition anytime soon the following is probably not very useful, but the only game template I'd consider using is my own, because that corresponds to my coding style and way of thinking...

Right, which is why the kit is optional. It's designed for those who are still learning how to do what it does.

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

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

Zaphos
Member #1,468
August 2001

Okay, so here's mine again, c89 style:

1#include <allegro.h>
2 
3int quitnow = 0;
4void close_callback() {
5 quitnow = 1;
6}
7 
8int logic_time = 0;
9void logic_timer()
10{
11 logic_time++;
12}
13END_OF_FUNCTION(logic_timer);
14 
15/* initialize systems! */
16BITMAP* init(int w, int h, const char *title) {
17 allegro_init();
18 install_mouse();
19 install_timer();
20 install_keyboard();
21 
22 set_color_depth(16);
23 if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, 0, 0) != 0) {
24 set_color_depth(15);
25 if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, 0, 0) != 0){
26 allegro_message("Couldn't set graphics mode!");
27 exit(1);
28 }
29 }
30 
31 LOCK_VARIABLE(logic_time);
32 LOCK_FUNCTION(logic_timer);
33 install_int_ex(logic_timer, BPS_TO_TIMER(60));
34 
35 set_close_button_callback(close_callback);
36 
37 set_window_title(title);
38 
39 return create_bitmap(w, h);
40}
41
42int main() {
43 
44 BITMAP *buffer = init(640,480, "minorhack");
45 if (!buffer) {
46 allegro_message("Couldn't create back buffer");
47 exit(-1);
48 }
49
50
51 while (!key[KEY_ESC] && !quitnow) {
52 while (logic_time > 0) {
53 /* game goes here */
54 logic_time--;
55 }
56
57 /* drawing goes here */
58 blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
59 clear_to_color(buffer, makecol(255,255,255));
60 }
61
62 return 0;
63} END_OF_MAIN()

Quote:

the only game template I'd consider using is my own, because that corresponds to my coding style and way of thinking...

Perhaps the competition could say "using a custom template which accomplishes nothing significantly more or different from the provided template is also fine."

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Quote:

But I want error checking, programs that work, programs that close nicely, and programs that use a portable timer. And I wouldn't want to worry about the idiosyncrasies of a delta timing system in an hour-long hack ...

I haven't got Allegro get_gfx_mode error since I've moved away from my 486DX4 and switched from DOSt to using Windows 98 as a main platforms. For me pressing "Esc" counts as closing nicely for sure and timeGetTime() is portable timer if you use my gettimeofday replacement version. :) As for timing, I'd use Allegro timers, but delta-timing is much easier for me and using timeGetTime() takes less code than using Allegro timers. :)

Jakub Wasilewski
Member #3,653
June 2003
avatar

I had my basic code completed in under 5 minutes (+3 for the entity system I often use here and there) and I honestly think that retyping the same old stuff is only to your advantage. Your hands have something to do, while your brain can concentrate on how to tackle the important parts of the game :).

I already expressed my position about code reuse, so I will only do a short recap... I believe the "clean slate" approach provides much more feeling of achievement, and I honestly recommend this style, it's worth it in my opinion. On the other hand, if you feel like using a framework, I won't hold that against you or your entry. It's just another approach, and who am I to tell you what's fun for you?

Quote:

but delta-timing is much easier for me and using timeGetTime() takes less code than using Allegro timers

With my previous entry, I somehow thought that using allegro timers will be faster to code, but it wasn't exactly the case. I'll go with what I'm used to (DT) in the next one, with the added benefit that it'll run smoother :).

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Victor Williams Stafusa da Silva
Member #4,212
January 2004
avatar

About code re-use for initialization only, that was exactly what i reused in my asteroid game (from Rambanana). That was just code to detect joystick, keyboard and mouse, setting up sound and MIDI, defining graphic modes (32, 24, 16, 15 and 8 bits, fullscreen and windowed), LOCK_VARIABLE, LOCK_FUNCTION, etc.

It's a few messed up. Maybe i should modularize it better to make it look better and avoid the code overbloat (I.E: Sound and joystick code, which had no use in my game).

I think it's very annoying and repetitive retype this whole thing again and again and again. It's very easier copy and paste it in your code and work all the 60 minutes for what really matter: develop the game.

[The attack of the space bugs - Speedhack 2005] [Rambananas - Speedhack 2006] [Make clean - Speedhack 2009] [The source god - TINS 2010]

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

for what really matter: develop the game.

MinorHack isn't about developing a game ::) It's about developing a game in 1 hour ;)

I think I will put up both a C and a C++ template sometime this week. It will set a graphics mode, install a keyboard, mouse, and timer at 30 BPS, and set up a double buffer. That should be enough to get people off to a good start without giving them too much of an advantage. Objections?

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

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

Onewing
Member #6,152
August 2005
avatar

Quote:

I think I will put up both a C and a C++ template sometime this week.

As long as it's optional. I don't think there's anything wrong with having initialization code and a very generic framework laid out beforehand. I have my code that, although slightly bloated, works well for me. It consists of an init function (setting up allegro, keyboard, joysticks, etc.), a game init function (for setting up game variables), a play_game function (runs the main loop), a game_update function (for doing all the update functions) and a game_draw function (for handling all the drawing functions).

With this simple layout, all I have to worry about is making the game.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Victor Williams Stafusa da Silva
Member #4,212
January 2004
avatar

CGamesPlay said:

It's about developing a game in 1 hour

I said:

work all the 60 minutes for what really matter: develop the game.

:P

[The attack of the space bugs - Speedhack 2005] [Rambananas - Speedhack 2006] [Make clean - Speedhack 2009] [The source god - TINS 2010]

CGamesPlay
Member #2,559
July 2002
avatar

No, you miss the point. The idea of Minorhack isn't to have a high-quality game that you can show off to friends. It's to have a low-quality game that you can show off to your friends and say "yeah, I did this entirely in 1 hour".

Quote:

Retyping it takes almost no thinking and just about 3 minutes of coding, which is really small price for the fact that you can state that your game is 100% coded during one hour.

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

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

Onewing
Member #6,152
August 2005
avatar

Quote:

Copying and Pasting takes no thinking and just about 30 seconds, which is really small price for the fact that you can state that your game is 97% coded during one hour.

Fixed.;D

------------
Solo-Games.org | My Tech Blog: The Digital Helm

CGamesPlay
Member #2,559
July 2002
avatar

Right, right. That's why we are allowing using templates. To each his own.

On a side note, I just got clearance for the Allegro.cc authentication, so I will be adding that in in just a few hours. I am also conviniently leaving work early.

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

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

Onewing
Member #6,152
August 2005
avatar

Quote:

Right, right. That's why we are allowing using templates. To each his own.

Heh, I'm just giving you a hard time. Whatever format you choose, we shall abide to (or not do entirely).

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Victor Williams Stafusa da Silva
Member #4,212
January 2004
avatar

CGamesPlay said:

The idea of Minorhack isn't to have a high-quality game that you can show off to friends.

Of course. Actually, Chuck Norris is the only person that is capable of doing a high-quality game in one hour. ;D

CGamesPlay said:

It's to have a low-quality game that you can show off to your friends and say "yeah, I did this entirely in 1 hour".

Or maybe "I did this entirely in 1 hour after copying and pasting this code".:P

[The attack of the space bugs - Speedhack 2005] [Rambananas - Speedhack 2006] [Make clean - Speedhack 2009] [The source god - TINS 2010]

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Quote:

Copying Quake 3 source code takes absolutely no thinking and just about 5 seconds, which is really small price for the fact that you can state that your game is 0% coded during one hour.

Fixed the fix. ;D

Anyway, do whatever you enjoy, I'll be starting from scratch to get 100% one hour coded game. :)

Jakub Wasilewski
Member #3,653
June 2003
avatar

Quote:

Anyway, do whatever you enjoy, I'll be starting from scratch to get 100% one hour coded game.

We should get a "100% natural product, no artificial ingredients" sticker for our games :).

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Quote:

We should get a "100% natural product, no artificial ingredients" sticker for our games :).

And in our case "Teraz Polska" would accompany it nicely (especially considering our last MinorHack results). ;)

Jonatan Hedborg
Member #4,886
July 2004
avatar

my girlfriend (she's polish) is laughing at me because i got beaten by two polish guys :(

-------
Sweden: Free from the shackles of Democracy since 2008-06-18!

relpatseht
Member #5,034
September 2004
avatar

Being beaten by two Poles is most certainly not a pleasant experience, I imagine. Nevertheless, I will risk that beating to participate in the next MicroHack, assuming some unfortunate event does not arise during its hour.

Jakub Wasilewski
Member #3,653
June 2003
avatar

Quote:

my girlfriend (she's polish) is laughing at me because i got beaten by two polish guys

Well, tell her that at least you have beaten both of us to her, and that's probably more of an achievement :).
And honestly, I think the only way to get 'beaten' in this competition is if you do not finish and get beaten by your own weaknesses. And after all, I still would rate your entry above mine (if I had to rate mine).

Quote:

Being beaten by two Poles is most certainly not a pleasant experience, I imagine.

I'm wondering, how is it any worse than being beaten by two other random guys? Honestly, I'm curious.

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Zaphos
Member #1,468
August 2001

Quote:

Honestly, I'm curious.

It was a pun.



Go to: