Example #1
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_set_source_rgb (cr, 1, 1, 1);
    cairo_paint (cr);

    cairo_set_source_rgb (cr, 0, 0, 0);

    cairo_save (cr);
    cairo_translate (cr, 50, 50);
    cairo_scale (cr, 1, 1);
    draw_symbol (cr);
    cairo_restore (cr);

    cairo_save (cr);
    cairo_translate (cr, 150, 50);
    cairo_scale (cr, -1, 1);
    draw_symbol (cr);
    cairo_restore (cr);

    cairo_save (cr);
    cairo_translate (cr, 150, 150);
    cairo_scale (cr, -1, -1);
    draw_symbol (cr);
    cairo_restore (cr);

    cairo_save (cr);
    cairo_translate (cr, 50, 150);
    cairo_scale (cr, 1, -1);
    draw_symbol (cr);
    cairo_restore (cr);

    return CAIRO_TEST_SUCCESS;
}
Example #2
0
/******************************************************************
*                           redraw_screen                         *
*******************************************************************/
void redraw_screen(int *bell, int maxmoves, int num, long score, int nf,
                   int diamonds, int mx, int sx, int sy,
                   char (*frow)[ROWLEN + 1])
{
    char buffer[50];

    clear();
    move(0, 48);
    addstr("Score\t   Diamonds");
    move(1, 48);
    addstr("\tFound\tTotal");
    move(3, 48);
    sprintf(buffer, "%ld\t %d\t %d  ", score, nf, diamonds);
    addstr(buffer);
    if (!edit_mode)
    {
        move(6, 48);
        sprintf(buffer, "Current screen %d", num);
        addstr(buffer);
    }
    if (maxmoves != -1)
        sprintf(buffer, "Moves remaining = %d   ", maxmoves);
    else
        strcpy(buffer, "     Unlimited moves     ");
    move(15, 48);
    addstr(buffer);
    move(17, 56);
    if (*bell)
        addstr("Bell ON ");
    else
        addstr("Bell OFF");
    if (mx != -1)
    {                           /* tell player if monster exists */
        draw_symbol(50, 11, 'M');
        move(12, 56);
        addstr("Monster on the");
        move(13, 56);
        printw("%-14s", "loose!");
    }
    else
    {
        draw_symbol(50, 11, ' ');
        move(12, 56);
        printw("%14s", "");
        move(13, 56);
        printw("%14s", "");
    }

    showname();

    if (!debug_disp)
        display(sx, sy, frow);
    else
        map(frow);
}
Example #3
0
/***********************************************
*                   display                    *
************************************************/
void display(int cx, int cy, char (*row_ptr)[ROWLEN + 1])
{
    int x, y = 0, x_coord, y_coord;
    char ch;
    while (y < (cy - 3))
    {
        y++;
        row_ptr++;
    };
    move(0, 0);
    addstr("+---------------------------------+");
    move(15, 0);
    addstr("+---------------------------------+");
    for (y = (cy - 3); y <= (cy + 3); y++)
    {
        y_coord = (y + 3 - cy) * 2;
        if ((y < 0) || (y >= NOOFROWS))
        {
            move(y_coord + 1, 0);
            addstr("|#################################|");
            move(y_coord + 2, 0);
            addstr("|#################################|");
        }
        else
        {
            move(y_coord + 1, 0);
            addch('|');
            move(y_coord + 1, 34);
            addch('|');
            move(y_coord + 2, 0);
            addch('|');
            move(y_coord + 2, 34);
            addch('|');
            for (x = (cx - 5); x <= (cx + 5); x++)
            {
                x_coord = (x + 5 - cx) * 3;
                if ((x < 0) || (x > ROWLEN - 1))
                    draw_symbol(x_coord, y_coord, '#');
                else
                {
                    ch = (*row_ptr)[x];
                    draw_symbol(x_coord, y_coord, ch);
                }
            };
            row_ptr++;
        }                       /*   end if   */
    }                           /* end y loop */
    move(16, 0);
    refresh();
}
Example #4
0
File: legend.c Project: npe9/sprite
/****************************************************************
 *								*
 *	drawlegend - draw a legend				*
 *								*
 ****************************************************************/
