void VideoManager::loadVideoAtCurrentStep()
{
	char filename[256] = "DATA/video/";
	if ( script[currentStep].filename[0] == '*' )
	{
		strcat_s(filename, 256, script[currentStep-1].filename); // check for videos named '*'. I think the original game used this to denote "play that video again"
	}
	else
	{
		strcat_s(filename, 256, script[currentStep].filename);
	}
	strcat_s(filename, 256, ".ogg");

	// default case: show a placeholder texture
	unloadVideo();
	clear_to_color(frameData, makecol(255,255,255));
	textprintf_centre(frameData, font, 160, 90, makecol(0,0,0), "%s", script[currentStep].filename);

	loadVideo(filename);
	if ( cmov == NULL )
	{
		al_trace("Movie %s did not open for whatever reason.\r\n", filename);
		return;
	}

	if ( apeg_advance_stream(cmov, true) != APEG_OK)
	{
		al_trace("Video problem! Breakpoint!\r\n"); // doesn't really matter if it fails
	}
	blit(cmov->bitmap, frameData, 0, 0, 0, 0, 320, 192);
}
Exemple #2
0
//the final score screen
void CGame::ShowResults() {

	int i;
	int finalscore;
	WINDOWS_BITMAP *text;

	text = create_bitmap(220, 130);
	clear_to_color(text,makecol(255,0,255));
	

	scare_mouse();

	//background image
	blit((WINDOWS_BITMAP *)data[ZSCORE_BMP].dat, background,0,0,0,0,SCREEN_W,SCREEN_H);
	
	//print text on temp image and resize
	text_mode(-1);

	for (i=0;i<numplayers;i++) {
		
		finalscore = players[i].CalcFinalScore();
		textprintf_centre(text,font,110,(i*40),players[i].color,"%d - %s",finalscore,players[i].name);
	}
	
	masked_stretch_blit(text,background,0,0,220,130,210,190,390,250);

	blit(background,screen,0,0,0,0,SCREEN_W,SCREEN_H);

	clear_keybuf();
	readkey();

	destroy_bitmap(text);

}
Exemple #3
0
void CGame::DrawPlayer() {
	
	// draw players name and tile rack and temp tile rack
	// and buttons to do stuff
	// all color coded
	
	int i; //used to calculate rack position offset when drawing sprite
	CObject *object; //object pointer
	POSITION pos; //CObList position
	CTile *tile; //tile pointer

	//boarder around board
	rect(background,0,0,570,570,players[currplayer].color);
	
	//player hud
	rect(background,570,101,SCREEN_W-1,SCREEN_H-1,players[currplayer].color);
	
	//player name ("rub out" old one. cheap and nasty style)
	textout_centre(background,font,"Current player is:",685,105,players[currplayer].color);
	textout(background,font,".                          .",571,125,players[currplayer].color);
	textprintf_centre(background,font,685,125,players[currplayer].color,"%s",players[currplayer].name);
	
	//rack 1
	rectfill(background,580,150,790,180,players[currplayer].color);
	//rack2
	rectfill(background,580,210,790,240,players[currplayer].color);

	// render rack1 tiles
	i = 1;
	if (!players[currplayer].rack.IsEmpty()) {
		for( pos = players[currplayer].rack.GetHeadPosition(); pos != NULL; i++) {	

			object = players[currplayer].rack.GetNext(pos);
			tile = (CTile *)object;

			draw_sprite(background, smalltiles[tile->GetIndex()], (551+(i*30)),151);
		}
	}

	//render rack2 tiles
	i = 1;
	if (!players[currplayer].tmprack.IsEmpty()) {
		for( pos = players[currplayer].tmprack.GetHeadPosition(); pos != NULL; i++) {	
		
			object = players[currplayer].tmprack.GetNext(pos);
			tile = (CTile *)object;
		
			draw_sprite(background, smalltiles[tile->GetIndex()], (551+(i*30)),211);
		}

	}

	//draw buttons + spam banner :)
	draw_sprite(background, (WINDOWS_BITMAP *)data[ZRESET_BMP].dat, 580,260);
	draw_sprite(background, (WINDOWS_BITMAP *)data[ZSWAP_BMP].dat, 690,260);
	draw_sprite(background, (WINDOWS_BITMAP *)data[ZSPAM_BMP].dat, 571,310);	
	draw_sprite(background, (WINDOWS_BITMAP *)data[ZDONE_BMP].dat, 635,530);

}
Exemple #4
0
void
zmg(int i,int j)
{
	//play_sample(hit,255,255-(j/SIRINA*255),1000,0);
	textprintf_centre(screen,font,SREDINA,VISINA/3,15,
			"Player %d wins!",i);
	end_game=1;
}
Exemple #5
0
void 
menu()
{
	int a=0;
	char s[50],version[]="1.0.8";

	
	//play_sample(themes,255,128,1000,1);
	while(1) {
		textprintf_centre(screen,font,SREDINA,VISINA/3,15,
			"  TANKS! v%s",version);
		if(a==0) {
			textprintf_centre(screen,font,SREDINA,VISINA/3+15,
					15,"->Start game",version);
			textprintf_centre(screen,font,SREDINA,VISINA/3+30,
					15,"  Exit",version);
		}
		else {
			textprintf_centre(screen,font,SREDINA,VISINA/3+15,
					15,"  Start game",version);
			textprintf_centre(screen,font,SREDINA,VISINA/3+30,
					15,"->Exit",version);
		}
		if(key[KEY_ESC])
			exit(1);
		if(key[KEY_ENTER]) {
			if(a==0) 
				break;
			else
				exit(1);
		}
		if(key[KEY_UP]||key[KEY_DOWN]) {
			a=!a;
			rest(100);
		}			

	}
	//stop_sample(themes);
	rest(200);
	clear(screen);
	narisi();
}					
void save_animation()
{
    char name[256];
    int i;

    clear(screen);

    for (i=0; i<frame; i++) {
        sprintf(name, "%s%03d.tga", out_file, i);
        strlwr(name);

        textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2, makecol(128, 128, 128), "Writing %s...", name);

        if (save_bitmap(name, bmp[i], pal) != 0) {
            set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
            allegro_message("Error writing '%s'\n", name);
            return;
        }
    }
}
Exemple #7
0
unsigned char information_box(const char *text1, const char *text2, const char *text3, char waiting)
{

    unsigned char read_k = 0;

    switch(video_mode)
    {
    case 0: // 320x200
        rectfill(screen, 50, 80, 270, 140, 0);
        rect(screen, 50, 80, 270, 140, 5);

        textprintf_centre(screen, large_font, 160, 90, 15, text1);
        textprintf_centre(screen, large_font, 160, 105, 15, text2);
        textprintf_centre(screen, large_font, 160, 120, 15, text3);
        break;
    default:
        rectfill(screen, 140, 170, 500, 300, 0);
        rect(screen, 140, 170, 500, 300, 5);

        textprintf_centre(screen, large_font, 320, 200, 15, text1);
        textprintf_centre(screen, large_font, 320, 230, 15, text2);
        textprintf_centre(screen, large_font, 320, 260, 15, text3);
        break;
    }

    if (waiting)
    {
        rest(500);
        switch(video_mode)
        {
        case 0: // 320x200
            rect(screen, 50, 80, 270, 140, 180);
            break;
        default:
            rect(screen, 140, 170, 500, 300, 180);
            break;
        }
        while(!keypressed())
        {
        }
        read_k = readkey();
    }

    return read_k;

}
int main(int argc, char *argv[])
{
    int ret = 0;
    int i;

    allegro_init();
    install_keyboard();
    install_mouse();
    install_timer();

    srand(time(NULL));

    for (i=1; i<argc; i++) {

        if (stricmp(argv[i], "-bpp") == 0) {
            if ((i >= argc-1) || (bpp > 0)) {
                usage();
                return 1;
            }

            bpp = atoi(argv[++i]);
        }
        else if (stricmp(argv[i], "-frames") == 0) {
            if ((i >= argc-1) || (frames > 0)) {
                usage();
                return 1;
            }

            frames = atoi(argv[++i]);
        }
        else if (stricmp(argv[i], "-size") == 0) {
            if ((i >= argc-2) || (size_x > 0) || (size_y > 0)) {
                usage();
                return 1;
            }

            size_x = atoi(argv[++i]);
            size_y = atoi(argv[++i]);
        }
        else if (stricmp(argv[i], "-mode") == 0) {
            if ((i >= argc-2) || (mode_x > 0) || (mode_y > 0)) {
                usage();
                return 1;
            }

            mode_x = atoi(argv[++i]);
            mode_y = atoi(argv[++i]);
        }
        else if (stricmp(argv[i], "-step") == 0) {
            step = TRUE;
        }
        else if (stricmp(argv[i], "-modesel") == 0) {
            modesel = TRUE;
        }
        else if (stricmp(argv[i], "-pregen") == 0) {
            pregen = TRUE;
        }
        else if (stricmp(argv[i], "-o") == 0) {
            if ((i >= argc-1) || (out_file)) {
                usage();
                return 1;
            }

            out_file = argv[++i];
        }
        else if (stricmp(argv[i], "-pal") == 0) {
            if ((i >= argc-1) || (pal_file)) {
                usage();
                return 1;
            }

            pal_file = argv[++i];
        }
        else {
            if ((*argv[i] == '-') || (in_file)) {
                usage();
                return 1;
            }

            in_file = argv[i];
        }
    }

    if (!in_file) {
        usage();
        return 1;
    }

    if ((pregen) && ((frames <= 0) || (step))) {
        allegro_message("The '-pregen' option requires '-frames num' to be specified,\nand cannot be used at the same time as '-step'\n");
        return 1;
    }

    if (!set_video_mode()) {
        ret = 1;
        goto getout;
    }

    the_egg = load_egg(in_file, error);

    if (!the_egg) {
        set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
        allegro_message("%s", error);
        return 1;
    }

    if (size_x <= 0)
        size_x = 128;

    if (size_y <= 0)
        size_y = 128;

    if (pal_file) {
        BITMAP *tmp = load_bitmap(pal_file, pal);

        if (!tmp) {
            set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
            allegro_message("Error reading palette from '%s'\n", pal_file);
            ret = 1;
            goto getout;
        }

        destroy_bitmap(tmp);
    }
    else
        generate_332_palette(pal);

    clear(screen);

    set_palette(pal);

    text_mode(0);

    do {
        if (pregen) {
            textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2-24, makecol(128, 128, 128), "Rendering frame %d/%d", the_egg->frame+1, frames);
            textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2+24, makecol(128, 128, 128), "Please Wait");
        }

        if (update_egg(the_egg, error) != 0) {
            allegro_exit();
            printf("Error running EGG script:\n%s\n\n", error);
            ret = 1;
            goto getout;
        }

        bmp[frame] = create_bitmap(size_x, size_y);

        lay_egg(the_egg, bmp[frame]);

        if (!pregen) {
            vsync();
            blit(bmp[frame], screen, 0, 0, (SCREEN_W-size_x)/2, (SCREEN_H-size_y)/2, size_x, size_y);
            textprintf(screen, font, 0, 0, makecol(128, 128, 128), "Frame %d, %d particles        ", the_egg->frame, the_egg->part_count);
        }

        if ((!pregen) && (!out_file)) {
            destroy_bitmap(bmp[frame]);
            bmp[frame] = NULL;
        }

        frame++;

        if ((step) || (keypressed())) {
            if ((readkey()&0xFF) == 27)
                break;

            clear_keybuf();
        }

    } while (((frames <= 0) || (frame < frames)) && (frame < 4096));

    if (pregen)
        view_animation();

    if (out_file)
        save_animation();

getout:

    if (the_egg)
        destroy_egg(the_egg);

    for (i=0; i<frame; i++)
        if (bmp[frame])
            destroy_bitmap(bmp[frame]);

    return ret;
}
Exemple #9
0
void main()
{
    allegro_init();
    install_keyboard();
    install_mouse();
    install_timer();
    set_color_depth(32);
    set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
    srand(time(NULL)+clock());
    text_mode(-1);

    buffer = create_bitmap(WIDTH, HEIGHT);

    textprintf_centre(screen, font, 320, 200, WHITE, "-Endless Tower-");

    textprintf_centre(screen, font, 320, 240, WHITE, "press enter to start");

    while (!key[KEY_ENTER])
    {}

    for(int i = 0; i < 13; i++)
    {
        land[i].y = rand() % HEIGHT;
        land[i].x = ((rand()%300)*2) + 20;
        land[i].w = (rand()%20) + 20;
    }
    land[13].y = y + 10;
    land[13].x = x;
    land[13].w = 45;

    rest(50);

    while (!key[KEY_ESC])
    {
        start_time = clock();

        /*game goes here*/
        //move left
        if (key[KEY_LEFT])
                x -= 10;

        //move right
        if (key[KEY_RIGHT])
                x += 10;

        //jump
        if ((!jump)&&(key[KEY_SPACE]))
        {
                jump = true;
                jumpforce = 60;
        }

        if ((jump)&&(key[KEY_SPACE]))
        {
                jumpforce += 1;
        }

        //speed up!
        speed = 3 + (game_time/20000);

        //fall
        if (jump)
        {
                jumpforce -= 3;
        }
        if (!jump)
                jumpforce = -12;
        y -= jumpforce/4;

        //drop platforms down
        add_platform();
        for (int i = 0; i < 14; i++)
        {
                land[i].y += speed;
        }

        //collision
        on_land = 0;
        for (int i = 0; i < 14; i++)
        {
                if ((y > land[i].y - 20)&&(y < land[i].y))
                {
                                if ((x < land[i].x + land[i].w)&&(x > land[i].x - land[i].w))
                                {
                                        if (jumpforce < 5)
                                        {
                                                jump = false;
                                        }
                                        jumpforce = -speed*3;
                                        on_land += 1;
                                }
                }
        }
        if (on_land == 0)
                jump = true;
        //warp
        if (x < 0)
            x = 0;
        if (x > WIDTH)
            x = WIDTH;

        //die
        if (y > HEIGHT)
            return;

        /*drawing goes here*/
        rectfill(buffer, 0, 0, WIDTH, HEIGHT, BLACK);
        circlefill(buffer, x, y, 10, WHITE);
        textprintf(buffer, font, 320, 20, WHITE, "%i'%i", game_time/60000, (game_time/1000)%60);

        for (int i = 0; i < 14; i++)
        {
                hline(buffer, land[i].x - land[i].w, land[i].y, land[i].x + land[i].w, WHITE);
        }

        blit(buffer, screen, 0, 0, 0, 0, WIDTH, HEIGHT);

        game_time += 20;
        while (clock() < start_time + 20)
        {}
    }
    destroy_bitmap(buffer);
    return;
}
/////////////////////////////////////
//// MAIN ///////////////////////////
/////////////////////////////////////
int main(int argc, char *argv[])
{
 
/////////////////////////////////////
// START GUI SPECIFIC CODE //////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////
	int bpp; // color depth 
	int ret; // for processing return values
	
	//initialise allegro stuff
	allegro_init(); 
	install_keyboard(); 
	install_timer();

	bpp = desktop_color_depth();
	set_color_depth(bpp);
	
	/* Lets play the color depth game!  tries 32, 24, then 16 bit color modes */
	// set resolution to play intro movie
	ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	/* did the video mode set properly? */
	if (ret != 0) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Error setting %d bit graphics mode\n%s\nLets try another color depth!", bpp, allegro_error);
		
		bpp = 32;
		set_color_depth(bpp);
		
		// set resolution
		ret = set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
		/* did the video mode set properly? */
		if (ret != 0) {
			set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
			allegro_message("Error setting %d bit graphics mode\n%s\nLets try another color depth!", bpp, allegro_error);

			bpp = 16;
			set_color_depth(bpp);

			// set resolution
			ret = set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
			/* did the video mode set properly? */
			if (ret != 0) {
				set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
				allegro_message("Error setting %d bit graphics mode\n%s\nIm all out of options. Exiting", bpp, allegro_error);
				return 1;
			}
		}
	}
	
///////////////////////////
// END OF GUI SPECIFIC //////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////

//////////////////////////
///// VARIABLES //////////
//////////////////////////

	CEdge edgelist; //the edges
	int besttour = MAX_DISTANCE*NUM_TOWNS; //best result ever
	int currtour = MAX_DISTANCE*NUM_TOWNS; //best result from last tour
	int bestant = -1; //stores ant that did really well and adds more phero to its trail
	CAnt colony[NUM_ANTS]; //the ants

	int i,j; //universal for loop counters
	
	int cycles=0;
	
	srand(time(NULL));		 //seed random number
	int limit;				//universal random number limit.. (rand()%limit will give a number between 0 and limit-1)

	// Start Cycling
	while (!key[KEY_ESC] && cycles < MAX_CYCLES) {
		
		textprintf(screen,font,5,5,makecol(255,0,0),"Press Esc to hault processing [Cycle %d]",cycles);
		
		//initialise the ants before they all do a tour	
		//sets each ants first town to somewhere random
		
		limit = NUM_TOWNS;
		for (i=0;i<NUM_ANTS;i++) {			
			//colony[i].SetTown(0,i); //set each ants first tour element to a town 
			colony[i].SetTown(0,rand()%limit); //random version
		}	
		
		
		//each time though loop add another node to each ants tour list 
		//starting at the 2nd node (the 1st node is already set)
		limit = NUM_TOWNS+1;				
		double distance;
		double pheromone;	
		double probability;
		double total;
		double p[NUM_TOWNS];

		for (int tourcount=1;tourcount<NUM_TOWNS;tourcount++) {
			
			for (i=0;i<NUM_ANTS;i++) { //for each ant.. add 1 more tour
				
				//reset probabilities
				probability=0;
				total=0;
				
				//calculate best probability from all possible new paths
				
				//loop through all remaining possible tours left on the current ant
				//each time through the loop calc probability and keep track of best
				int k;
				for (j=tourcount,k=0;j<NUM_TOWNS;j++,k++) {
					
					//get variables used to calc probability
					distance = edgelist.GetDistance(colony[i].GetTown(tourcount-1), colony[i].GetTown(j));
					pheromone = edgelist.GetPhero(colony[i].GetTown(tourcount-1), colony[i].GetTown(j));
					
					probability = pow(pheromone, ALPHA);
					probability = probability * pow(distance, -BETA);
					
					p[k] = probability;
					total += probability;
					
				}
				
				//choose new town based on probability
				int best = 0;
				for (j=0;j<k;j++) {
					
					if ((p[best]/total)  > (p[j]/total)) {
						//new best
						best = j; 
					}
					
				}
				
				//move current ant to new town
				colony[i].SetTown(tourcount, colony[i].GetTown(tourcount+best));
				
			}//for ant
		}
		

		//////////////////////////////////////
		//ants now have full tour lists
		//compute length of each ants list
		//////////////////////////////////////
		for (i=0;i<NUM_ANTS;i++) { //for each ant
			
			int distance = 0;
			
			//reset currtour
			currtour = MAX_DISTANCE*NUM_TOWNS;
			
			printf("\nant %d [%d",i,colony[i].GetTown(0));//display ants tour in console window
			
			for (int j=1;j<NUM_TOWNS;j++) { //for each edge in the ants tour
				
				printf(",%d",colony[i].GetTown(j));//display ants tour in console window
				distance += edgelist.GetDistance(colony[i].GetTown(j-1), colony[i].GetTown(j));
				
			}
			
			printf("]");//display ants tour in console window
			
			//add on loopback distance
			distance += edgelist.GetDistance(colony[i].GetTown(NUM_TOWNS-1), colony[i].GetTown(0));
			
			printf("=%d",distance);//display ants tour distance in console window

			//keep record of best tours
			if (distance < besttour) {
				besttour = distance;
				bestant = i; //we only add extra phero to a tour when a best tour "record" is broken
			}
			if (distance < currtour)
				currtour = distance;

			//store distance on ant
			colony[i].SetDistance(distance);
		}

		
		/////////////////////////
		//evaporate pheromones
		/////////////////////////
		edgelist.Evaporate(EVAP);


		//////////////////////////////////////////////////
		//lay new pheromones based on colony[i].distance
		//////////////////////////////////////////////////
		for (i=0;i<NUM_ANTS;i++) {
			
			double phero;
			
			for (int j=1;j<NUM_TOWNS;j++) { //for each edge in the ants tour
				
				phero = edgelist.GetPhero(colony[i].GetTown(j-1), colony[i].GetTown(j)); //get old phero
				phero = phero + QUE / colony[i].GetDistance(); //calc new phero
				
				//reinforce best path
				if (bestant != -1 && i == bestant) {
					phero += ADD_PHERO;
				}

				edgelist.SetPhero(colony[i].GetTown(j-1), colony[i].GetTown(j), phero);
			}
			
			//loop back 
			phero = edgelist.GetPhero(colony[i].GetTown(NUM_TOWNS-1), colony[i].GetTown(0)); //get old phero
			phero = phero + QUE / colony[i].GetDistance(); //calc new phero
			
			//reinforce best path
			if (bestant != -1 && i == bestant) {
				phero += ADD_PHERO;
				bestant = -1;
			}

			edgelist.SetPhero(colony[i].GetTown(NUM_TOWNS-1), colony[i].GetTown(0), phero); //set phero
		}

		
		/////////////////////////////
		//reset ants and do it again
		/////////////////////////////
		for (i=0;i<NUM_ANTS;i++) {
			
			colony[i].ResetAnt();
			
		}
				
		//cycle done
		
		cycles ++;
		Draw(cycles, currtour, besttour);

	}

	clear_keybuf();
	textprintf_centre(screen,font,SCREEN_W/2,SCREEN_H/2-60,makecol(255,0,0),"Best Tour = %d",besttour);
	textout_centre(screen,font,"Press a key to exit",SCREEN_W/2,SCREEN_H/2-40,makecol(255,0,0));
	readkey();

	return 0;
}
Exemple #11
0
/*
returns 1 if player 1 wins (for challenge game)
*/
int score_table(void)
{

// int num_users = 0;
 int li = 0;
 int ui = 0;
 int ranked = 0;
 char found_rank = 0;
 int rank [NO_USERS];
 int ranknum [NO_USERS];
 int done_user [NO_USERS];
 int highest_score = 1000;
// int done_score = 0;

 char rank_text [40];
 char ittext [10];

 textprintf_centre(screen, large_font, 160, text_size, 1, "Game Over");
 textprintf_centre(screen, large_font, 160, text_size * 2, 1, "Ranking");


 if (game[0].game_type == GAME_LAST_ONE)
 {
  for (ui = 0; ui < NO_USERS; ui ++)
  {
   if (user[ui].ranked == 0) user[ui].ranked = 100;
  }
 }
 // if a game of last-one-standing is aborted, survivors should all be
 //  ranked 1.

 do
 {
//  if (user[li].active == 1)
//  num_users ++;
  rank [li] = -1;
  ranknum [li] = li;
  done_user [li] = 0;
  li ++;
 } while (li < NO_USERS);

 li = 0;

 do
 {
 ui = 0;

 do
 {

  if (user[ui].active == 0)
  {
   ui ++;
   continue;
  }


  switch(game[0].game_type)
  {
   default:
   case GAME_KILL:
    if (user[ui].score >= highest_score && done_user [ui] == 0)
    {
     rank [li] = ui;
     ranknum [li] = ranked;
     li ++;
     done_user [ui] = 1;
     found_rank = 1;
    }
   break;
   case GAME_LAST_ONE:
    if (user[ui].ranked >= highest_score && done_user [ui] == 0)
    {
     rank [li] = ui;
     ranknum [li] = ranked;
     li ++;
     done_user [ui] = 1;
     found_rank = 1;
    }
   break;
  }

  
  ui ++;
 } while (ui < NO_USERS);
 highest_score --;
 if (found_rank == 1)
  ranked ++;
 found_rank = 0;

 } while (highest_score > -5);

 li = 0;

 do
 {
  if (rank [li] == -1)
  {
   li ++;
   continue;
  }
  
//  strcpy(rank_text, itoa(li + 1, ittext, 10));
  strcpy(rank_text, itoa(ranknum [li] + 1, ittext, 10));
  strcat(rank_text, ". ");
  strcat(rank_text, user[rank [li]].uname);
  strcat(rank_text, " - Score ");
  strcat(rank_text, itoa(user[rank [li]].score, ittext, 10));
  if (game[0].lives_each > 0)
  {
   if (user [rank [li]].out_of_lives == 1)
    strcat(rank_text, " - Eliminated");
     else
      {
       strcat(rank_text, " - Lives ");
       strcat(rank_text, itoa(user[rank [li]].lives, ittext, 10));
      }
  }
  
  textprintf_centre(screen, large_font, 160, ((li + 3) * text_size), COLOUR_YELLOW4, rank_text);
  li ++;
 } while (li < NO_USERS);

 if (rank [0] == player[1].user
     && user[player[1].user].score >= game[0].score_limit)
  return 1;

 return 0;


}
Exemple #12
0
/*
returns 1 if player 1's team wins (for challenge game)
*/
int score_table_team(void)
{

// int num_users = 0;
 int li = 0;
 int ui = 0;
 int ranked = 0;
 char found_rank = 0;
 int rank [NO_TEAMS];
 int ranknum [NO_TEAMS];
 int done_team [NO_TEAMS];
 int highest_score = 1000;
// int done_score = 0;

 char rank_text [40];
 char ittext [10];

 textprintf_centre(screen, large_font, 160, text_size, 1, "Game Over");
 textprintf_centre(screen, large_font, 160, text_size * 2, 1, "Team Ranking");

 if (game[0].game_type == GAME_LAST_ONE)
 {
  for (ui = 0; ui < NO_TEAMS; ui ++)
  {
   if (team[ui].ranked == 0) team[ui].ranked = 100;
  }
 }
 // if a game of last-one-standing is aborted, survivors should all be
 //  ranked 1.

 do
 {
//  if (user[li].active == 1)
//  num_users ++;
  rank [li] = -1;
  ranknum [li] = li;
  done_team [li] = 0;
  li ++;
 } while (li < NO_TEAMS);

 li = 0;

 do
 {
 ui = 0;

 do
 {

  if (team[ui].active == 0)
  {
   ui ++;
   continue;
  }


  switch(game[0].game_type)
  {
   default: // most games are scored on points
   case GAME_KILL:
    if (team[ui].score >= highest_score && done_team [ui] == 0)
    {
     rank [li] = ui;
     ranknum [li] = ranked;
     li ++;
     done_team [ui] = 1;
     found_rank = 1;
    }
   break;
   case GAME_LAST_ONE:
    if (team[ui].ranked >= highest_score && done_team [ui] == 0)
    {
     rank [li] = ui;
     ranknum [li] = ranked;
     li ++;
     done_team [ui] = 1;
     found_rank = 1;
    }
   break;
  }

  
  ui ++;
 } while (ui < NO_TEAMS);
 highest_score --;
 if (found_rank == 1)
  ranked ++;
 found_rank = 0;

 } while (highest_score > -5);

 li = 0;

 do
 {
  if (rank [li] == -1)
  {
   li ++;
   continue;
  }
  
//  strcpy(rank_text, itoa(li + 1, ittext, 10));
  strcpy(rank_text, itoa(ranknum [li] + 1, ittext, 10));
  strcat(rank_text, ". ");

  switch(rank [li])
  {
   case TEAM_RED: strcat(rank_text, "Red Team"); break;
   case TEAM_BLUE: strcat(rank_text, "Blue Team"); break;
   case TEAM_GREEN: strcat(rank_text, "Green Team"); break;
   case TEAM_GREY: strcat(rank_text, "Grey Team"); break;
   case TEAM_GOLD: strcat(rank_text, "Gold Team"); break;
   case TEAM_BROWN: strcat(rank_text, "Brown Team"); break;
  }
  strcat(rank_text, " - Score ");
  strcat(rank_text, itoa(team[rank [li]].score, ittext, 10));
//  if (game[0].lives_each > 0)
//  {
   if (team [rank [li]].size == 0)
    strcat(rank_text, " - Eliminated");
//     else
//      {
//       strcat(rank_text, " - Lives ");
//       strcat(rank_text, itoa(team[rank [li]].lives, ittext, 10));
//      }
//  }
  
  textprintf_centre(screen, large_font, 160, ((li + 3) * text_size), team_colours(rank [li]), rank_text);
  li ++;
 } while (li < NO_TEAMS);

 if (rank [0] == player[1].team
     && team[player[1].team].score >= game[0].score_limit)
  return 1;

 return 0;

}