Allegro.cc - Online Community

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

This thread is locked; no one can reply to it. rss feed Print
MinorHack Returns!
Jakub Wasilewski
Member #3,653
June 2003
avatar

I can make the Windows binaries afterwards if someone wants them, it's no big deal. I'll probably participate if the rule won't turn out to be something braindead :).

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

Epoch
Member #4,737
June 2004
avatar

Anyone know how to do a precompiler #ifdef to check if the compiler is MSVC?

I'm throwing in a macro to fix the for scope.

Jakub Wasilewski
Member #3,653
June 2003
avatar

Well, the easiest way if you're using allegro is #ifdef ALLEGRO_MSVC. However, I don't know if anyone still uses MSVC6, which IIRC was the last version to have for scoping problems.

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

LennyLen
Member #5,313
December 2004
avatar

Quote:

LennyLen, Zaphos: You guys in?

I'm too rusty with Allegro to enter a 1-hour comp. I'd spend 50% of the time looking up the API. I might enter the next 48-hour comp, though probably not since they're always over the weekend, and I never have free time during the weekend (I can easily be working 30 of the 48 hours at this time).

Zaphos
Member #1,468
August 2001

Quote:

I'm too rusty with Allegro to enter a 1-hour comp. I'd spend 50% of the time looking up the API.

But all you need is circle()! And maybe textprintf_ex().
Especially now that Kikaru explained, "it was agreed on that we could use a simple code base to initialize Allegro, include headers, and [etc]".

Epoch
Member #4,737
June 2004
avatar

Yeah, I'm using MSVC6 :P

Zaphos
Member #1,468
August 2001

Quote:

Yeah, I'm using MSVC6

Why, though? Later versions are free and actually compile standard C++, for the most part.

Kikaru
Member #7,616
August 2006
avatar

Yeah, LennyLen! Join us! Prepare the code base now! :D

Epoch
Member #4,737
June 2004
avatar

I downloaded VSExpress and tried to use it to compile my current project and it threw 80 separate errors on code that compiled fine on VS6, and I just haven't felt like porting the code.

I probably should though, I use STL heavily and apparently more recent MSVCs do STL much better.

CGamesPlay
Member #2,559
July 2002
avatar

I think I should point out something...

Quote:

In addition to the above, try to follow these guidelines. They are not a rules, but if you do not follow them, you run the risk of not having your game judged.
* Do not reuse code. Write all of your code yourself, during the 1-hour slot. Code reuse is fine for longer competitions where you often spend 6-10 hours rewriting something that you have coded before, but here you are unlikely to spend more than 15 minutes on it. Also, writing from scratch boosts creativity because there is no temptation to use large chunks of other games.

If you must use a skeleton, that's fine. But don't be excessive. Really, it's against the spirit of the competition.

/me wears badge that says "I coded my MinorHack entry from scratch".

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

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

LennyLen
Member #5,313
December 2004
avatar

Quote:

Yeah, LennyLen! Join us! Prepare the code base now!

Maybe if I'm still awake at 7am. I've been up for 44 hours now, and my eyelids are getting very heavy.

Kikaru
Member #7,616
August 2006
avatar

As I mentioned, just initialize Allegro and make a

while (!key[KEY_ESC])
{
//do something
}

main loop.

I think that counts as a skeleton.

[EDIT]
MinorHack in 1 hour. twitch

Zaphos
Member #1,468
August 2001

Quote:

Really, it's against the spirit of the competition.

Well, I don't think there's much difference in spirit between starting with a skeleton or taking five minutes to regurgitate a skeleton from memory. And having a skeleton encourages new people to come in, and makes it more accessible for people who haven't done this sort of thing enough to have the startup code basically memorized. I see very little wrong with using a skeleton.

LennyLen
Member #5,313
December 2004
avatar

Quote:

And having a skeleton encourages new people to come in, and makes it more accessible for people who haven't done this sort of thing enough to have the startup code basically memorized

