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

I guess what I'd propose for a skeleton, to modify Kikaru's a bit:

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

That way there's a portable allegro timer in there, and you can use it however you want.
edit: Although to make it really the case that all you need to remember are circle() and textprintf_ex(), we could put:

        blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
        clear_to_color(buffer, makecol(255,255,255));

into the loop as well.

CGamesPlay
Member #2,559
July 2002
avatar

After the competition I will change "allegro.h" to <allegro.h> and remove text_mode, and put it on the site as the "accepted" template.

[edit]
Will do.

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

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

Zaphos
Member #1,468
August 2001

Quote:

After the competition I will change "allegro.h" to <allegro.h> and remove text_mode, and put it on the site as the "accepted" template.

Sounds good :)

CGamesPlay
Member #2,559
July 2002
avatar

And we're off! Good luck, everybody!

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

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

Simon Parzer
Member #3,330
March 2003
avatar

Achtung, fertig, Los!!!

CGamesPlay
Member #2,559
July 2002
avatar

Sadly, I failed miserably. I can't handle gravity, or so it seems. I am going to keep hacking at this for a few minutes.

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

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

Zaphos
Member #1,468
August 2001

I was going to add a timer to mine, and score on how fast the player landed, but for some reason with 10 minutes left I completely forgot to add that.
... it could use some value tweaking, too ...
but it's in!

Simon Parzer
Member #3,330
March 2003
avatar

My entry is somewhat complete. The only sad thing is that I spent the whole day on ways how to generate samples and music scores (tracker style) on the fly with as less source as possible. I really wanted to include sound and music.
sigh, time was simply too short :(.

Oh, and can anyone of you compile the entries for Windows? I can't even do this with mine, because all my Allegro installations are Linux ones. :D

Kikaru
Member #7,616
August 2006
avatar

Well, I actually finished the main game with 7 min to spare. Tweaked a few things, added a title, and double checked everything. And my source is here:

1#include "allegro.h"
2 
3#define MODE GFX_AUTODETECT_WINDOWED
4#define WIDTH 640
5#define HEIGHT 480
6#define WHITE makecol(255, 255, 255)
7#define BLACK makecol(0, 0, 0)
8 
9class platform
10{
11public:
12int x, y, w;
13};
14 
15BITMAP *buffer;
16long start_time;
17int jumpforce, x = 320, y = 20;
18bool jump;
19platform land[14];
20int on_land, game_time = 0, speed = 3;
21 
22//platform spawning function
23void add_platform()
24{
25 for (int i = 0; i < 13; i++)
26 {
27 if (land<i>.y > HEIGHT)
28 {
29 land<i>.y = 0;
30 land<i>.x = ((rand()%300)*2) + 20;
31 land<i>.w = (rand()%20) + 20;
32 return;
33 }
34 }
35 return;
36}
37 
38void main()
39{
40 allegro_init();
41 install_keyboard();
42 install_mouse();
43 install_timer();
44 set_color_depth(32);
45 set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
46 srand(time(NULL)+clock());
47 text_mode(-1);
48
49 buffer = create_bitmap(WIDTH, HEIGHT);
50
51 textprintf_centre(screen, font, 320, 200, WHITE, "-Endless Tower-");
52
53 textprintf_centre(screen, font, 320, 240, WHITE, "press enter to start");
54
55 while (!key[KEY_ENTER])
56 {}
57
58 for(int i = 0; i < 13; i++)
59 {
60 land<i>.y = rand() % HEIGHT;
61 land<i>.x = ((rand()%300)*2) + 20;
62 land<i>.w = (rand()%20) + 20;
63 }
64 land[13].y = y + 10;
65 land[13].x = x;
66 land[13].w = 45;
67
68 rest(50);
69
70 while (!key[KEY_ESC])
71 {
72 start_time = clock();
73
74 /*game goes here*/
75 //move left
76 if (key[KEY_LEFT])
77 x -= 10;
78
79 //move right
80 if (key[KEY_RIGHT])
81 x += 10;
82
83 //jump
84 if ((!jump)&&(key[KEY_SPACE]))
85 {
86 jump = true;
87 jumpforce = 60;
88 }
89
90 if ((jump)&&(key[KEY_SPACE]))
91 {
92 jumpforce += 1;
93 }
94
95 //speed up!
96 speed = 3 + (game_time/20000);
97
98 //fall
99 if (jump)
100 {
101 jumpforce -= 3;
102 }
103 if (!jump)
104 jumpforce = -12;
105 y -= jumpforce/4;
106
107 //drop platforms down
108 add_platform();
109 for (int i = 0; i < 14; i++)
110 {
111 land<i>.y += speed;
112 }
113
114 //collision
115 on_land = 0;
116 for (int i = 0; i < 14; i++)
117 {
118 if ((y > land<i>.y - 20)&&(y < land<i>.y))
119 {
120 if ((x < land<i>.x + land<i>.w)&&(x > land<i>.x - land<i>.w))
121 {
122 if (jumpforce < 5)
123 {
124 jump = false;
125 }
126 jumpforce = -speed*3;
127 on_land += 1;
128 }
129 }
130 }
131 if (on_land == 0)
132 jump = true;
133 //warp
134 if (x < 0)
135 x = 0;
136 if (x > WIDTH)
137 x = WIDTH;
138
139 //die
140 if (y > HEIGHT)
141 return;
142
143 /*drawing goes here*/
144 rectfill(buffer, 0, 0, WIDTH, HEIGHT, BLACK);
145 circlefill(buffer, x, y, 10, WHITE);
146 textprintf(buffer, font, 320, 20, WHITE, "%i'%i", game_time/60000, (game_time/1000)%60);
147
148 for (int i = 0; i < 14; i++)
149 {
150 hline(buffer, land<i>.x - land<i>.w, land<i>.y, land<i>.x + land<i>.w, WHITE);
151 }
152
153 blit(buffer, screen, 0, 0, 0, 0, WIDTH, HEIGHT);
154
155 game_time += 20;
156 while (clock() < start_time + 20)
157 {}
158 }
159 destroy_bitmap(buffer);
160 return;
161}
162END_OF_MAIN()

:)

