Store user data in $HOME
[kball.git] / src / intro.cpp
blobc136eb49ebfccb2130bc577e2eb972d8b2b1cf6d
1 // ------------------------------------------------------------------
2 // intro.cpp
3 // ------------------------------------------------------------------
4 // This is the intro and exit secuence for the game - everything hardcoded, sorry
5 // ------------------------------------------------------------------
6 // By Kronoman - In loving memory of my father
7 // Copyright (c) 2004, Kronoman
8 // ------------------------------------------------------------------
10 #include <allegro.h>
11 #include "intro.h"
12 #include "cwdata.h"
14 void kball_do_the_intro()
16 CWDatafile data;
18 clear_bitmap(screen);
19 textout_centre_ex(screen, font, "[ Please wait... loading... ]", SCREEN_W / 2, SCREEN_H / 2, makecol(255, 255, 255), makecol(0, 0, 64));
21 data.load_datafile("intro.dat");
23 BITMAP *logo = (BITMAP *)data.get_resource_dat("LOGO_KRONOMAN_BMP");
25 SAMPLE *krono_wav = (SAMPLE *)data.get_resource_dat("KRONOMAN_WAV");
27 clear_bitmap(screen);
29 blit(logo, screen,0,0,0,0,logo->w,logo->h);
31 rest(1000);
33 play_sample(krono_wav, 255,128,1000,0);
35 rest(1000);
36 while (!keypressed()) rest(100);
38 clear_bitmap(screen);
39 data.nuke_datafile();
42 void kball_do_the_exit()
44 char tmp_str[2048];
45 BITMAP *face = NULL;
46 CWDatafile data;
47 DATAFILE *datastream; // data stream for reading about text
48 char *readstream; // stream for reading about text
49 int xstream = 0; // where I'm reading the stream?
51 clear_bitmap(screen);
52 textout_centre_ex(screen, font, "[ Please wait... loading... ]", SCREEN_W / 2, SCREEN_H / 2, makecol(255, 255, 255), makecol(0, 0, 64));
54 data.load_datafile("intro.dat");
56 datastream = data.get_resource("INTRO_TXT"); // get about text
58 readstream = (char *)datastream->dat;
60 usprintf(tmp_str, "%d_BMP", rand()%5+1);
61 face = (BITMAP *)data.get_resource_dat(tmp_str);
63 clear_to_color(screen, makecol(255,255,255));
64 blit(face, screen,0,0,(SCREEN_W - face->w) / 2, 5,face->w,face->h);
65 // poner texto
66 int y = face->h+5;
67 int x = SCREEN_W / 2;
68 int c = makecol(0,0,0);
69 int c2 = makecol(0,0,0);
70 char buf[1024];
71 int xbuf = 0;
72 for (xstream =0; xstream < datastream->size; xstream++)
74 if (readstream[xstream] > '\n')
76 buf[xbuf] = readstream[xstream];
77 xbuf++;
79 else
81 if (readstream[xstream] == '\n')
83 buf[xbuf] = '\0';
84 //textout_centre_ex(screen, font, buf, x+1,y+1,c2,-1);
85 textout_centre_ex(screen, font, buf, x,y,c,-1);
87 xbuf = 0;
88 x = SCREEN_W/2;
89 y += text_height(font);
93 buf[xbuf] = '\0';
94 textout_centre_ex(screen, font, buf, x,y,c,-1);
96 rest(500);
97 while (!keypressed()) rest(100);
98 clear_bitmap(screen);