Пример #1
0
static void draw_scores(state_t *state)
{
	glColor4f(1.0, 1.0, 1.0, 0.5);
	draw_num(state->total_noobs, XRES, 0.0, 30.0);
	glColor4f(0.1, 1.0, 0.1, 1.0);
	draw_num(state->kills, XRES, 40.0, 30.0);
	glColor3f(1.0, 0.1, 0.1);
	draw_num(state->leaks, XRES, 80.0, 30.0);
}
Пример #2
0
void image_printf(IMAGE * img, int edged_width, int height,
                  int x, int y, char *fmt, ...)
{
    va_list args;
    char buf[FONT_BUF_SZ];
    int i;

    va_start(args, fmt);
    vsprintf(buf, fmt, args);
    va_end(args);

    for (i = 0; i < buf[i]; i++) {
        const char * font;

        if (buf[i] >= '!' && buf[i] <= '@')
            font = ascii33[buf[i]-'!'];
        else if (buf[i] >= 'A' && buf[i] <= 'Z')
            font = ascii65[buf[i]-'A'];
        else if (buf[i] >= '[' && buf[i] <= '`')
            font = ascii91[buf[i]-'['];
        else if (buf[i] >= 'a' && buf[i] <= 'z')
            font = ascii65[buf[i]-'a'];
        else
            continue;

        draw_num(img, edged_width, height, font, x + i*FONT_ZOOM*(FONT_WIDTH+1), y);
    }
}
Пример #3
0
void status_bar::draw_health(image *screen,int amount)
{
  if (total_weapons)
  {
    int x1,y1,x2,y2;
    area(x1,y1,x2,y2);
    draw_num(screen,x1+(small_render ? 17*2 : 17),y1+(small_render ? 11*2 : 11),amount,bnum);
  }
}
Пример #4
0
int main(void)
{
	int num = 0;

	lcd_init();

	draw_num(num);

	return 0;
}
Пример #5
0
void status_bar::draw_ammo(image *screen, int weapon_num, int amount, int light)
{
  if (total_weapons)
  {
    int x1,y1,x2,y2;
    area(x1,y1,x2,y2);
    draw_num(screen,
        x1+(small_render ? 52*2+weapon_num*34*2 : 52+weapon_num*34),
        y1+(small_render ? 25*2 : 25),amount,bnum+(light ? 20 : 10));
  }
}
Пример #6
0
Файл: game.c Проект: shiftky/GBA
void game_step(void)
{
  switch ( game_get_state() ) {
    case START:
      current_stage = 0;
      draw_string("Press START key to start.", 23, 85, COLOR_WHITE);
      if ( get_key_state(KEY_START) ) {
        draw_string("Press START key to start.", 23, 85, COLOR_BLACK);
        game_set_state(REMAINING);
      }
      break;

    case NEXTSTAGE:
      game_set_state(REMAINING);
      break;

    case REMAINING:
      draw_string("stage ", 95, 75, COLOR_WHITE);
      draw_num(current_stage+1, 140, 75, COLOR_WHITE);
      draw_string("ball x", 90, 85, COLOR_YELLOW);
      draw_num(ball_get_remaining(), 145, 85, COLOR_YELLOW);
      delay(30000);
      draw_string("stage ", 95, 75, COLOR_BLACK);
      draw_num(current_stage+1, 140, 75, COLOR_BLACK);
      draw_string("ball x", 90, 85, COLOR_BLACK);
      draw_num(ball_get_remaining(), 145, 85, COLOR_BLACK);
      game_set_state(RUNNING);
      break;

    case RUNNING:
      // for Debug
      if ( get_key_state(KEY_SELECT) ) {
        game_set_state(CLEAR);
      }
      break;

    case DEAD:
      draw_string("GAME OVER", 85, 70, COLOR_RED);
      draw_string("Press START key to restart.", 16, 85, COLOR_WHITE);
      if ( get_key_state(KEY_START) ) {
        init_screen();
        game_set_state(RESTART);
      }
      break;

    case CLEAR:
      if ( current_stage < 2 ) {
        draw_string("CLEAR!!", 95, 70, COLOR_ITF);
        draw_string("Press A key to", 65, 85, COLOR_WHITE);
        draw_string("next stage!", 80, 95, COLOR_WHITE);
        if ( get_key_state(KEY_A) ) {
          init_screen();
          current_stage++;
          game_set_state(NEXTSTAGE);
        }
      } else {
        draw_string("CLEAR!!", 95, 70, COLOR_ITF);
        draw_string("Press START key to restart.", 16, 85, COLOR_WHITE);
        if ( get_key_state(KEY_START) ) {
          init_screen();
          game_set_state(RESTART);
        }
      }
      break;

    case RESTART:
      current_stage = 0;
      game_set_state(START);
      break;
  }
}
Пример #7
0
    // main drawing routine
    bool Draw::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
    {
        int num_cells = b.num_bowls + 2;
        double inv_num_cells = 1.0 / num_cells;

        Gtk::Allocation alloc = get_allocation();

        Pango::FontDescription font("Monospace");
        font.set_size(std::min(alloc.get_width(), alloc.get_height()) * .1 * Pango::SCALE);
        cr->set_source_rgb(0.0, 0.0, 0.0);

        // draw bg
        draw_img(cr, bg_board, 0.0, 0.0, alloc.get_width() / (bg_board->get_width() - .5),
            alloc.get_height() / (bg_board->get_height() - .5));

        // draw bg for left store
        draw_img(cr, bg_store, 0.0, 0.0, alloc.get_width() / (bg_store->get_width() - .5) * inv_num_cells,
            alloc.get_height() / (bg_store->get_height() - .5));

        // l store beads
        for(auto & j: b.l_store.beads)
        {
            draw_img(cr, bead_imgs[j.color_i], alloc.get_width() * j.pos[0], alloc.get_height() * j.pos[1],
                alloc.get_width() / (bead_imgs[j.color_i]->get_width() - .5) * inv_num_cells,
                alloc.get_height() / (bead_imgs[j.color_i]->get_height() - .5) * .5);
            draw_img(cr, bead_s_img, alloc.get_width() * j.pos[0], alloc.get_height() * j.pos[1],
                alloc.get_width() / (bead_s_img->get_width() - .5) * inv_num_cells,
                alloc.get_height() / (bead_s_img->get_height() - .5) * .5);
        }

        // draw # for left store
        draw_num(cr, font, b.l_store.beads.size(), alloc.get_width() * .5 * inv_num_cells,
            alloc.get_height() * .5);

        // draw bg for right store
        draw_img(cr, bg_store, alloc.get_width() * (1.0 - inv_num_cells), 0,
            alloc.get_width() / (bg_store->get_width() - .5) * inv_num_cells,
            alloc.get_height() / (bg_store->get_height() - .5));

        // r store beads
        for(auto & j: b.r_store.beads)
        {
            draw_img(cr, bead_imgs[j.color_i], alloc.get_width() * j.pos[0], alloc.get_height() * j.pos[1],
                alloc.get_width() / (bead_imgs[j.color_i]->get_width() - .5) * inv_num_cells,
                alloc.get_height() / (bead_imgs[j.color_i]->get_height() - .5) * .5);
            draw_img(cr, bead_s_img, alloc.get_width() * j.pos[0], alloc.get_height() * j.pos[1],
                alloc.get_width() / (bead_s_img->get_width() - .5) * inv_num_cells,
                alloc.get_height() / (bead_s_img->get_height() - .5) * .5);
        }

        // draw # for right store
        draw_num(cr, font, b.r_store.beads.size(), alloc.get_width() * (1.0 - .5 * inv_num_cells),
            alloc.get_height() * .5);

        // draw bowls
        for(size_t i = 0; i < b.top_row.size(); ++i)
        {
            // draw upper row hint
            if(hint_player == PLAYER_2 && show_hint && hint_i == (int)i)
            {
                draw_img(cr, hint_img, alloc.get_width() * (i + 1) * inv_num_cells, 0.0,
                    alloc.get_width() / (hint_img->get_width() - .5) * inv_num_cells,
                    alloc.get_height() / (hint_img->get_height() - .5) * .5);
            }

            // upper row bgs
            draw_img(cr, bg_bowl, alloc.get_width() * (i + 1) * inv_num_cells, 0,
                alloc.get_width() / (bg_bowl->get_width() - .5) * inv_num_cells,
                alloc.get_height() / (bg_bowl->get_height() - .5) * .5);

            // upper row beads
            for(auto & j: b.top_row[i].beads)
            {
                draw_img(cr, bead_imgs[j.color_i], alloc.get_width() * j.pos[0], alloc.get_height() * j.pos[1],
                    alloc.get_width() / (bead_imgs[j.color_i]->get_width() - .5) * inv_num_cells,
                    alloc.get_height() / (bead_imgs[j.color_i]->get_height() - .5) * .5);
                draw_img(cr, bead_s_img, alloc.get_width() * j.pos[0], alloc.get_height() * j.pos[1],
                    alloc.get_width() / (bead_s_img->get_width() - .5) * inv_num_cells,
                    alloc.get_height() / (bead_s_img->get_height() - .5) * .5);
            }

            // upper row txt
            draw_num(cr, font, b.top_row[i].beads.size(), alloc.get_width() * (2 * i + 3) * .5 * inv_num_cells,
                alloc.get_height() * .25);

            // draw lower row hint
            if(hint_player == PLAYER_1 && show_hint && hint_i == (int)i)
            {
                draw_img(cr, hint_img, alloc.get_width() * (i + 1) * inv_num_cells, .5 * alloc.get_height(),
                    alloc.get_width() / (hint_img->get_width() - .5) * inv_num_cells,
                    alloc.get_height() / (hint_img->get_height() - .5) * .5);
            }

            // lower row bgs
            draw_img(cr, bg_bowl, alloc.get_width() * (i + 1) * inv_num_cells, .5 * alloc.get_height(),
                alloc.get_width() / (bg_bowl->get_width() - .5) * inv_num_cells,
                alloc.get_height() / (bg_bowl->get_height() - .5) * .5);

            // lower row beads
            for(auto & j: b.bottom_row[i].beads)
            {
                draw_img(cr, bead_imgs[j.color_i], alloc.get_width() * j.pos[0], alloc.get_height() * j.pos[1],
                    alloc.get_width() / (bead_imgs[j.color_i]->get_width() - .5) * inv_num_cells,
                    alloc.get_height() / (bead_imgs[j.color_i]->get_height() - .5) * .5);
                draw_img(cr, bead_s_img, alloc.get_width() * j.pos[0], alloc.get_height() * j.pos[1],
                    alloc.get_width() / (bead_s_img->get_width() - .5) * inv_num_cells,
                    alloc.get_height() / (bead_s_img->get_height() - .5) * .5);
            }

            // lower row txt
            draw_num(cr, font, b.bottom_row[i].beads.size(), alloc.get_width() * (2 * i + 3) * .5 * inv_num_cells,
                alloc.get_height() * .75);
        }
        return true;
    }
Пример #8
0
void status_bar::redraw(image *screen)
{
  need_rf=0;
  if (!v) return ;

  if (total_weapons)
  {
    if (!playing_state(the_game->state)) return ;

    image *sb=cache.img(sbar);

    // status bar width & height
    int sb_w=(small_render ? sb->Size().x*2 : sb->Size().x),
    sb_h=(small_render ? sb->Size().y*2 : sb->Size().y);

    // status bar x & y position
    int sx=xres/2-sb_w/2,sy=yres-sb_h;

    // weapon x offset, and x add increment
    int wx=small_render ? 80 : 40,wa=small_render ? 34*2 : 34;

    // weapon icon width & height
    int ww=small_render ? cache.img(bweap[0])->Size().x*2 : cache.img(bweap[0])->Size().x;
    int wh=small_render ? cache.img(bweap[0])->Size().y*2 : cache.img(bweap[0])->Size().y;


    // numpad y offset
    int np_yo=small_render ? 42 : 21;
    int np_w=small_render ? cache.img(sbar_numpad)->Size().x*2 : cache.img(sbar_numpad)->Size().x;
    int np_h=small_render ? cache.img(sbar_numpad)->Size().y*2 : cache.img(sbar_numpad)->Size().y;

    // selection bar width * height
    int sel_w=small_render ? cache.img(sbar_select)->Size().x*2 : cache.img(sbar_select)->Size().x;
    int sel_h=small_render ? cache.img(sbar_select)->Size().y*2 : cache.img(sbar_select)->Size().y;

    int sel_off=small_render ?  8 : 4;
    scale_put(sb,screen,sx,sy,sb_w,sb_h);

    if (v->focus)
      draw_num(screen,sx+(small_render ? 17*2 : 17),sy+(small_render ? 11*2 : 11),v->focus->hp(),bnum);

    int ammo_x,ammo_y;
    if (small_render)
    {
      ammo_x=sx+52*2;
      ammo_y=sy+25*2;
    } else { ammo_x=sx+52; ammo_y=sy+25; }

    int i,x_on=sx+wx,t=TOTAL_WEAPONS;
    if (t>=total_weapons) t=total_weapons;
    for (i=0; i<t; i++,x_on+=wa,ammo_x+=wa)
    {
      if (v->has_weapon(i))
      {
    if (v->current_weapon==i)
        scale_put_trans(cache.img(bweap[i]),screen,x_on,sy,ww,wh);
    else
        scale_put_trans(cache.img(dweap[i]),screen,x_on,sy,ww,wh);

    scale_put_trans(cache.img(sbar_numpad),screen,x_on-2,sy+np_yo,np_w,np_h);

    if (v->current_weapon==i)
          draw_num(screen,ammo_x,ammo_y,v->weapon_total(i),bnum+20);
    else
          draw_num(screen,ammo_x,ammo_y,v->weapon_total(i),bnum+10);

    if (i==icon_in_selection)
        scale_put_trans(cache.img(sbar_select),screen,x_on+sel_off,sy,sel_w,sel_h);
      }
    }
  }
}