Jakub Wasilewski
Member #3,653
June 2003
avatar

My entry is in too. I'm going to write up a basic readme this time, so please don't judge it before you read it :). Of course many things were left off because the time was too short, but I'll finish it within the next half-hour and post a revised, 1,5 hour compo version ;).

As it is it's quite fun to play... for about 2 minutes ;). I have to tweak the constants - the time was added in at the last minute and it's way too lenient.

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

Yeah, mine came out way too easy.

I didn't have time to code the enemy AI properly, and now that I think about it, I really should have seeded the randoms.

It's the same game every time now, heh. Oops.

Oh well, still cool. :)

Zaphos
Member #1,468
August 2001

Just posted a revised version of mine, with a timer, and things moving a bit faster, so it's at least a little more interesting.

Simon Parzer
Member #3,330
March 2003
avatar

Uh, why can I still change my entry (upload a newer version)? I think the time is over?

Kikaru
Member #7,616
August 2006
avatar

I don't know... Anyway, I really need binaries. :-/

Zaphos
Member #1,468
August 2001

Quote:

Uh, why can I still change my entry (upload a newer version)? I think the time is over?

I think the 'upload a newer version' is for after-the-fact entry revisions; ie, so you can put up a 'fixed' version, which isn't for the competition, but rather just so you can show what it would have looked like if you'd had more time.

Jakub Wasilewski
Member #3,653
June 2003
avatar

I just put up the revised version too - it has some basic eye-candy, and some very important constant tweaks to make the game better. I would recommend playing this version if you want to actually have fun :).

So, does anyone actually need me to make the Windows binaries, or is everyone able to compile themselves?

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

Kikaru
Member #7,616
August 2006
avatar

raises hand I am incapable. Reason: still using allegro v 4.0, also can't seem to get windows.h to work.

Epoch
Member #4,737
June 2004
avatar

Alright, I posted a revised version and I'm going to ask that my game be judged based off this; I didn't add any new features, but I tweaked the gameplay so that it's actually fun to play, and that the random has been seeded.

If I am judged off the revised version, I will extend the same courtesy to those who do so. ;)

Oh, and windows binaries would be excellent.

Controls:
WASD/Arrow Keys - Move
Mouse - Aim
Mouse Button 1 - Shoot

Zaphos
Member #1,468
August 2001

Okay, attached binaries.
edit: names to numbers are:
2259: CGames
4737: Epoch
3653: Jakub
7616: Kikaru
3330: Simon
1468: Zaphos

Kikaru
Member #7,616
August 2006
avatar

Yay! binaries!

Epoch
Member #4,737
June 2004
avatar

Great, now I have to figure out what entry is what number.

Thanks alot.

;)

Zaphos
Member #1,468
August 2001

Quote:

Great, now I have to figure out what entry is what number.

Okay, I edited that into the post (above).

Note that I didn't include any of the revised versions; these are just the competition entries.
Also: To play mine use the arrow keys. UP to thrust, LEFT/RIGHT to turn.

Epoch
Member #4,737
June 2004
avatar

Would it be too much to ask for you to compile a separate set of revised binaries?

I'd kinda like to play them.

Jakub Wasilewski
Member #3,653
June 2003
avatar

Revised binaries!

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

Kikaru
Member #7,616
August 2006
avatar

Cool! I'll play some more now.



Go to: