Main Page | Class List | Directories | File List | Class Members | File Members

bowler.c File Reference

#include <stdio.h>
#include <allegro.h>
#include "include/supercsbros.h"

Include dependency graph for bowler.c:

Go to the source code of this file.

Functions

int main (void)
void initialize ()
void main_menu ()
void quitgame ()
void settings_menu ()
void ticker ()
void updatetime ()
void updatescore ()
void updatestats ()
BITMAP * grabframe (BITMAP *source, int width, int height, int startx, int starty, int columns, int frame)
void loadsprites ()
int inside (int x, int y, int left, int top, int right, int bottom)
void updatebullet (SPRITE *spr)
void updatebullets ()
void loadsounds ()
int collided (int x, int y)
void draw_crosshair ()
void restart_level ()
void fire ()
void checkinput ()
void update_enemies ()
void updatesprite (SPRITE *spr)
void updatemap ()
void updateplayer ()
void get_cd ()
void get_jumpdrive ()
void check_ground ()
void do_jump ()
void boss_battle ()
void init_win32 ()
void init_linux ()
void init_unix ()
char * OSinit (int number)
 END_OF_MAIN ()


Function Documentation

void boss_battle  ) 
 

Definition at line 786 of file bowler.c.

Referenced by main(), and updateplayer().

00787 {
00788   remove_timer();
00789   allegro_message("The Battle Begins Now...");
00790   
00791 }

void check_ground  ) 
 

Definition at line 767 of file bowler.c.

References collided(), SPRITE::collision, SPRITE::height, jump, JUMPIT, player, SPRITE::width, SPRITE::x, and SPRITE::y.

Referenced by main().

00768 {
00769   if (jump==JUMPIT) {
00770     if (!collided(player->x + player->width/2, player->y + player->height+5)) {
00771       jump = 0;
00772       player->collision=0;
00773     }
00774   }
00775 }

Here is the call graph for this function:

void checkinput  ) 
 

Definition at line 568 of file bowler.c.

Referenced by boss_battle(), and main().

00569 {
00570   if (key[KEY_1]) {
00571     if (env->audio_enabled)
00572       play_sample(music, env->audio_volume, env->audio_pan, env->audio_pitch, TRUE);
00573   }
00574   if (key[KEY_2]) {
00575     if (env->audio_enabled)
00576       stop_sample(music);
00577   }
00578   if (key[KEY_S]) {
00579     env->counter = 100000;
00580     remove_timer();
00581   }
00582   if (key[KEY_H]) {
00583     stats->health -= (int)(env->diff_mod * 5);
00584     if (stats->health < 0) {
00585       allegro_message("You die.  Your corpse is quickly eaten by a grue.");
00586       stats->lives--;
00587       restart_level();
00588     }
00589   }
00590   if (key[KEY_C]) {
00591     get_cd();
00592   }
00593   if (key[KEY_J]) {
00594     get_jumpdrive();
00595   }
00596   if (key[KEY_W]) {
00597     jump = 45;
00598   }
00599   if (key[KEY_LCONTROL]) {
00600     fire();
00601   }
00602   if (key[KEY_RIGHT]) { 
00603     player->rightfacing = 1; 
00604     player->x+=4; 
00605     if (++player->framecount > player->framedelay) {
00606       player->framecount=0;
00607       if (++player->curframe > player->maxframe)
00608         player->curframe=1;
00609     }
00610   }
00611   else if (key[KEY_LEFT]) { 
00612     player->rightfacing = 0; 
00613     player->x-=4; 
00614     if (++player->framecount > player->framedelay) {
00615       player->framecount=0;
00616       if (++player->curframe > player->maxframe)
00617         player->curframe=1;
00618     }
00619   }
00620   else player->curframe=0;
00621   
00622   if (key[KEY_SPACE]) {
00623     do_jump();
00624   }
00625   return;
00626 }

int collided int  x,
int  y
 

Definition at line 498 of file bowler.c.

References BLKSTR::bl, mapblockheight, mapblockwidth, and MapGetBlock().

Referenced by check_ground(), checkinput(), updateplayer(), and updatesprite().

00499 {
00500   BLKSTR *blockdata;
00501   blockdata = MapGetBlock(x/mapblockwidth, y/mapblockheight);
00502   return blockdata->bl;
00503 }

Here is the call graph for this function:

void do_jump  ) 
 

Definition at line 777 of file bowler.c.

Referenced by checkinput().

00778 {
00779   jump=35;
00780   if (env->audio_enabled)
00781     play_sample(sounds[JUMP], VOLUME, PAN, PITCH, FALSE);
00782 }

void draw_crosshair  ) 
 

Definition at line 505 of file bowler.c.

Referenced by main().