It's a little late for this time, but perhaps for the next MinorHack (and subsequent ones), there could be an "official" skeleton that everyone can use.

[edit]I'm not gonna make it until 7am. It took me more than twice as long to correct this post than it did to write it.

Zaphos
Member #1,468
August 2001

Quote:

It's a little late for this time, but perhaps for the next MinorHack (and subsequent ones), there could be an "official" skeleton that everyone can use.

This was actually sort-of planned at some point, but then dropped -- I'm not sure why. I believe I proposed this skeleton, which I would still be fine with:

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(30));
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
53 while (logic_time == 0) { /* yield while we've got nothing to do */
54 rest(0);
55 }
56
57 while (logic_time > 0) {
58 /* game goes here */
59 logic_time--;
60 }
61
62 /* drawing goes here */
63 blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
64 clear_to_color(buffer, makecol(255,255,255));
65 }
66
67 return 0;
68} END_OF_MAIN()

Epoch
Member #4,737
June 2004
avatar

Zaphos: Way too much error checking for a hack. :)

Is there an official MinorHack IRC channel?

Kikaru
Member #7,616
August 2006
avatar

I made one of my own, which is actually less complex than that.
Here it is:

1#include "allegro.h"
2 
3#define MODE GFX_AUTODETECT_WINDOWED
4#define WIDTH 640
5#define HEIGHT 480
6 
7BITMAP *buffer;
8 
9void main()
10{
11 allegro_init();
12 install_keyboard();
13 install_mouse();
14 install_timer();
15 set_color_depth(32);
16 set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
17 text_mode(-1);
18
19 buffer = create_bitmap(WIDTH, HEIGHT);
20
21 while (!key[KEY_ESC])
22 {
23 }
24 destroy_bitmap(buffer);
25 return;
26}
27END_OF_MAIN()

[EDIT]
What is IRC? ???

Epoch
Member #4,737
June 2004
avatar

Internet Relay Chat?

I didn't even initialize graphics/timers in my skeleton. I'm wondering if I should.

Zaphos
Member #1,468
August 2001

Quote:

Way too much error checking for a hack.

Yeah -- I wouldn't go any more complex than it, probably should go less. I figured an official starter code might want to do things 'right', to some greater extent, but Kikaru's approach is also good. (edit: I might go somewhere between, and add some timer code to Kikaru's skeleton, since most games are going to need that too)

Quote:

What is IRC? ???

It's a chat protocol, so people can have a more real-time discussion.

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

makes it more accessible for people who haven't done this sort of thing enough to have the startup code basically memorized.

This is the only case I consider a skeleton "acceptable". That is, if you can do it from memory, do it from memory.

Epoch: Nope, and you will watch as this thread drops silent for 1 hour coming up here.

Quote:

What is IRC? ???

Omigosh! IRC is the thing where you go to http://silverex.info and download and install that, then open it, connect to "Freenode", and type "/join #allegro" (without quotes. You will love it :)

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

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

Zaphos
Member #1,468
August 2001

Quote:

That is, if you can do it from memory, do it from memory.

The idea that copy pasting from memory is 'cooler' than copy pasting from actual code is funny to me, but, you know, whatever you need to do to feel 'hardcore', I guess ;D

Kikaru
Member #7,616
August 2006
avatar

By "timer code" you mean like: long start_time = clock(); at the beginning of the loop and

while (clock() < start_time + 20)
{}

at the end?

Zaphos
Member #1,468
August 2001

Quote:

By "timer code" you mean like:

That's so bad, but sure. Something to control the speed of the game.

CGamesPlay
Member #2,559
July 2002
avatar

Don't use clock for timing, it's inaccurate :P

8 yes's and 2 maybes! BAF says he'll be in but a bit late.

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

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

Kikaru
Member #7,616
August 2006
avatar

Yay! Lots of people! MinorHack FTW! :D twitch twitch twitch



Go to: