示例#1
0
void cryoprison_effect_deff (void) {
	dmd_alloc_pair_clean();

	for (;;) {
		dmd_draw_thin_border (dmd_low_buffer);

		font_render_string_center (&font_steel, DMD_MIDDLE_X, DMD_BIG_CY_Top - 2, "CRYOPRISON");

		sprintf_score(current_score);
		font_render_string_center (&font_var5, DMD_MIDDLE_X, DMD_SMALL_CY_3 - 2, sprintf_buffer);

		if (CRYO_TOGGLE == 0) 		{ sprintf ("15 MILLION"); font_render_string_center (&font_steel, DMD_MIDDLE_X, DMD_BIG_CY_Bot - 2, sprintf_buffer); }
		else if (CRYO_TOGGLE == 1)	{ sprintf ("JACKPOT LIT"); font_render_string_center (&font_steel, DMD_MIDDLE_X, DMD_BIG_CY_Bot - 2, sprintf_buffer); }
		else if (CRYO_TOGGLE == 2)	{sprintf ("%d JACKPOTS", cryoprison_jackpot_shots_made); font_render_string_center (&font_steel, DMD_MIDDLE_X, DMD_BIG_CY_Bot - 2, sprintf_buffer); }
		else if (CRYO_TOGGLE == 3)	{ if (flag_test(FLAG_IS_SUPER_JACKPOT_ACTIVATED) )	sprintf ("SUPER LIT");
									else 											sprintf ("%d FOR SUPER", 5 - (cryoprison_jackpot_shots_made % 5) );
									font_render_string_center (&font_steel, DMD_MIDDLE_X,  DMD_BIG_CY_Bot - 2, sprintf_buffer); }

		show_snake(snake_pos);  // takes approx 1.5 seconds

		if (snake_pos < 7) snake_pos ++;
		else snake_pos = 0;

		if (++cryoprison_display_counter % 7 == 0) { if (++CRYO_TOGGLE > 3) CRYO_TOGGLE = 0; } //change CRYO_TOGGLE once per second
	}//END OF ENDLESS LOOP
}//end of function
示例#2
0
void design_cp2()
{
	cp=2;
	srand((unsigned)time(NULL));
	food.flag=1;
	mine.flag=1;
	direct=4;
	score=0;
	poigrass.cor[0].x=240;
	poigrass.cor[0].y=40;
	poigrass.cor[1].x=340;
	poigrass.cor[1].y=180;
	poigrass.cor[2].x=240;
    poigrass.cor[2].y=500;
	poigrass.cor[3].x=60;
	poigrass.cor[3].y=240;
	poigrass.cor[4].x=500;
	poigrass.cor[4].y=300;
    p0=(struct Snake*)malloc(LEN);
	head=(struct Snake*)malloc(LEN);
	tail=(struct Snake*)malloc(LEN);
	p1=(struct Snake*)malloc(LEN);
	head->x=2*20;
	head->y=5*20;
	tail->x=20;
	tail->y=5*20;
	p0=tail;
	map();
	tail->x=head->x-20;
	tail->y=head->y;
	head->next=tail;
	head->previous=NULL;
	tail->next=NULL;
	tail->previous=head;
	tim1=(unsigned)time(NULL);
    while(1)
	{
		while(!kbhit())
		{
		  set_poigrass();
		  set_poigrass1();
		  if(food.flag==1)
              set_food();
		  if(mine.flag==1)
	          set_mine();
		  show_food();
	      show_mine();
          snake_move();
		  ju_eat_food();
		  if(node==16)
		  {
			  initgraph(500,400);
			  setbkcolor(GREEN);
              cleardevice();
			  setcolor(RED);
			  setfont(40,0,"华文行楷");
			  outtextxy(70,160,"恭喜你,进入下一关!");
			  Sleep(3000);
			  design_cp3();
		  }
		  ju_meet_mine();
		  ju_eat_poigrass();
          while(p0->next!=NULL)
		  {
	         if((p0->next->x==head->x)&&(p0->next->y==head->y))
		        life=0;
	    	p0=p0->next; 
		  }
		  if(life==0)
			  gameover();
          if(head->x>=680)
		  {  
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x-20,tail->y,tail->x,tail->y+20);
		      gameover();
		  }
		  if(head->x<20)
		  {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x+20,tail->y,tail->x+40,tail->y+20);
		      gameover();
          }
		  if(head->y>=580)
		  {  
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x,tail->y-20,tail->x+20,tail->y);
		      gameover();
		  }
		  if(head->y<20)
		  {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x,tail->y+20,tail->x+20,tail->y+40);
		      gameover();
		  }
		  if(direct==4)
		     if(head->x==200&&(head->y>=160&&head->y<=380)||head->x==420&&(head->y>=280&&head->y<=420))
			 {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x-20,tail->y,tail->x,tail->y+20);
		      gameover();
			 }
		  if(direct==3)
		     if(head->x==200&&(head->y>=160&&head->y<=380)||head->x==420&&(head->y>=280&&head->y<=420))
			 {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x+20,tail->y,tail->x+40,tail->y+20);
		      gameover();
			 }
		  if(direct==1)
		     if(head->x==200&&head->y==380||head->x==420&&head->y==420)
			 {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x,tail->y+20,tail->x+20,tail->y+40);
		      gameover();
			 }
			 if(direct==2)
		     if(head->x==200&&head->y==160||head->x==420&&head->y==280)
			 {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x,tail->y-20,tail->x+20,tail->y);
		      gameover();
			 }
		  show_snake();
		  tim2=(unsigned)time(NULL);
		  if(tim2-tim1>=50)
			  no_poigrass();
		}
		change();
	}
}
示例#3
0
void design_cp3()
{
	cp=3;
	srand((unsigned)time(NULL));
	food.flag=1;
	mine.flag=1;
	direct=4;
	poigrass.cor[0].x=240;
	poigrass.cor[0].y=40;
	poigrass.cor[1].x=340;
	poigrass.cor[1].y=180;
	poigrass.cor[2].x=240;
    poigrass.cor[2].y=500;
	poigrass.cor[3].x=60;
	poigrass.cor[3].y=240;
	poigrass.cor[4].x=500;
	poigrass.cor[4].y=300;
	poigrass.cor[5].x=600;
	poigrass.cor[5].y=120;
	poigrass.cor[6].x=520;
	poigrass.cor[6].y=540;
    p0=(struct Snake*)malloc(LEN);
	head=(struct Snake*)malloc(LEN);
	tail=(struct Snake*)malloc(LEN);
	p1=(struct Snake*)malloc(LEN);
	head->x=2*20;
	head->y=5*20;
	tail->x=20;
	tail->y=5*20;
	p0=tail;
	map();
	tail->x=head->x-20;
	tail->y=head->y;
	head->next=tail;
	head->previous=NULL;
	tail->next=NULL;
	tail->previous=head;
	tim1=(unsigned)time(NULL);
    while(1)
	{
		while(!kbhit())
		{
		  set_poigrass();
		  set_poigrass1();
		  if(food.flag==1)
              set_food();
		  if(mine.flag==1)
	          set_mine();
		  show_food();
	      show_mine();
          snake_move();
		  ju_eat_food();
		  ju_meet_mine();
		  ju_eat_poigrass();
          while(p0->next!=NULL)
		  {
	         if((p0->next->x==head->x)&&(p0->next->y==head->y))
		        life=0;
	    	p0=p0->next; 
		  }
		  if(life==0)
			  gameover();
          if(head->x>=680)
		  {  
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x-20,tail->y,tail->x,tail->y+20);
		      gameover();
		  }
		  if(head->x<20)
		  {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x+20,tail->y,tail->x+40,tail->y+20);
		      gameover();
          }
		  if(head->y>=580)
		  {  
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x,tail->y-20,tail->x+20,tail->y);
		       gameover();
		  }
		  if(head->y<20)
		  {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x,tail->y+20,tail->x+20,tail->y+40);
		      gameover();
		  }
		  if(direct==4)
		     if(head->x==200&&(head->y>=160&&head->y<=380)||head->x==420&&(head->y>=280&&head->y<=420)||
				 head->y==200&&head->x==300)
			 {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x-20,tail->y,tail->x,tail->y+20);
		      gameover();
			 }
		  if(direct==3)
		     if(head->x==200&&(head->y>=160&&head->y<=380)||head->x==420&&(head->y>=280&&head->y<=420)||
				 head->y==200&&head->x==580)
			 {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x+20,tail->y,tail->x+40,tail->y+20);
		      gameover();
			 }
		  if(direct==1)
		     if(head->x==200&&head->y==380||head->x==420&&head->y==420||
				 head->y==200&&(head->x>=300&&head->x<=580))
			 {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x,tail->y+20,tail->x+20,tail->y+40);
		      gameover();
			 }
			 if(direct==2)
		     if(head->x==200&&head->y==160||head->x==420&&head->y==280||
				 head->y==200&&(head->x>=300&&head->x<=580))
			 {
              setfillcolor(YELLOW);
	          setcolor(YELLOW);
	          bar(tail->x,tail->y-20,tail->x+20,tail->y);
		      gameover();
			  tim2=(unsigned)time(NULL);
		      if(tim2-tim1>=80)
			      no_poigrass();
			 }
		  show_snake();
		}
		change();
	}
}