示例#1
0
void render_loop() {
    int base,top,state;
    //draw them backgrounds!
    switch(levl->bgtype) {
    default:
    case 0:
        clear_bitmap(buffer); //black backgrund, not that useful
        break;
    case 1:
        render_sky(levl->lines); //sky-thingy
        break;
    case 2:
        show_fire(); //A fire...
        break;
    }
    render_level_map(levl,xorg,yorg);
    for (int ei=levl->entitycnt-1;ei>=0;ei--) {
        ENTITY *e = levl->entities+ei;
        switch (e->type) {
        default:
            printf("Unknown entity type in render loop! type: %d id: %d",e->type,ei);
        case ENTITY_TYPE_NULL:
            break;
        case ENTITY_TYPE_PLAYER:
            xorg = e->x-368/64.0 <=0 ? 0 : e->x+432/64.0 > levl->sizex ? levl->sizex-800/64.0 : e->x-368/64.0;
            yorg = e->y-268/64.0 <=0 ? 0 : e->y+332/64.0 > levl->sizey ? levl->sizey-600/64.0 : e->y-268/64.0;
            state = (e->data1&0x0300)>>16;
            top = 0;
            if (e->accely < 0) top = 1;
            if (e->accely > 0) top = 2;
            if (e->accely == 1/8.0) top = 5;
            if (e->accelx < 0) top = 3;
            if (e->accelx > 0) top = 4;
            if (e->health <= 0) top = 7;
            
            base = 0;
            render_player((e->x-xorg)*64,(e->y-yorg)*64,base,top);
            render_health(10,10,256,32,e->health,1024);
            textprintf_ex(buffer,font,0,0,getpixel(buffer,0,0)^0xFFFF,-1,"P: %d",e->data3);
            //stretch_blit(collectable_c[2],buffer,0,0,64,64,800-16,0,16,16);
            textprintf_right_ex(buffer,font,799,0,getpixel(buffer,799,0)^0xFFFF,-1,"%d",e->data4);
            break;
        case ENTITY_TYPE_COLLECTABLE:
            //printf("%X, %X, %X, %X ?? %X %X\n",e->data2,e->data2&0xFF00,e->data2&0xFF00 == 0x0100,0x0100,e->data2&0xFF00 > 0x0100,e->data2&0xFF00 < 0x0100);
            if ((e->data2&0xFF00) == 0x0100) {
                draw_rle_sprite(buffer,collectable_c[e->data2&0x0007],(e->x-xorg)*64,(e->y-yorg)*64);
                //draw_rle_sprite(buffer,collectable_c[e->data2&0x0007],0, 0);
            }
            break;
        }
    }
}
示例#2
0
文件: render.c 项目: mtmiron/lich
void
render_info(BITMAP *bmp)
{
	char buf[256];

	scare_mouse();

	rectfill(bmp, 0, bmp->h - 16, bmp->w/2, bmp->h, bgc);
	rectfill(bmp, bmp->w/3, 0, (int)bmp->w*.66, 10, bgc);

	if (selected_node)
	{
		snprintf(buf, sizeof(buf), "%s: %s (ID: %d   coord: %d,%d)",
		         (selected_node->area?selected_node->area:"(unknown area)"),
		         (selected_node->title?selected_node->title:"(unknown title)"),
		         selected_node->id, selected_node->x, selected_node->y);

		textprintf_centre_ex(bmp, font, bmp->w/2, 2, 0, -1, "%s",
		                     buf);
		hline(bmp, bmp->w/2 - text_length(font, buf)/2, 10,
		      bmp->w/2 + text_length(font, buf)/2, 0);

		highlight_node(selected_node, highlight_color);
	}

	textprintf_ex(bmp, font, 2, (bmp->h - 8) - 2 - text_height(font), 0, -1,
		              "Center: %d,%d", (int)(bmp->w/2.0+xoffset), (int)(bmp->h/2.0+yoffset));
	textprintf_ex(bmp, font, 2, bmp->h - 8, 0, -1,
		              "Mouse: %d,%d", mouse_x+xoffset, mouse_y+yoffset);

	if (last_file)
	{
		snprintf(buf, sizeof(buf), "Most recent file: \"%s\"   (%d nodes total)", last_file, vector_len((vector_t *)nodelist));
		rectfill(bmp, text_length(font, buf), bmp->h - text_height(font), bmp->w, bmp->h, bgc);

		textprintf_right_ex(bmp, font, bmp->w, bmp->h-10, 0, -1, "%s", buf);
	}

	unscare_mouse();
}
示例#3
0
文件: menu.c 项目: evktalo/butterfly
void startup_menu(void)
{


 reset_menu_palette();


 menu_select = 0;
 key_wait = 30;

// int counter;

 menu_counter = 0;
 counter2 = 0;

 arena.difficulty = 0;

 int y1 = 170;
 int y2 = 190 + menu_select * 30;
 int y3 = 218 + menu_select * 30;
 int y4 = 218 + menu_select * 30;

 int anykey = 0;

 int i;

//#define TEST_MUSIC


#ifdef TEST_MUSIC

 arena.level = 3;

 init_beat_new_level();

#endif

 init_menu_circles();

 while (TRUE)
 {


#ifdef TEST_MUSIC
run_beat();

#endif



 clear_to_color(display, COL_BACK1);


 run_menu_background();



 menu_counter += 4;
 if (menu_counter >= 40)
  menu_counter = 0;

 counter2 ++;
 if (counter2 >= 256)
  counter2 = 0;

// textprintf_centre_ex(display, font, 300, 190, -1, -1, "W H I T E   B U T T E R F L Y");
 draw_rle_sprite(display, white_RLE, 150, 150);

 int my = 300;

 y1 = my - 23;
 y2 = my - 10 + menu_select * 30;
 y3 = my + 19 + menu_select * 30;
 y4 = my + 150;


// rectfill(display, 370, y1, 600, y2, COL_COL1);
 TRANS_MODE
 rectfill(display, 370, y2 + 9, 640, y3 - 2, TRANS_BLUE3);
 rect(display, 368, y2 + 7, 641, y3 - 0, TRANS_BLUE3);
 END_TRANS
// rectfill(display, 370, y3, 600, y4, TRANS_DGREEN);


 textprintf_ex(display, font, 400, my, -1, -1, "START GAME");
 switch(arena.difficulty)
 {
      case 0: textprintf_ex(display, font, 400, my + 30, -1, -1, "DIFFICULTY - NORMAL"); break;
      case 1: textprintf_ex(display, font, 400, my + 30, -1, -1, "DIFFICULTY - HARD"); break;
      case 2: textprintf_ex(display, font, 400, my + 30, -1, -1, "DIFFICULTY - PUNISHMENT"); break;
 }
// textprintf_ex(display [2], font, 400, 260, -1, -1, "STAGE - %i", arena.starting_level);
 textprintf_ex(display, font, 400, my + 90, -1, -1, "SET  KEYS");
 textprintf_ex(display, font, 400, my + 120, -1, -1, "OPTIONS");
 textprintf_ex(display, font, 400, my + 150, -1, -1, "EXIT");

// textprintf_ex(display, font, 40, 10, -1, -1, "%i", joy[0].stick[options.joy_stick].axis[0].pos);
// textprintf_ex(display, font, 40, 30, -1, -1, "%i", joy[0].stick[options.joy_stick].axis[1].pos);

/*
 if (options.joystick)
  textprintf_ex(display, font, 400, my + 120, -1, -1, "CALIBRATE JOYSTICK");
   else
   {
    textprintf_ex(display, font, 400, my + 120, -1, -1, "NO JOYSTICK");
    drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
    rectfill(display, 399, my + 110, 530, my + 135, CONVERT_WHITE_TO_GREY);
    drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
   }
*/
 if (options.joystick)
 {
  if (options.key_or_joy == 1)
  textprintf_ex(display, font, 400, my + 60, -1, -1, "CONTROLS - JOYSTICK");
   else
    textprintf_ex(display, font, 400, my + 60, -1, -1, "CONTROLS - KEYBOARD");
 }
  else
  {
   textprintf_ex(display, font, 400, my + 60, -1, -1, "NO JOYSTICK");
   drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
   rectfill(display, 399, my + 50, 530, my + 75, CONVERT_WHITE_TO_GREY);
   drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);

  }


// textprintf_ex(display, font, 5, 5, -1, -1, "%i", any_joystick_input());



 my = 330;

 y2 = my + 7 + arena.just_got_highscore * 30;
 y3 = my + 29 + arena.just_got_highscore * 30;


 if (arena.just_got_highscore > 0)
 {
   rectfill(display, 0, y2 - 5, 250, y3, COL_COL3);
   rect(display, -1, y2 - 5 - 2, 250 + 2, y3 + 2, COL_COL4);
 }

// textprintf_right_ex(display, font, 137, my, -1, -1, "HIGH");
// textprintf_ex(display, font, 157, my, -1, -1, "SCORES");

 textprintf_centre_ex(display, font, 147, my, -1, -1, "HIGHSCORES");

 textprintf_right_ex(display, font, 137, my + 40, -1, -1, "NORMAL");
 textprintf_ex(display, font, 157, my + 40, -1, -1, "%i", options.highscore [0]);

 textprintf_right_ex(display, font, 137, my + 70, -1, -1, "HARD");
 textprintf_ex(display, font, 157, my + 70, -1, -1, "%i", options.highscore [1]);

 textprintf_right_ex(display, font, 137, my + 100, -1, -1, "PUNISHMENT");
 textprintf_ex(display, font, 157, my + 100, -1, -1, "%i", options.highscore [2]);

 textprintf_right_ex(display, font, 600, 570, -1, -1, "COPYRIGHT 2009 LINLEY HENZELL");

// should print last score here...

 anykey = 0;

  for (i = KEY_A; i < KEY_CAPSLOCK + 1; i ++)
  {
   if (key [i])
   {
    anykey = 1;
   }
  }

  if (anykey == 0 && (options.joystick == 0 || any_joystick_input() == 0))
   key_wait = 0;



 if (key_wait == 0)
 {
  if (menu_command(MC_UP))
  {
   menu_select --;
   if (menu_select < 0)
    menu_select = MENU_EXIT;
   if (menu_select == MENU_JOY_OR_KEYS && options.joystick == 0)
    menu_select = MENU_JOY_OR_KEYS - 1;
   key_wait = 7;
  }
  if (menu_command(MC_DOWN))
  {
   menu_select ++;
   if (menu_select > MENU_EXIT)
    menu_select = 0;
   if (menu_select == MENU_JOY_OR_KEYS && options.joystick == 0)
    menu_select = MENU_KEYS;
   key_wait = 7;
  }
  if (menu_command(MC_LEFT))
  {
//   if (menu_select == 2)
//    arena.starting_level = 1;
   if (menu_select == MENU_JOY_OR_KEYS)
   {
    if (options.key_or_joy == 0)
     options.key_or_joy = 1;
      else
       options.key_or_joy = 0;
   }
   if (menu_select == MENU_DIFFICULTY)
   {
    arena.difficulty --;
    if (arena.difficulty < 0)
     arena.difficulty = 0;
   }
   key_wait = 7;
  }
  if (menu_command(MC_RIGHT))
  {
//   if (menu_select == 2)
//    arena.starting_level = 2;
   if (menu_select == MENU_JOY_OR_KEYS)
   {
    if (options.key_or_joy == 0)
     options.key_or_joy = 1;
      else
       options.key_or_joy = 0;
   }
   if (menu_select == MENU_DIFFICULTY)
   {
    arena.difficulty ++;
    if (arena.difficulty > 2)
     arena.difficulty = 2;
   }
   key_wait = 7;
  }

//  if (key [KEY_ESC])
//   exit(0);
  if (menu_command(MC_SELECT))
  {
   if (menu_select == MENU_EXIT)
   {
    goodbye_menu_circles();
    return;
   }

   if (menu_select == MENU_KEYS)
   {
    key_wait = 10;
    define_keys();
    key_wait = 10;
   }

   if (menu_select == MENU_OPTIONS)
   {
    key_wait = 10;
    set_options();
    key_wait = 10;
   }

/*   if (menu_select == MENU_CALIBRATE)
   {
    jstick_calibrate();
    key_wait = 20;
    ticked = 0;
   }*/

   if (menu_select == MENU_START)
   {
    arena.level = 1;//arena.starting_level;
    ticked = 0;
    key_wait = 30;
    if (ship_select() == 1)
    {
     vsync();
//     clear_bitmap(screen);
//     clear_bitmap(display);
     player.type = PTYPE_BASIC;
//     player.type = PTYPE_BOMBER;
//     player.type = PTYPE_ANENOME;
//     player.type = PTYPE_HAND;
     player.weapon_level = 0;
     int ship_select = select_a_ship();
     if (ship_select != -1)
     {
      switch(ship_select)
      {
       default:
       case 0: player.type = PTYPE_BASIC; break;
       case 1: player.type = PTYPE_ANENOME; break;
       case 2: player.type = PTYPE_BOMBER; break;
       case 3: player.type = PTYPE_HAND; break;
       case 4: player.type = PTYPE_SQUID; break;
      }
      if (arena.level == 1)
       arena.from_start = 1;
        else
         arena.from_start = 0;
      arena.cleared = 0;
      arena.unlocked = 0;
      menu_counter = 0;
      goodbye_menu_circles();
      new_game();
      game_loop();
      if (arena.level == 4)
       congratulations();
      arena.target_palette = PAL_MENU;
      arena.shift_palette = 2;
      init_menu_circles();
//     reset_menu_palette();
      key_wait = 10; // was 1
//      flower_dir *= -1;
      ticked = 0;
     }
    }
     else key_wait = 20;
   }
    else
     key_wait = 20;
  }
 }
  else
   key_wait --;




    do
    {
        thing ++;
    } while (ticked == 0);
    ticked = 0;

 if (arena.shift_palette > 0 && menu_counter % 12 == 0)
 {
  run_palette_shift();
  build_new_palette(0, 0, 0, 0);
  set_palette(palet);
  if (arena.shift_palette == 1)
   arena.shift_palette = 0;
 }

 vsync();
 blit(display, screen, 0, 0, 100, 0, 600, 600);



 };


}
示例#4
0
///////////////////////////////////////////////////////////////////
//
// Function Name:	selectScreen()
// Description:		Draws popup box displaying router information
//
///////////////////////////////////////////////////////////////////
void Router::selectScreen() {
  int startX = xPixel + 10;
  int startY = yPixel - 105;
  int numtopaint;
  int black = makecol(0, 0, 0);

  if ((startX + 140) > SCREEN_W) startX = xPixel - 150;
  if ((startY + 220) > SCREEN_H) startY = SCREEN_H - 220;
  if ((startY < 15)) startY = 15;

  masked_blit(routerinfo, popup, 0, 0, startX, startY, SCREEN_W, SCREEN_H);

  numtopaint = routerIndex;
  textprintf_ex(popup, font, startX + 65, startY + 10, black, -1, "%d",
                numtopaint);
  textprintf_ex(popup, font, startX + 15, startY + 35, black, -1, "\"%s\"",
                name);
  numtopaint = numWorkstations;
  textprintf_right_ex(popup, font, startX + 129, startY + 57, black, -1, "%d",
                      numtopaint);
  numtopaint = 100.0 * double(numWorkstations) /
               double(threadZero->getCurrentActiveWorkstations());
  textprintf_right_ex(popup, font, startX + 129, startY + 72, black, -1, "%d",
                      numtopaint);
  numtopaint = edgeList.size();
  textprintf_right_ex(popup, font, startX + 129, startY + 90, black, -1, "%d",
                      numtopaint);

  if (connAttemptsToThis == 0)
    numtopaint = 0;
  else
    numtopaint =
        100 -
        (100.0 * ((double)connSuccessesToThis / (double)connAttemptsToThis));

  textprintf_right_ex(popup, font, startX + 129, startY + 130, black, -1, "%d",
                      numtopaint);

  // for percentage of failures by dest
  int totalfailures = 0;
  for (int r = 0; r < threadZero->getNumberOfRouters(); ++r) {
    totalfailures += threadZero->getRouterAt(r)->getConnAttemptsTo() -
                     threadZero->getRouterAt(r)->getConnSuccessesTo();
  }
  if (totalfailures == 0)
    numtopaint = 0;
  else
    numtopaint =
        floor(100.0 * ((double)(connAttemptsToThis - connSuccessesToThis)) /
              (double)totalfailures);
  textprintf_right_ex(popup, font, startX + 129, startY + 158, black, -1, "%d",
                      numtopaint);

  if (connAttemptsFromThis == 0)
    numtopaint = 0;
  else
    numtopaint = 100 - (100.0 * ((double)connSuccessesFromThis /
                                 (double)connAttemptsFromThis));
  textprintf_right_ex(popup, font, startX + 129, startY + 191, black, -1, "%d",
                      numtopaint);

  // for percentage of failures by source
  totalfailures = 0;
  for (int r = 0; r < threadZero->getNumberOfRouters(); ++r) {
    totalfailures += threadZero->getRouterAt(r)->getConnAttemptsFrom() -
                     threadZero->getRouterAt(r)->getConnSuccessesFrom();
  }
  if (totalfailures == 0)
    numtopaint = 0;
  else
    numtopaint =
        floor(100.0 * ((double)(connAttemptsFromThis - connSuccessesFromThis)) /
              (double)totalfailures);
  textprintf_right_ex(popup, font, startX + 129, startY + 219, black, -1, "%d",
                      numtopaint);

  textprintf_right_ex(popup, font, startX + 129, startY + 248, black, -1,
                      "%2.3f", avgQTo);
  textprintf_right_ex(popup, font, startX + 129, startY + 263, black, -1,
                      "%2.3f", avgQFrom);
  // numtopaint = avgQTo
  // textprintf_ex(popup,font,startX+5,startY+170,black,-1,"Avg. Q Factor: ");
}