00506 {
00507 
00508   //  line (buffer, player->x+player->width/4 - mapxoff, player->y - jump/5 - mapyoff, player->x + 3 * player->width/4 - mapxoff, player->y - jump/5 - mapyoff, RED);
00509   // top left
00510   line(buffer, (player->x - 10 - mapxoff), (player->y - mapyoff), (player->x + 10 - mapxoff), (player->y - mapyoff), RED);
00511   line(buffer, (player->x - mapxoff), (player->y - 10 - mapyoff), (player->x - mapxoff), (player->y + 10 - mapyoff), RED);
00512 
00513   // bottom left
00514   line(buffer, (player->x - 10 - mapxoff), (player->y - mapyoff + player->height), (player->x + 10 - mapxoff), (player->y - mapyoff + player->height), RED);
00515   line(buffer, (player->x - mapxoff), (player->y - 10 - mapyoff + player->height), (player->x - mapxoff), (player->y + 10 - mapyoff + player->height), RED);
00516 
00517   // top right
00518   line(buffer, (player->x - 10 - mapxoff + player->width), (player->y - mapyoff), (player->x + 10 - mapxoff + player->width), (player->y - mapyoff), RED);
00519   line(buffer, (player->x - mapxoff + player->width), (player->y - 10 - mapyoff), (player->x - mapxoff + player->width), (player->y + 10 - mapyoff), RED);
00520 
00521   // bottom right
00522   line(buffer, (player->x - 10 - mapxoff + player->width), (player->y - mapyoff + player->height), (player->x + 10 - mapxoff + player->width), (player->y - mapyoff + player->height), RED);
00523   line(buffer, (player->x - mapxoff + player->width), (player->y - 10 - mapyoff + player->height), (player->x - mapxoff + player->width), (player->y + 10 - mapyoff + player->height), RED);
00524   return;
00525 }

END_OF_MAIN  ) 
 

void fire  ) 
 

Definition at line 547 of file bowler.c.

Referenced by checkinput().

00548 {
00549   int n;
00550   for (n=0; n<MAX_BULLETS; n++)
00551     {
00552       if (!bullets[n]->alive)
00553         {
00554           bullets[n]->alive++;
00555           bullets[n]->x = player->x;
00556           bullets[n]->y = player->y + player->height/2;
00557           if (player->rightfacing)
00558             bullets[n]->rightfacing=1;
00559           else
00560             bullets[n]->rightfacing=0;
00561           return;
00562         }
00563     }
00564 }

void get_cd  ) 
 

Definition at line 751 of file bowler.c.

References ENVIRONMENT::audio_enabled, env, ITEM, PAN, PITCH, STATS::score, sounds, stats, and VOLUME.

Referenced by checkinput().

00752 {
00753   if (env->audio_enabled) {  play_sample(sounds[ITEM], VOLUME, PAN, PITCH, FALSE); }
00754   stats->score += 35;
00755   return;
00756 }

void get_jumpdrive  ) 
 

Definition at line 759 of file bowler.c.

References ENVIRONMENT::audio_enabled, env, ITEM, PAN, PITCH, STATS::score, sounds, stats, and VOLUME.

Referenced by checkinput().

00760 {
00761   if (env->audio_enabled) {  play_sample(sounds[ITEM], VOLUME, PAN, PITCH, FALSE); }
00762   stats->score += 35;
00763   return;
00764 }

BITMAP* grabframe BITMAP *  source,
int  width,
int  height,
int  startx,
int  starty,
int  columns,
int  frame
 

Definition at line 260 of file bowler.c.

References temp.

Referenced by boss_battle(), and loadsprites().

00264 {
00265   BITMAP *temp = create_bitmap(width,height);
00266   int x = startx + (frame % columns) * width;
00267   int y = starty + (frame / columns) * height;
00268   blit(source,temp,x,y,0,0,width,height);
00269   return temp;
00270 }

void init_linux  ) 
 

Definition at line 801 of file bowler.c.

Referenced by OSinit().

00802 {
00803   allegro_message("GNU/Linux has not yet been tested; some options will be disabled");
00804   env->audio_enabled = FALSE;
00805   set_window_title(title_string);
00806   return;
00807 }

void init_unix  ) 
 

Definition at line 808 of file bowler.c.

Referenced by OSinit().

00809 {
00810   env->audio_enabled = FALSE;
00811   set_window_title(title_string);
00812   return;
00813 }

void init_win32  ) 
 

Definition at line 795 of file bowler.c.

Referenced by OSinit().

00796 {
00797   set_window_title(title_string);
00798   //loadsounds();
00799   return;
00800 }

void initialize  ) 
 

Definition at line 54 of file bowler.c.

Referenced by main().

00055 {
00056   allegro_init();
00057 
00058   install_timer();
00059   install_keyboard();
00060   install_mouse(); 
00061    
00062   set_color_depth(32);
00063   set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
00064   buffer = create_bitmap (WIDTH, HEIGHT);
00065   clear(buffer);
00066 
00067   enable_hardware_cursor();
00068   select_mouse_cursor(MOUSE_CURSOR_ARROW);
00069   show_mouse(screen);
00070 
00071   if (MapLoad(map_file))
00072     {
00073       allegro_message("Error reading the map file: %s", map_file);
00074       exit(1);
00075     }
00076   player = malloc(sizeof(SPRITE));
00077   stats  = malloc(sizeof(STATS));
00078   env    = malloc(sizeof(ENVIRONMENT));
00079 
00080   stats->health = 25;
00081   stats->score  = 0;
00082   stats->lives  = 3;
00083 
00084   env->counter  = 300;
00085   env->ticks    = 0;
00086   env->diff_mod = 2.00;
00087 
00088   player->x = 0;
00089   player->y = 0;
00090 
00091   OSinit(os_type);
00092   return;
00093 }

int inside int  x,
int  y,
int  left,
int  top,
int  right,
int  bottom
 

Definition at line 380 of file bowler.c.

Referenced by updatebullet(), and updateplayer().

00381 {
00382     if (x > left && x < right && y > top && y < bottom)
00383         return 1;
00384     else
00385         return 0;
00386 }

void loadsounds  ) 
 

Definition at line 439 of file bowler.c.

00440 {
00441   /* we might actually want to keep these in a modifiable place, rather than DEFINEs, so we can change them in-game.... */
00442   /*   env->audio_enabled = 1; */
00443   /*   env->audio_pan = 128; */
00444   /*   env->audio_pitch = 1000; */
00445   /*   env->audio_volume = 128; */
00446   if (install_sound(DIGI_AUTODETECT, MIDI_NONE, " ") != 0)
00447     {
00448       allegro_message("Error initializing sound system");
00449       return;
00450     }
00451   
00452   sounds[villian_Audio] = load_sample("villian_Audio.wav");
00453   if (!sounds[villian_Audio])
00454     {
00455       allegro_message("error reading villian_Audio.wav");
00456       return;
00457     }
00458   
00459   sounds[JUMP] = load_sample("jump.wav");
00460   if (!sounds[JUMP])
00461     {
00462       allegro_message("error reading jump.wav");
00463       return;
00464     }
00465   
00466   sounds[ITEM] = load_sample("item.wav");
00467   if (!sounds[ITEM])
00468     {
00469       allegro_message("error reading item.wav");
00470       return;
00471     }
00472   
00473   sounds[SHOOT] = load_sample("shoot.wav");
00474   if (!sounds[SHOOT])
00475     {
00476       allegro_message("error reading shoot.wav");
00477       return;
00478     }
00479   
00480   sounds[HIT] = load_sample("hit.wav");
00481   if (!sounds[HIT])
00482     {
00483       allegro_message("error reading hit.wav");
00484       return;
00485     }
00486   
00487   play_sample(sounds[4], VOLUME, PAN, PITCH, FALSE);
00488   
00489   //free the samples
00490   //for (n=0; n < NUM_SOUNDS; n ++)
00491   //   destroy_sample(sounds[n]);
00492   
00493   //remove_sound();  /* why are we removing the sound driver?  we have to play sound! */
00494 }

void loadsprites void   ) 
 

Definition at line 273 of file bowler.c.

Referenced by initialize(), and main().

00274 {
00275   int n;
00276 
00277   // used for health status
00278   temp = load_bitmap("images/progress.bmp", NULL);
00279   progress = grabframe(temp,130,14,0,0,1,0);
00280   bar = grabframe(temp,6,10,130,2,1,0);
00281   destroy_bitmap(temp);
00282 
00283   // Stevie's sprites
00284   temp = load_bitmap(player_bitmap, NULL);
00285   for (n=0; n<8; n++)
00286     player_images[n] = grabframe(temp,50,64,0,0,8,n);
00287   destroy_bitmap(temp);
00288     
00289   player = malloc(sizeof(SPRITE));
00290   player->x = 80;
00291   player->y = 100;
00292   player->curframe=0;
00293   player->framecount=0;
00294   player->framedelay=6;
00295   player->rightfacing=0;
00296   player->maxframe=7;
00297   player->width=player_images[0]->w;
00298   player->height=player_images[0]->h;
00299   player->collision=0;
00300     
00301   temp = load_bitmap(enemy_bitmap1, NULL);
00302   for (n=0; n<8; n++)
00303     mis_1_images[n] = grabframe(temp,50,64,0,0,8,n);
00304   destroy_bitmap(temp);
00305 
00306   for (n=0; n<MAX_ENEMIES; n++)
00307     {
00308       enemies[n] = malloc(sizeof(SPRITE));
00309       enemies[n]->alive = 1;
00310       enemies[n]->width = mis_1_images[0]->w;
00311       enemies[n]->height = mis_1_images[0]->h;
00312       enemies[n]->rightfacing = 0;
00313       enemies[n]->xdelay = 4;
00314       enemies[n]->ydelay = 0;
00315       enemies[n]->xcount = 5;
00316       enemies[n]->ycount = 0;
00317       enemies[n]->xspeed = 0;
00318       enemies[n]->yspeed = 0;
00319       enemies[n]->curframe = 0;
00320       enemies[n]->maxframe = 2;
00321       enemies[n]->framecount = 0;
00322       enemies[n]->framedelay = 10;
00323       enemies[n]->animdir = 1;
00324       //      enemies[n]->jump = JUMPIT;
00325     }
00326   enemies[0]->x = 524;   enemies[0]->y = 287;
00327   enemies[1]->x = 1456;  enemies[1]->y = 127;
00328   enemies[2]->x = 2316;  enemies[2]->y = 286;
00329   enemies[3]->x = 2656;  enemies[3]->y = 286;
00330   enemies[4]->x = 3632;  enemies[4]->y = 158;
00331   enemies[5]->x = 5256;  enemies[5]->y = 446;
00332   enemies[6]->x = 5196;  enemies[6]->y = 254;
00333   enemies[7]->x = 5592;  enemies[7]->y = 254;
00334   enemies[8]->x = 6280;  enemies[8]->y = 319;
00335   enemies[9]->x = 7436;  enemies[9]->y = 190;
00336 
00337   temp = load_bitmap(boss_bitmap, NULL);
00338   for (n=0; n<8; n++)
00339     boss_images[n] = grabframe(temp,50,64,0,0,8,n);
00340   destroy_bitmap(temp);
00341   
00342   boss = malloc(sizeof(SPRITE));
00343   boss->x = 9016 ;
00344   boss->y = 62 ;
00345   boss->curframe = 0;
00346   boss->alive=1;
00347   boss->framecount = 0;
00348   boss->framedelay = 4;
00349   boss->maxframe=7;
00350   boss->width=boss_images[0]->w;
00351   boss->height=boss_images[0]->h;
00352   boss->collision = 0;
00353   boss->rightfacing=0;
00354   //  boss->jump = JUMPIT;
00355 
00356   bullet_image = load_bitmap("objects/ball.pcx", NULL);
00357 
00358   for (n=0; n<MAX_BULLETS; n++) {
00359     bullets[n] = malloc(sizeof(SPRITE));
00360     bullets[n]->alive=0;
00361     bullets[n]->x=0;
00362     bullets[n]->y=0;
00363     bullets[n]->xspeed=6;
00364     bullets[n]->yspeed=0;
00365     bullets[n]->xdelay=0;
00366     bullets[n]->ydelay=0;
00367     bullets[n]->xcount=1;
00368     bullets[n]->ycount=0;
00369     bullets[n]->curframe=0;
00370     bullets[n]->maxframe=0;
00371     bullets[n]->animdir=0;
00372     bullets[n]->framedelay=0;
00373     bullets[n]->framecount=0;
00374     bullets[n]->width=bullet_image->w;
00375     bullets[n]->height=bullet_image->h;
00376   }
00377 
00378 }

int main void   ) 
 

Definition at line 5 of file bowler.c.

References buffer, check_ground(), checkinput(), SPRITE::collision, ENVIRONMENT::counter, ENVIRONMENT::diff_mod, draw_crosshair(), env, HEIGHT, initialize(), loadsprites(), main_menu(), MapFreeMem(), SPRITE::oldpx, SPRITE::oldpy, player, ticker(), ENVIRONMENT::ticks, ticks, update_enemies(), updatebullets(), updateplayer(), updatescore(), updatestats(), updatetime(), WIDTH, SPRITE::x, and SPRITE::y.

00006 {
00007   int nticks;
00008   initialize(); /* env->diff_mod is given a default value here. */
00009   main_menu();  /* env->diff_mod is given a uservalue here.  it is part of the difficulty setting menu. */
00010   loadsprites();
00011 
00012   LOCK_VARIABLE(ticks);
00013   LOCK_FUNCTION(ticker);
00014   install_int_ex(ticker, MSEC_TO_TIMER( (int)(1000 * env->diff_mod)));
00015   env->ticks=0;
00016 
00017   while (!key[KEY_ESC])
00018     {
00019 
00020       clear(buffer);
00021       player->oldpy = player->y; /* XXX: Here be dragons.  We need to keep track of last */
00022       player->oldpx = player->x; /*      position for collision detection                */
00023       nticks = env->ticks;
00024       env->ticks = 0;
00025 
00026       for (; nticks >0; nticks--) {
00027         --env->counter;
00028       }
00029 
00030       player->collision=0;
00031       checkinput();
00032       check_ground();
00033       updateplayer();
00034       updatebullets();
00035       update_enemies();
00036       draw_crosshair();
00037       updatestats();
00038       updatescore();
00039       updatetime();
00040       
00041       vsync();
00042       acquire_screen();
00043       blit(buffer, screen, 0, 0, 0, 0, WIDTH-1, HEIGHT-1);
00044       release_screen();
00045     }
00046 
00047   MapFreeMem();
00048   allegro_exit();
00049   return 0;
00050 }

Here is the call graph for this function:

void main_menu  ) 
 

Definition at line 95 of file bowler.c.

Referenced by end_game(), and main().

00096 {
00097   int i = 0;
00098   int s = 3;
00099   
00100   BITMAP *bg;
00101   /* in order: start, settings, quit */
00102   BITMAP *menu_items_unselected[3];
00103   BITMAP *menu_items_selected[3];
00104 
00105   bg = load_bitmap(bg_file, NULL);
00106   if (!bg) {
00107     allegro_message("Error loading %s", bg);
00108     return;
00109   }
00110   menu_items_unselected[0] = load_bitmap("menus/start_unselected.pcx", NULL);
00111   menu_items_unselected[1] = load_bitmap("menus/settings_unselected.pcx", NULL);
00112   menu_items_unselected[2] = load_bitmap("menus/quit_unselected.pcx", NULL);
00113   menu_items_selected[0]  = load_bitmap("menus/start_selected.pcx", NULL);
00114   menu_items_selected[1]  = load_bitmap("menus/settings_selected.pcx", NULL);
00115   menu_items_selected[2]  = load_bitmap("menus/quit_selected.pcx", NULL);
00116 
00117   blit(bg, screen, 0, 0, 0, 0, bg->w, bg->h);
00118   for (i=0; i<3; i++) {
00119     blit(menu_items_unselected[i], screen, 0, 0, 300, (200 + i * 64), SCREEN_W-1, SCREEN_H-1);
00120   }
00121 /*   blit(menu_items_selected[s], screen, 0, 0, 300, (200 + s * 64), SCREEN_W-1, SCREEN_H-1); */
00122   
00123   while (1)
00124     {
00125       mouse_b=0;
00126       if ((mouse_x >= 300) && (mouse_x <= 510) && (mouse_y >= 200) && (mouse_y <= 263)) s = 0;
00127       if ((mouse_x >= 300) && (mouse_x <= 510) && (mouse_y >= 264) && (mouse_y <= 327)) s = 1;
00128       if ((mouse_x >= 300) && (mouse_x <= 510) && (mouse_y >= 328) && (mouse_y <= 392)) s = 2;
00129 
00130       /* set selected item based on bounding rectangle */
00131       if (mouse_b & 1) {
00132         switch (s) {
00133         case 0: break;
00134         case 1: 
00135           settings_menu();
00136           blit(bg, screen, 0, 0, 0, 0, bg->w, bg->h);
00137           for (i=0; i<3; i++)
00138             blit(menu_items_unselected[i], screen, 0, 0, 300, (200 + i * 64), SCREEN_W-1, SCREEN_H-1);
00139           break;
00140         case 2: quitgame();
00141         }
00142         if (s == 0) break;
00143       }
00144     }
00145   return;
00146 }

char* OSinit int  number  ) 
 

Definition at line 820 of file bowler.c.

Referenced by initialize().

00821 {
00822   switch (number)
00823     {
00824     case OSTYPE_WIN3:    /* fallthrough */
00825     case OSTYPE_WIN95:   /*      |      */
00826     case OSTYPE_WIN98:   /*      |      */
00827     case OSTYPE_WINME:   /*      |      */
00828     case OSTYPE_WINNT:   /*     \|/     */
00829     case OSTYPE_WIN2000: /*      '      */
00830     case OSTYPE_WINXP:
00831       init_win32(); 
00832       break;
00833     case OSTYPE_LINUX:
00834       init_linux();
00835       break;
00836     case OSTYPE_UNIX:
00837       init_unix();
00838       break;
00839     }
00840   return "";
00841 }

void quitgame  ) 
 

Definition at line 148 of file bowler.c.

Referenced by main_menu().

00149 {
00150   exit(0);
00151 }

void restart_level  ) 
 

Definition at line 527 of file bowler.c.

Referenced by checkinput(), updateplayer(), and updatetime().

00528 {
00529   if (stats->lives > 0)
00530     {
00531       stats->health=25;
00532       env->counter=300;
00533       stats->score=0;
00534       player->x = 80;
00535       player->y = 100;
00536       player->collision=0;
00537       jump = JUMPIT;
00538     }
00539   else
00540     {
00541       allegro_message("Deiner gemütlichkeit is kaput!  Exiting game...\n");
00542       exit(0);
00543     }
00544   return;
00545 }

void settings_menu  ) 
 

Definition at line 153 of file bowler.c.

Referenced by main_menu(), and show_menu().

00154 {
00155   int i;
00156   int s = 0;
00157 
00158   BITMAP *settings_bg;
00159   BITMAP *difficulty_level_on[3];
00160   BITMAP *difficulty_level_off[3];
00161   BITMAP *on_unselected, *off_unselected, *done_unselected;
00162   BITMAP *difficulty, *audio;
00163 
00164   settings_bg = load_bitmap("menus/settings_bg.pcx", NULL);
00165   blit(settings_bg, screen, 0, 0, 0, 0, settings_bg->w, settings_bg->h);
00166  
00167   difficulty = load_bitmap("menus/difficulty.pcx", NULL);
00168   audio = load_bitmap("menus/audio.pcx", NULL);
00169   done_unselected = load_bitmap("menus/done_unselected.pcx", NULL);
00170   on_unselected = load_bitmap("menus/on_unselected.pcx", NULL);
00171   off_unselected = load_bitmap("menus/off_unselected.pcx", NULL);
00172 
00173   difficulty_level_off[0] = load_bitmap("menus/a_unselected.pcx", NULL);
00174   difficulty_level_off[1] = load_bitmap("menus/b_unselected.pcx", NULL);
00175   difficulty_level_off[2] = load_bitmap("menus/c_unselected.pcx", NULL);
00176   difficulty_level_on[0]  = load_bitmap("menus/a_selected.pcx", NULL);
00177   difficulty_level_on[1]  = load_bitmap("menus/b_selected.pcx", NULL);
00178   difficulty_level_on[2]  = load_bitmap("menus/c_selected.pcx", NULL);
00179 
00180   blit(difficulty, screen,0, 0, 85, 200, difficulty->w, difficulty->h);
00181   blit(audio, screen, 0, 0, 250, 240, audio->w, audio->h);
00182   blit(done_unselected, screen, 0, 0, 270, 280, done_unselected->w, done_unselected->h);
00183   blit(on_unselected, screen, 0, 0, 410, 240, on_unselected->w, on_unselected->h);
00184   blit(off_unselected, screen, 0, 0, 470, 240, off_unselected->w, off_unselected->h);
00185 
00186   for (i=0; i<3; i++) {
00187     blit(difficulty_level_off[i], screen, 0, 0, (400 + i * 70), 200, SCREEN_W-1, SCREEN_H-1);
00188   }
00189   
00190   while (1)
00191     {
00192        /* which option are we selecting? */
00193       if ((mouse_x >= 400) && (mouse_x <= 460) && (mouse_y >= 200) && (mouse_y <= 240)) s = 0; /* A Option */
00194       if ((mouse_x >= 470) && (mouse_x <= 530) && (mouse_y >= 200) && (mouse_y <= 240)) s = 1; /* B  "     */
00195       if ((mouse_x >= 540) && (mouse_x <= 600) && (mouse_y >= 200) && (mouse_y <= 240)) s = 2; /* C  "     */
00196       if ((mouse_x >= 410) && (mouse_x <= 460) && (mouse_y >= 241) && (mouse_y <= 280)) s = 3; /* Audio on */
00197       if ((mouse_x >= 470) && (mouse_x <= 530) && (mouse_y >= 241) && (mouse_y <= 280)) s = 4; /* Audio off*/
00198       if ((mouse_x >= 270) && (mouse_x <= 375) && (mouse_y >= 280) && (mouse_y <= 320)) s = 5; /* Done     */
00199 
00200       /* set selected item based on bounding rectangle */
00201       if (mouse_b & 1) {
00202         switch (s) {
00203         case 0: env->diff_mod = 0.42;   break; /* A option */
00204         case 1: env->diff_mod = 0.75;   break; /* B  "     */
00205         case 2: env->diff_mod = 1.00;   break; /* C  "     */
00206         case 3: env->audio_enabled = 1; break; 
00207         case 4: env->audio_enabled = 0; break;
00208         case 5: break;                         /* Just one of those days. */
00209         }
00210         if (s == 5) break;
00211       }
00212     }
00213   destroy_bitmap(settings_bg);
00214   return;
00215 }

void ticker  ) 
 

Definition at line 217 of file bowler.c.

Referenced by main().

00218 {
00219   ++env->ticks;
00220   return;
00221 }

void update_enemies  ) 
 

Definition at line 630 of file bowler.c.

Referenced by boss_battle(), and main().

00631 {
00632   int n;
00633   
00634   for (n=0; n<10; n++) {
00635     if (enemies[n]->alive) {
00636            if ((enemies[n]->x - player->x - mapxoff) <= 600)
00637              enemies[n]->xspeed = 2;
00638            updatesprite(enemies[n]);
00639            draw_sprite(buffer, mis_1_images[enemies[n]->curframe],
00640                        enemies[n]->x - mapxoff, enemies[n]->y-mapyoff);
00641     }
00642   }
00643   if (boss->alive) {
00644     draw_sprite(buffer, boss_images[boss->curframe], boss->x-mapxoff, boss->y-mapyoff);
00645   } 
00646 }

void updatebullet SPRITE spr  ) 
 

Definition at line 388 of file bowler.c.

Referenced by updatebullets().

00389 {
00390     int n,x,y;
00391     int x1,y1,x2,y2;
00392 
00393     updatesprite(spr);
00394 
00395     if (spr->x < mapxoff || spr->x > mapxoff + SCREEN_W)
00396     {
00397         spr->alive = 0;
00398         return;
00399     }
00400 
00401     for (n=0; n<MAX_ENEMIES; n++)
00402     {
00403         if (enemies[n]->alive)
00404         {
00405             //find center of bullet
00406             x = spr->x + spr->width/2 - mapxoff;
00407             y = spr->y + spr->height/2 - mapyoff;
00408 
00409             //get enemy bounding rectangle
00410             x1 = enemies[n]->x - mapxoff;
00411             y1 = enemies[n]->y - mapyoff;
00412             x2 = x1 + enemies[n]->width;
00413             y2 = y1 + enemies[n]->height;
00414 
00415             //check for collisions
00416             if (inside(x, y, x1, y1, x2, y2))
00417             {
00418                 enemies[n]->alive=0;
00419                 spr->alive=0;
00420                 //startexplosion(spr->x+16, spr->y);
00421                 //score+=2;
00422                 //break;
00423             }
00424         }
00425         }
00426 }

void updatebullets  ) 
 

Definition at line 428 of file bowler.c.

Referenced by boss_battle(), and main().

00429 {
00430     int n;
00431     for (n=0; n<MAX_BULLETS; n++)
00432         if (bullets[n]->alive)
00433         {
00434           updatebullet(bullets[n]);
00435           draw_sprite(buffer,bullet_image, bullets[n]->x-mapxoff, bullets[n]->y-mapyoff);
00436         }
00437 }

void updatemap  ) 
 

Definition at line 686 of file bowler.c.

References buffer, HEIGHT, SPRITE::height, mapblockheight, mapblockwidth, MapDrawBG(), MapDrawFG(), mapheight, mapwidth, mapxoff, mapyoff, player, WIDTH, SPRITE::width, SPRITE::x, and SPRITE::y.

Referenced by updateplayer().

00687 {
00688   //update the map scroll position
00689   mapxoff = player->x + player->width/2 - WIDTH/2 + 10;
00690   mapyoff = player->y + player->height/2 - HEIGHT/2 + 10;
00691     
00692   //avoid moving beyond the map edge
00693   if (mapxoff < 0) mapxoff = 0;
00694   if (mapxoff > (mapwidth * mapblockwidth - WIDTH))
00695     mapxoff = mapwidth * mapblockwidth - WIDTH;
00696   if (mapyoff < 0) 
00697     mapyoff = 0;
00698   if (mapyoff > (mapheight * mapblockheight - HEIGHT)) 
00699     mapyoff = mapheight * mapblockheight - HEIGHT;
00700   
00701   MapDrawBG(buffer, mapxoff, mapyoff, 0, 0, WIDTH-1, HEIGHT-1);
00702   MapDrawFG(buffer, mapxoff, mapyoff, 0, 0, WIDTH-1, HEIGHT-1, 0);
00703   return;
00704 }

Here is the call graph for this function:

void updateplayer  ) 
 

Definition at line 708 of file bowler.c.

Referenced by boss_battle(), and main().