drawlegend()
{
    register int i;
    float legendlx, legendly;
    int legend_line_len;

    if(legendbox)
      drawlbox();
    legendlx = cg.lframe.frame1x + 10.0;
    legendly = cg.lframe.frame1y+10.0;
    for (curline = 0; ((curline != cg.maxlines) && (cl != NULL)); ++curline)
      if(cl->lonoff){
        drawctext(legendlx+10.0, legendly, cl->llelabel.t_font,
	  cl->llelabel.t_size, cl->llelabel.t_text, BOTLEFT_TEXT);
	legend_line_len = xcharsz[cl->llelabel.t_size] * 
	  strlen(cl->llelabel.t_text);
	drawline(cl->ltype, legendlx+10.0, legendly-3.0,
	  legendlx+legend_line_len+10, legendly-3.0);
	draw_symbol(cl->mtype, legendlx, legendly+5.0);
	legendly = legendly + cg.ylabel.t_size * 15.0 * 0.6;
      }
    if (cg.legend.t_text[0] == NULL)
      strcpy (cg.legend.t_text, "Legend");
    drawctext((cg.lframe.frame1x+cg.lframe.frame3x)/2.0, 
      cg.lframe.frame2y - 3.0, cg.legend.t_font, cg.legend.t_size,
      cg.legend.t_text, TOPCENTER_TEXT);
    return;
}
Example #5
0
/*--------------------------------------------------------------
 Routine : draw_symbol_small
 Purpose :
---------------------------------------------------------------*/
void
draw_symbol_small(Canvas canvas, CanvasCoord symbol_centre, SYMBOL *symbol)
{
/*     SEGMENT        *seg_list; */
/*     ARC                *arc; */
/*     RECTANGLE        *rect; */
/*     POLYLINE        *poly; */
/*     LINE        *line; */
    SYMBOL *small_symbol;

    ASSERT( symbol != NULL );

    small_symbol = scale_symbol(symbol, 1.1);
    symbol_centre.y += (symbol->depth - small_symbol->depth)/2.0;
    draw_symbol(canvas, symbol_centre, small_symbol);
    delete_symbol(small_symbol);
}
Example #6
0
void _draw()
{
    int state = statestack_top();

    io::clear_screen();

    view_t view;

    if (state == STATE_EXAMINE)
    {
        view = compute_view(target_cursor_position(), VIEW_WIDTH, VIEW_HEIGHT,
                            current_dungeon->width, current_dungeon->height);
    }
    else
    {
        view = compute_view(player.pos, VIEW_WIDTH, VIEW_HEIGHT,
                            current_dungeon->width, current_dungeon->height);
    }

    compute_fov(current_dungeon, player.pos.x, player.pos.y);
    draw_dungeon(current_dungeon, view);

    if (inside_view(view, player.pos))
    {
        if (player.flag & CF_INVISIBLE)
            draw_symbol_hilite(player.symbol, player.pos.x - view.x, player.pos.y - view.y);
        else
            draw_symbol(player.symbol, player.pos.x - view.x, player.pos.y - view.y);
    }

    if (state == STATE_EXAMINE || state == STATE_CAST_SPELL || state == STATE_ZAP_WAND)
    {
        draw_target_cursor(view);
    }

    draw_stats();

    erase_msg_buffer();
    flush_turn_log(false);

    io::flush();
}
Example #7
0
void draw_dungeon(dungeon_t* dungeon, const view_t& view)
{
  int fog_symbol = game_config::get_int("fog_symbol");

  for (int y = view.y; y < view.y + view.h; y++)
  {
    for (int x = view.x; x < view.x + view.w; x++)
    {
      int index = y * dungeon->width + x;

      if (x < 0 || y < 0 || x >= dungeon->width || y >= dungeon->height || index < 0 || index >= dungeon->width * dungeon->height)
        continue;

      tile_t tile = dungeon->map[index];

      if (dungeon->lightmap[index] != DARK)
      {
        color_t final_color = tile.sym.color;
        if (dungeon->lightmap[index] == SEEN)
        {
          final_color = color_dark_gray;//tile.sym.color * 0.5f;
        }

        symbol_t symbol = tile.sym;
        symbol.color = final_color;
        draw_symbol(symbol, x - view.x, y - view.y);
      }
      else
      {
        if (fog_symbol != 0 && fog_symbol != 32)
        {
          symbol_t symbol;
          symbol.color = color_dark_gray;
          symbol.glyph = static_cast<char>(fog_symbol);
          draw_symbol(symbol, x - view.x, y - view.y);
        }
      }
    }
  }

  for (size_t i = 0; i < dungeon->items.size(); i++)
  {
    item_t* item = dungeon->items.at(i);

    if (!inside_view(view, item->pos))
      continue;

    int lightmap_index = item->pos.y * dungeon->width + item->pos.x;

    if (dungeon->lightmap[lightmap_index] != DARK)
    {
      color_t final_color = item->symbol.color;
      if (dungeon->lightmap[lightmap_index] == SEEN)
      {
        final_color = color_dark_gray;//final_color * 0.5f;
      }
      // item->symbol.color = final_color;
      // TODO: Remember items outside LOS
      symbol_t symbol = item->symbol;
      symbol.color = final_color;

      if (count_items_at(dungeon, item->pos.x, item->pos.y) > 1)
      {
        draw_symbol_hilite(symbol, item->pos.x - view.x, item->pos.y - view.y);
      }
      else
      {
        draw_symbol(symbol, item->pos.x - view.x, item->pos.y - view.y);
      }
    }
  }

  dungeon->cloud_system.draw(view);

  for (size_t i = 0; i < dungeon->creatures.size(); i++)
  {
    creature_t* creature = dungeon->creatures.at(i);

    if (!inside_view(view, creature->pos))
      continue;

    int lightmap_index = creature->pos.y * dungeon->width + creature->pos.x;

    if (dungeon->lightmap[lightmap_index] == LIT)
    {
      if (creature->flag & CF_PLAYER_ALLY)
      {
        // If ally, mark this by highlighting.
        draw_symbol_hilite(creature->symbol, creature->pos.x - view.x, creature->pos.y - view.y);
      }
      else
      {
        bool should_draw = !(creature->flag & CF_INVISIBLE);
        if (!should_draw && (player.flag & CF_SEE_INVISIBLE))
          should_draw = true;

        if (should_draw)
          draw_symbol(creature->symbol, creature->pos.x - view.x, creature->pos.y - view.y);
      }
    }
  }
}
Example #8
0
	bool onUpdate(float timeDelta)
	{	
		april::rendersys->clear();
		april::rendersys->setOrthoProjection(drawRect);
	
		april::rendersys->setTexture(background);
		v[0].x = 0;				v[0].y = 0;				v[0].z = 0;	v[0].u = 0;	v[0].v = 0;
		v[1].x = drawRect.w;	v[1].y = 0;				v[1].z = 0;	v[1].u = 1;	v[1].v = 0;
		v[2].x = 0;				v[2].y = drawRect.h;	v[2].z = 0;	v[2].u = 0;	v[2].v = 1;
		v[3].x = drawRect.w;	v[3].y = drawRect.h;	v[3].z = 0;	v[3].u = 1;	v[3].v = 1;
		april::rendersys->render(april::RO_TRIANGLE_STRIP, v, 4);
	
		april::rendersys->setTexture(NULL);
		april::rendersys->drawFilledRect(grect(size.x, 0, 10, drawRect.h), april::Color::Magenta);
		april::rendersys->drawFilledRect(grect(size.x * 2 + 10, 0, 10, drawRect.h), april::Color::Magenta);
		april::rendersys->drawFilledRect(grect(0, size.y, drawRect.w, 10), april::Color::Magenta);
		april::rendersys->drawFilledRect(grect(0, size.y * 2 + 10, drawRect.w, 10), april::Color::Magenta);
	
		for (int j = 0; j < 3; j++)
		{
			for (int i = 0; i < 3; i++)
			{
				if (positions[i][j] == 1)
				{
					draw_symbol(i + 1, j + 1, "x_symbol");
				}
				else if (positions[i][j] == 2)
				{
					draw_symbol(i + 1, j + 1, "o_symbol");
				}
			}
		}
		
		switch (victory)
		{
		case 1:
			draw_line(0, 0, 0, 2, "line_horz");
			break;
		case 2:
			draw_line(1, 0, 1, 2, "line_horz");
			break;
		case 3:
			draw_line(2, 0, 2, 2, "line_horz");
			break;
		case 4:
			draw_line(0, 0, 2, 0, "line_vert");
			break;
		case 5:
			draw_line(0, 1, 2, 1, "line_vert");
			break;
		case 6:
			draw_line(0, 2, 2, 2, "line_vert");
			break;
		case 7:
			draw_line(0, 0, 2, 2, "line45");
			break;
		case 8:
			draw_line(0, 0, 2, 2, "line315");
			break;
		}
	
		return true;
	}