Javisst.
Först ska jag säga att jag hade tänkt skriva det i C, men eftersom jag ville ha bilder med så var jag tvungen att använda mig av Allegro. Detta gjorde så att scanf inte funkar, det funkar bara i konsolfönstret.
Dessutom fungerar inte funktioner inne i spelet för man har en sk. gameloop där hele spelet måste vara innanför.
Detta gör att typ hela spelet är inne i main, och det är mycket Allegro-specifika kommandon.
#include <allegro.h>
#include <cstdlib>
#include <ctime>
#include <string>
void initAllegro(); // Function to initialize Allegro
volatile long speed_counter = 0; // Long integer stores value of speedcounter
void increment_speed_counter(); // Function to increment the speed counter
volatile int closeWindow = false;
volatile long timer = 0;
void Increment(){timer++;}
END_OF_FUNCTION(Increment);
int main(int argc, char *argv[])
{
initAllegro();
increment_speed_counter();
FONT *myfont7 = load_font("myfont7.pcx", NULL, NULL); // Load font
FONT *m2 = load_font("m2.pcx", NULL, NULL);
BITMAP *buffer = create_bitmap(1200,983); // create buffer of 1200x983
BITMAP *menu = load_bitmap("menu.bmp", NULL); // load bitmap
BITMAP *about = load_bitmap("about.bmp",NULL);
BITMAP *me = load_bitmap("me.bmp",NULL);
BITMAP *swamp = load_bitmap("swamp.bmp",NULL);
BITMAP *road = load_bitmap("road.bmp",NULL);
BITMAP *raft = load_bitmap("raft.bmp",NULL);
BITMAP *book = load_bitmap("book.bmp",NULL);
BITMAP *cave = load_bitmap("cave.bmp",NULL);
BITMAP *dragon1 = load_bitmap("dragon1.bmp",NULL);
BITMAP *dragon2 = load_bitmap("dragon2.bmp",NULL);
BITMAP *dragon3 = load_bitmap("dragon3.bmp",NULL);
BITMAP *dragon4 = load_bitmap("dragon4.bmp",NULL);
BITMAP *end = load_bitmap("end.bmp",NULL);
BITMAP *raftdead = load_bitmap("raftdead.bmp",NULL);
BITMAP *swampdead = load_bitmap("swampdead.bmp",NULL);
BITMAP *roaddead = load_bitmap("roaddead.bmp",NULL);
BITMAP *cavedead = load_bitmap("cavedead.bmp",NULL);
BITMAP *bookdead = load_bitmap("bookdead.bmp",NULL);
BITMAP *tummy = load_bitmap("tummy.bmp",NULL);
BITMAP *Bunny = load_bitmap ("Bunny.bmp", NULL);
MIDI *gamemusic = load_midi("gamemusic.mid"); // load midi
MIDI *ending = load_midi("ending.mid");
MIDI *gameover = load_midi("gameover.mid");
MIDI *hack = load_midi("hack.mid");
SAMPLE *menumusic = load_sample("menumusic.wav"); // load wav
SAMPLE *bookdeadwav = load_sample("bookdeadwav.wav");
SAMPLE *cavedead1 = load_sample("cavedead1.wav");
SAMPLE *drown = load_sample("drown.wav");
SAMPLE *error1 = load_sample("error1.wav");
SAMPLE *error2 = load_sample("error2.wav");
SAMPLE *heartbeat = load_sample("heartbeat.wav");
int song_frequency = 1000; // how fast the music is playing
bool done = false;
bool keydown = false;
int Screen = 1;
// Bunny animation:
enum Source {Left, Right};
int Position[2] = {450, 850}; // x, y
int currentFrame[2] = {0, Right}; // start position
int Frames[2] = {3, 2}; // how many frames in the picture
int Dimensions[2] = {Bunny->w / Frames[0], Bunny->h / Frames[1]}; // where is the different animations in the picture
int moveSpeed = 3;
int switchFrame = 8; // switch from image to image
int frameCounter = 0; // counting up to switchframe
bool isActive; // check to see if you press the button to activate sprite
// end Bunny animation
while (!done) // start of gameloop
{
while (speed_counter > 0) // start of speedcounter
{
if (Screen == 1 && keydown == false) // menu screen
{
stop_midi();
play_sample(menumusic, 50, 128, song_frequency, true);
if (key[KEY_1]) { Screen = 3; play_midi(gamemusic, true);} // start game
if (key[KEY_2]) { Screen = 2;} // about
if (key[KEY_3]) { done = true; } // quit
}
else if (Screen == 2 && keydown == false) //About (Screen with Bunny animation)
{
if (key[KEY_ESC]) { Screen = 1; } //esc = go back to menu screen.
// here starts bunny animation stuff
isActive = true;
if(key[KEY_RIGHT])
{
Position[0] += moveSpeed;
currentFrame[1] = Right;
}
else if(key[KEY_LEFT])
{
Position[0] -= moveSpeed;
currentFrame[1] = Left;
}
else
isActive = false;
if(isActive)
{
frameCounter += 1; // increment framecounter by 1
if(frameCounter >= switchFrame)
{
currentFrame[0] += Dimensions[0]; // where to start drawing from, and jump to next frame
frameCounter = 0; // reset framecounter, so it cycles through the images
}
if (currentFrame[0] >= Bunny->w) // if its drawing last picture
currentFrame[0] = 0; // reset
}
else
{
currentFrame[0] = 0; // if not active, reset to 0
frameCounter = 0;
}
timer--;
}
// end bunny animation
else if (Screen == 3 && keydown == false) // raft
{
if (key[KEY_ESC]) { Screen = 1; }
else if (key[KEY_1]) { Screen = 4; } // swamp
else if (key[KEY_2]) { Screen = 14; play_sample(drown, 255, 128, 1000, 0); play_midi(gameover, true);} // death1 - raftdead
else if (key[KEY_3]) { Screen = 4; }
}
else if (Screen == 4 && keydown == false) // swamp
{
if (key[KEY_ESC]) { Screen = 1; }
else if (key[KEY_1]) { Screen = 15; play_sample(drown, 255, 128, 1000, 0); play_midi(gameover, true);} // death2 - swampdead
else if (key[KEY_2]) { Screen = 15; play_sample(drown, 255, 128, 1000, 0); play_midi(gameover, true);} // death2
else if (key[KEY_3]) { Screen = 5; } // road
}
else if (Screen == 5 && keydown == false) // road
{
if (key[KEY_ESC]) { Screen = 1; }
else if (key[KEY_1]) { Screen = 6; } // cave1
else if (key[KEY_2]) { Screen = 16; play_sample(heartbeat, 255, 128, 1000, 0); play_midi(gameover, true); } // death3 - roaddead
else if (key[KEY_3]) { Screen = 7; } // cave2
}
else if (Screen == 6 && keydown == false) // cave1
{
if (key[KEY_ESC]) { Screen = 1; }
else if (key[KEY_1]) { Screen = 17; play_sample(cavedead1, 255, 128, 1000, 0);play_midi(gameover, true); } // death4 - cavedead
else if (key[KEY_2]) { Screen = 8; } // book
else if (key[KEY_3]) { Screen = 18; play_sample(cavedead1, 255, 128, 1000, 0); play_midi(gameover, true);} // death5 - cavedead
}
else if (Screen == 7 && keydown == false) // cave2
{
if (key[KEY_ESC]) { Screen = 1; }
else if (key[KEY_1]) { Screen = 17; play_sample(cavedead1, 255, 128, 1000, 0); play_midi(gameover, true);} // death4
else if (key[KEY_2]) { Screen = 8; } // book
else if (key[KEY_3]) { Screen = 18; play_sample(cavedead1, 255, 128, 1000, 0); play_midi(gameover, true);} // death5
}
else if (Screen == 8 && keydown == false) // book
{
if (key[KEY_ESC]) { Screen = 1; }
else if (key[KEY_1]) { Screen = 19; play_sample(bookdeadwav, 255, 128, 1000, 0); play_midi(gameover, true);} // death6 bookdead
else if (key[KEY_2]) { Screen = 9; } // dragon
else if (key[KEY_3]) { Screen = 20; play_sample(cavedead1, 255, 128, 1000, 0); play_midi(gameover, true);} // death7 cavedead
}
else if (Screen == 9 && keydown == false) // dragon
{
if (key[KEY_ESC]) { Screen = 1; }
else if (key[KEY_1]) { Screen = 10; } // dragon2
else if (key[KEY_2]) { Screen = 10; } // dragon2
else if (key[KEY_3]) { Screen = 21; play_sample(heartbeat, 255, 128, 1000, 0); play_midi(gameover, true);} // death8 - tummy
}
else if (Screen == 10 && keydown == false) // dragon2
{
if (key[KEY_ESC]) { Screen = 1; }
if (key[KEY_1]) { Screen = 11; play_sample(error2, 255, 0, 1000, 0); play_sample(error1, 255, 255, 1000, 0); play_sample(error2, 255, 0, 1000, 0); play_sample(error1, 255, 255, 1000, 0); play_midi(hack, true);} //dragon3
}
else if (Screen == 11 && keydown == false) // dragon3
{
if (key[KEY_ESC]) { Screen = 1; }
if (key[KEY_1]) { Screen = 12; play_midi(gamemusic, true);} // dragon4
}
else if (Screen == 12 && keydown == false) // dragon4
{
if (key[KEY_ESC]) { Screen = 1; }
else if (key[KEY_1]) { Screen = 22; play_sample(heartbeat, 255, 128, 1000, 0); play_midi(gameover, true);} // death9 - tummy
else if (key[KEY_2]) { Screen = 22; play_sample(heartbeat, 255, 128, 1000, 0); play_midi(gameover, true);} // death9
else if (key[KEY_3]) { Screen = 13; play_midi(ending, true);} // end
}
else if (Screen == 13 && keydown == false) // end
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 14 && keydown == false) // death1
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 15 && keydown == false) // death2
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 16 && keydown == false) // death3
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 17 && keydown == false) // death4
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 18 && keydown == false) // death5
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 19 && keydown == false) // death6
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 20 && keydown == false) // death7
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 21 && keydown == false) // death8
{
if (key[KEY_ESC]) { Screen = 1; }
}
else if (Screen == 22 && keydown == false) // death9
{
if (key[KEY_ESC]) { Screen = 1; }
}
if(!key[KEY_1] && !key[KEY_2] && !key[KEY_3]) // handle single keypress,
keydown = false; // so one have to release key before its registering again
else keydown = true;
speed_counter--; // end of speedcounter
}
if (Screen == 1) // menu
{
draw_sprite(buffer, menu, 0,0);
textout_ex(buffer,myfont7,"Press (1) to start the game.",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Press (2) for about screen.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Press (3) to quit.",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"You can always press (esc) to return to this screen",30,860,makecol(255,255,255), -1 );
}
else if (Screen == 2) // about
{
draw_sprite(buffer, about, 0,0);
draw_sprite(buffer, me, 770,100);
textout_ex(buffer,myfont7,"My name is Christoffer and I am 37 years old. Thats me in ASCII -->",30,160,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"This little game is made as a school project for The Noroff Institute.",30,185,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"It is written in C with the Allegro library.",30,210,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"The graphics are drawn by me with charcoal, except for the boss ",30,255,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"who is made on a Wacom tablet by my GF. I tried to paint with the ",30,280,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"tablet myself, but the pictures came out even worse then they are now. ",30,305,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"(believe it or not)",30,330,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"The audio is taken from free libraries around the net, and they",30,355,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"are in .WAV and .MID format.",30,380,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"The game is a tribute to the oldschool textadventures,",30,425,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"now ''improved'' with graphics ^^",30,450,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"You navigate the game with the 1, 2 or 3 numberbuttons,",30,475,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"and you can always press the esc-key to return to main menu.",30,500,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Oh and you can walk the little bunny down there with the key-left and key-right.",30,545,makecol(255,255,255), -1 );
masked_blit(Bunny, buffer, currentFrame[0], currentFrame[1] * Dimensions[1], Position[0], Position[1], Dimensions[0], Dimensions[1]); // draw the bunny
textout_ex(buffer,myfont7,"Press (esc) to return to menu.",30,770,makecol(255,255,255), -1 );
}
else if (Screen == 3) // raft
{
stop_sample(menumusic);
draw_sprite(buffer, raft, 0, 0);
textout_ex(buffer,myfont7,"You awaken on a raft gliding down the river. You dont remember how you came here, or even what your name is.",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Suddenly the raft comes to an abrupt halt, it seems to have stopped on a big rock by the riverside.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"What do you do:",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"1. Carefully climb over the rock and into the dark woods.",40,860,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"2. Heroically jump to the shore.",40,890,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"3. Go into the water and try to reach the edge and climb up, then go into the woods.",40,920,makecol(255,255,255), -1 );
}
else if (Screen == 4) // swamp
{
draw_sprite(buffer, swamp, 0, 0);
textout_ex(buffer,myfont7,"You stumble across the dens woods, still trying to figure out what happened to you. Nothing about your past ",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"seems to enter your mind and all of a sudden you feel wet on the feet. You have come to the edge of a swamp.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"How do you proceed:",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"1. Run straight across the swamp and re-enter the dark woods on the other side.",40,860,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"2. Walk on all four across the swamp - that should be easy.",40,890,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"3. Walk across but thread only on the grass.",40,920,makecol(255,255,255), -1 );
}
else if (Screen == 5) // road
{
draw_sprite(buffer, road, 0, 0);
textout_ex(buffer,m2,"You make it across and continue your travel through the dense vegetation, still confused, tired, hungry and weak.",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"From out of nowhere a road apperas before you. You must have been deep in thought about what happened to you and",30,795,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"didn't notice how the woods became more and more open. Focus. In the middle of the road lies a golden key.",30,820,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"What is your choice:",30,850,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"1. Damn it all to hell! What would I ever need a key for. Kick the key as hard as you can!",40,875,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"2. You are actually very hungry - you eat the key.",40,900,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"3. You pick up the key.",40,925,makecol(255,255,255), -1 );
}
else if (Screen == 6) // cave1
{
draw_sprite(buffer, cave, 0, 0);
textout_ex(buffer,myfont7,"The key flings sideways and into the woods. You cant even kick a key straight....",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"You follow it and see a cave entrance. This was not visible from the road. There is a big rock above the entrance.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"This cant be good:",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"1. Throw yourself into the darkness as fast as humanly possible - speed is good!",40,860,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"2. Slowly walk into the cave.",40,890,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"3. Go and stand directly under the rock to inspect if its safe to walk under the rock.",40,920,makecol(255,255,255), -1 );
}
else if (Screen == 7) // cave2
{
draw_sprite(buffer, cave, 0, 0);
textout_ex(buffer,myfont7,"When you bend down and pick up the key you see something in the woods on the side of the road. ",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Its an entrance to a cave. When you aproach it you notice that It seems to be a big rock above the entrance.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"This cant be good:",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"1. Throw yourself into the darkness as fast as humanly possible - speed is good!",40,860,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"2. Slowly walk into the cave.",40,890,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"3. Go and stand directly under the rock to inspect if its safe to walk under the rock.",40,920,makecol(255,255,255), -1 );
}
else if (Screen == 8) // book
{
draw_sprite(buffer, book, 0, 0);
textout_ex(buffer,myfont7,"You walk about 20 meters into the cave and notice a candle in a niche. Underneath it is a book bound in leather.",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"You pick it up and start to read. The ink is wet and its written in a wierd language that you cant understand.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"What now:",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"1. Mmmm fresh ink - you eat the book.",40,860,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"2. Place the book back on the shelf and continue deep inside the cave.",40,890,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"3. Fresh ink....this is too wierd. You throw the book away and run out from the cave",40,920,makecol(255,255,255), -1 );
}
else if (Screen == 9) // dragon
{
draw_sprite(buffer, dragon1, 0, 0);
textout_ex(buffer,m2,"Is this a dream?? In the end of the cave you see a living breathing firespewing dragon!! ",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"Ok its not actually spewing fire, its really sound asleep. But still, a dragon!? ",30,795,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"The dragon is lying on top of a big pile of gold just like in the fairytales.",30,820,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"This should be good:",30,850,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"1. Wake the dragon (sounds like a good idea)",40,875,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"2. Dont wake the dragon (duh)",40,900,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"3. Take all the money from the dragon (are you kidding?)",40,925,makecol(255,255,255), -1 );
}
else if (Screen == 10) // dragon2
{
draw_sprite(buffer, dragon2, 0, 0);
textout_ex(buffer,myfont7,"As soon as you move, the dragon instantly awakes, wow he can talk!",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"- Who in the name of ..........are you? I'm Natchayullucaca. Says the dragon with a rumbling voice.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"- It doesn't really matter, I will now mindmeld with you (vulcan style) and boil your brain, get ready for it!! ",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Wow, this dragon has some issues, only one thing to do:",30,860,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"1. Quit the game.",40,890,makecol(255,255,255), -1 );
}
else if (Screen == 11) // dragon3
{
draw_sprite(buffer, dragon3, 0, 0);
textout_ex(buffer,myfont7,"[dragon_mastah@root]c:/specialshell/trojan.msx",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"ps aux | kill firewall",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"some leet hacker command...",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"load backdoor mystajli.doom -A -dOiT",40,860,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"if killswitch == yes then goto special hightech -(use all of the 640k memory)",40,890,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"/me trying !@$#%",40,920,makecol(255,255,255), -1 );
}
else if (Screen == 12) // dragon4
{
draw_sprite(buffer, dragon4, 0, 0);
textout_ex(buffer,myfont7,"-Oh....it seems you might have a newer OS then OS/2 Warp (wich I use) so I cant really acces your drive.",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Since you are very leet and all, I will give you 1 chance to escape. If you can say my name backwards you will ",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"be teleported to freedom. If not......well, lets just say we will become close.",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"1. acaculluyachtaN",40,860,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"2. a-KAKA! *cough* taN...",40,890,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"3. acaculluyahctaN",40,920,makecol(255,255,255), -1 );
}
else if (Screen == 13) // end
{
draw_sprite(buffer, end, 0, 0);
textout_ex(buffer,myfont7,"You pop down on a road. You see a town in the distance, its not far, you will make it. ",50,775,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"As you walk closer you think about all that has happened. Was it just a dream? ",50,805,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Still fuzzy in the head from everything you feel happy. Yes its truly a joy to be alive!",50,835,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"The wind is blowing in your hair and the sun is smiling on your face. ",50,865,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"Cant wait to take a bath, eat some and have a good night sleep. The future is looking bright.",50,895,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 14) // death1
{
draw_sprite(buffer, raftdead, 0, 0);
textout_ex(buffer,myfont7,"Just as you jump you slip on the raft and fall into the water. The current is too strong for your weak body",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"and the cold water numbs your brain as you drown. May your soul rest in peace.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 15) // death2
{
draw_sprite(buffer, swampdead, 0, 0);
textout_ex(buffer,myfont7,"As you try and make it across, the ground is just too loose, you sink deeper and deeper and due to exhaustion",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"there is nothing more you can do but think about how bad it smells and how annoying the insects are when you",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"slowly drown and leave no trace.",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 16) // death3
{
draw_sprite(buffer, roaddead, 0, 0);
textout_ex(buffer,myfont7,"You put the key into your mouth, shove it down your throat and choke on it. You die. ",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"There is no sense in eating a big golden key and this is what happens. Better luck next time.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 17) // death4
{
draw_sprite(buffer, cavedead, 0, 0);
textout_ex(buffer,myfont7,"You try to jump forward but stumble on your own feet, diving straight into the cave wall, resulting in the big rock ",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"falling down on you. Ouch, it really hurts inside the brain as you die, fortunately its kinda quick.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 18) // death5
{
draw_sprite(buffer, cavedead, 0, 0);
textout_ex(buffer,myfont7,"Really? Stand directly under a rock? How did you ever make it this far is beyond me. The rock falls on you, ",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"crushes you, and you die instantly. There is no real pain, but c'mon, you could have done better.",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 19) // death6
{
draw_sprite(buffer, bookdead, 0, 0);
textout_ex(buffer,myfont7,"Your tummy is wrong, a book is not food no matter how fresh the ink is. Also, the ink is poisonous, and",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"while you fall, your brain interprets the poison as numerous wierd colors. The last thing you hear before you",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"die is the voice of an hungry stomach, displeased with the chain of events.",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 20) // death7
{
draw_sprite(buffer, cavedead, 0, 0);
textout_ex(buffer,myfont7,"While running out from the cave you acidentally hit the sidewall. Uh-oh the big rock. Yes, it falls on you,",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"snapping every bone in your spine and pins you to the ground in a big pile of FAIL! ",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"May you have better luck in the afterlife.",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 21) // death8
{
draw_sprite(buffer, tummy, 0, 0);
textout_ex(buffer,myfont7,"You grab all the golden coins as you can, trying to fit them inside your pockets. You dont even notice when the ",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"dragon wakes up, and in one swift motion eats you alive. Well this sucks. Atleast you have some gold, its not ",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"much but its the only kind of poor help you have while slowly being digested.",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"May your kinda sucky soul rest in peace. (sorry but really.....take stuff from a dragon?)",30,860,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
else if (Screen == 22) // death9
{
draw_sprite(buffer, tummy, 0, 0);
textout_ex(buffer,myfont7,"'moms a-nom nom' is the sound when a dragon eats you alive. You really should pay more attention to detail.",30,770,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"At least you dont have to be afraid of the dragon eating you anymore....since it already happened. ",30,800,makecol(255,255,255), -1 );
textout_ex(buffer,myfont7,"You also lie on top of a big pile of gold.....if thats any comfort. ",30,830,makecol(255,255,255), -1 );
textout_ex(buffer,m2,"-:( press (esc) to return to main menu ):-",400,940,makecol(255,255,255), -1 );
}
acquire_screen(); // get control of the screen
blit(buffer, screen, 0, 0, 0, 0, 1200, 983); // draw from the buffer to the screen
clear_bitmap(buffer); // clear the buffer bitmap
release_screen(); // release control of the screen
} // while not done
destroy_bitmap(menu); // here we destroy everything loaded-
destroy_bitmap(about);// so there is no memory leaks.
destroy_bitmap(me);
destroy_bitmap(road);
destroy_bitmap(swamp);
destroy_bitmap(raft);
destroy_bitmap(end);
destroy_bitmap(book);
destroy_bitmap(cave);
destroy_bitmap(dragon1);
destroy_bitmap(dragon2);
destroy_bitmap(dragon3);
destroy_bitmap(dragon4);
destroy_bitmap(raftdead);
destroy_bitmap(roaddead);
destroy_bitmap(cavedead);
destroy_bitmap(bookdead);
destroy_bitmap(swampdead);
destroy_bitmap(tummy);
destroy_bitmap(buffer);
destroy_bitmap(Bunny);
destroy_font(myfont7);
destroy_font(m2);
destroy_sample(menumusic);
destroy_sample(bookdeadwav);
destroy_sample(cavedead1);
destroy_sample(drown);
destroy_sample(error1);
destroy_sample(error2);
destroy_sample(heartbeat);
destroy_midi(ending);
destroy_midi(gamemusic);
destroy_midi(gameover);
destroy_midi(hack);
allegro_exit(); // safety for compatability
return 0;
}
END_OF_MAIN(); // Allegro specific
void initAllegro() // function to initialize Allegro
{
allegro_init();
install_keyboard();
install_timer();
install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, "A");
LOCK_VARIABLE(speed_counter); //sets the timer - to regulate speed
LOCK_FUNCTION(increment_speed_counter);
install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));//Set BPS (60 frames per second)
set_color_depth( 32 );
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1200, 983, 0, 0);
set_window_title ("Escape From Madness");
LOCK_FUNCTION(Increment); // Locking because of interrupts,
LOCK_VARIABLE(counter); // so it works as expected
install_int_ex(Increment, BPS_TO_TIMER(60)); // 60 Beats per second (refreshrate)
}
END_OF_FUNCTION(initAllegro);
void increment_speed_counter()
{
speed_counter++;
}
END_OF_FUNCTION(increment_speed_counter);