00709 {
00710   if (jump != JUMPIT) /* if jump != JUMPIT */
00711     {
00712       if (!(collided(player->x, player->y - jump/5) || collided(player->x + player->width / 2, player->y - jump/5) || collided(player->x + player->width, player->y - jump/5)) ||
00713           collided(player->x, player->y + player->height/2) || collided(player->x + player->width, player->y + player->height/2) || 
00714           collided(player->x, player->height) || collided(player->x + player->width, player->y))
00715         {
00716           player->y -= jump/5;
00717           jump--;
00718         }
00719       else {
00720         jump = 0;
00721         player->collision = 1;
00722       }
00723     }
00724   
00725   if (jump<0)
00726     {
00727       if (collided(player->x + player->width/2, player->y + player->height) || collided(player->x + player->width/2, player->y))
00728         {
00729           player->collision=1;
00730           jump = JUMPIT;
00731           while (collided(player->x + player->width/2,  player->y + player->height))
00732             player->y -= 2;  /* in case we get stuck, push player back up */
00733         }
00734     }
00735 
00736   if (player->x == 8600)
00737     boss_battle();
00738   updatesprite(player);
00739   updatemap();
00740 
00741   if (player->rightfacing) 
00742     draw_sprite(buffer, player_images[player->curframe], 
00743                 (player->x-mapxoff), (player->y-mapyoff+1));
00744   else 
00745     draw_sprite_h_flip(buffer, player_images[player->curframe], 
00746                        (player->x-mapxoff), (player->y-mapyoff));
00747   return;
00748 }

void updatescore  ) 
 

Definition at line 235 of file bowler.c.

Referenced by boss_battle(), and main().

00236 {
00237   textprintf_ex(buffer, font, 15, 5, WHITE, -1,"Score: %d", stats->score);
00238   textprintf_ex(buffer, font, 105, 5, WHITE, -1, "Lives: %d", stats->lives);
00239   textprintf_ex(buffer, font, 210, 5, WHITE, -1, "Jump: %d", jump);
00240   return;
00241 }

void updatesprite SPRITE spr  ) 
 

Definition at line 648 of file bowler.c.

Referenced by update_enemies(), updatebullet(), and updateplayer().

00649 {
00650 
00651   if(!spr->rightfacing) { 
00652     if (collided(spr->x, spr->y + spr->height) || collided(spr->x, spr->y+5)) {
00653       spr->collision=1;
00654       spr->x = spr->oldpx; 
00655     }
00656   }
00657   else { 
00658     if (collided(spr->x + spr->width, spr->y + spr->height) || collided(spr->x + spr->width, spr->y+5)) {
00659       spr->collision=1;
00660       spr->x = spr->oldpx;  /* make sure to set oldpx for all sprites! */
00661     }
00662   }      
00663 
00664 
00665   if (spr->xcount > spr->xdelay) {
00666     if (spr->rightfacing)
00667       spr->x += spr->xspeed;
00668     else
00669       spr->x -= spr->xspeed;
00670   }
00671   
00672   if (++spr->framecount > spr->framedelay) {
00673     spr->framecount = 0;
00674     if (spr->animdir == -1) {
00675       if (--spr->curframe < 0)
00676         spr->curframe = spr->maxframe;
00677     }
00678     else if (spr->animdir == 1) {
00679       if (++spr->curframe > spr->maxframe)
00680         spr->curframe = 0;
00681     }
00682   }
00683 }

void updatestats  ) 
 

Definition at line 243 of file bowler.c.

Referenced by boss_battle(), and main().

00244 {
00245   int n;
00246   draw_sprite(buffer, progress, 14, 15);
00247    
00248   for (n = 0; n < stats->health; n++) {
00249     draw_sprite(buffer, bar, 15+n*5, 17);
00250   }
00251   textprintf_ex(buffer, font, 300, 5, WHITE, -1, "Player->x: %d", player->x);
00252   textprintf_ex(buffer, font, 450, 5, WHITE, -1, "Player->y: %d", player->y);
00253   textprintf_ex(buffer, font, 300, 20, WHITE, -1, "Difficulty Modifier: %3f", env->diff_mod);
00254   textprintf_ex(buffer, font, 300, 45, WHITE, -1, "Rightfacing: %d", player->rightfacing);
00255   if (jump < 0) {textprintf_ex(buffer, font, 400, 300, WHITE, -1, "FALLING!");}
00256   if (player->collision) {textprintf_ex(buffer, font, 400, 315, WHITE, -1, "Collision!!");}
00257 }

void updatetime  ) 
 

Definition at line 223 of file bowler.c.

Referenced by main().

00224 {
00225   if (env->counter > 0)
00226     textprintf_ex(screen, font, (WIDTH-100), 5, WHITE, -1, "Time: %d", env->counter);
00227   else
00228     {
00229       allegro_message("You've run out of time.  We should do someting now...like restart the level!\n");
00230       restart_level();
00231     }
00232   return;
00233 }


Generated on Wed Jul 5 09:05:22 2006 for Super CS Brothers by  doxygen 1.4.4