コード例 #1
0
ファイル: graphics.c プロジェクト: GNOME/gnome-robots
/**
 * draw_tile_pixmap
 * @tileno: Graphics tile number
 * @pno: Number of graphics set
 * @x: x position in grid squares
 * @y: y position in grid squares
 * @cr: context to draw on
 *
 * Description:
 * Draws tile pixmap @tileno from graphics set @pno at (@x, @y) in
 * a widget @area
 **/
static void
draw_tile_pixmap (gint tileno, gint x, gint y, cairo_t * cr)
{
  if ((x & 1) ^ (y & 1)) {
    gdk_cairo_set_source_rgba (cr, &dark_background);
  } else {
    gdk_cairo_set_source_rgba (cr, &light_background);
  }

  x *= tile_width;
  y *= tile_height;
  
  cairo_rectangle (cr, x, y, tile_width, tile_height);
  cairo_fill (cr);

  if (rerender_needed)
    render_graphics ();

  if ((tileno < 0) || (tileno >= SCENARIO_PIXMAP_WIDTH)) {
    /* nothing */
  } else {
    gdk_cairo_set_source_pixbuf (cr, theme_pixbuf, x - tileno * tile_width, y);
    cairo_rectangle (cr, x, y, tile_width, tile_height);
    cairo_fill (cr);
  }
}
コード例 #2
0
/**
 * draw_tile_pixmap
 * @tileno: Graphics tile number
 * @pno: Number of graphics set
 * @x: x position in grid squares
 * @y: y position in grid squares
 * @area: Pointer to drawing area widget
 *
 * Description:
 * Draws tile pixmap @tileno from graphics set @pno at (@x, @y) in
 * a widget @area
 **/
void
draw_tile_pixmap (gint tileno, gint x, gint y, GtkWidget * area)
{
  GdkGC *bg;

  if ((x & 1) ^ (y & 1)) {
    bg = dark_bggc;
  } else {
    bg = light_bggc;
  }

  x *= tile_width;
  y *= tile_height;

  gdk_draw_rectangle (area->window, bg, TRUE, x, y, tile_width, tile_height);

  if (rerender_needed)
    render_graphics ();

  if ((tileno < 0) || (tileno >= SCENARIO_PIXMAP_WIDTH)) {
    /* nothing */
  } else {
    gdk_draw_pixbuf (area->window, area->style->black_gc,
		     theme_pixbuf,
		     tileno * tile_width, 0,
		     x, y, tile_width, tile_height,
		     GDK_RGB_DITHER_NORMAL, 0, 0);
  }
}
コード例 #3
0
ファイル: maze.c プロジェクト: hexablade/Maze-Refactor
void render_board(){ // creates the board
    
    clear_graphics();
    int y;
    int x;
    Color sc;
    
    
    for(y=0; y < COL; y++){
        for(x=0; x < ROW; x++){
            if(maze[y][x]== _){
                sc = PIECEE;
                drawRect(sc, x*SQUARESIZEX , y*SQUARESIZEY, W, H);
            }
            else if(maze[y][x]== S){
                sc = PIECEC;
                drawRect(sc, x*SQUARESIZEX , y*SQUARESIZEY, W, H);
            }
            else if(maze[y][x]== E){
                sc = PIECEM;
                drawRect(sc, x*SQUARESIZEX , y*SQUARESIZEY, W, H);
            }
            else if(maze[y][x]== B){
                sc = PIECEB;
                drawRect(sc, x*SQUARESIZEX , y*SQUARESIZEY, W, H);
            }
            else if(maze[y][x]==P){
                sc = PIECEP;
                drawRect(sc, x*SQUARESIZEX + PW , y*SQUARESIZEY + PH, MW, MH);
            }
            else if(maze[y][x]== F){
                sc = BRDRC;
                drawRect(sc, x*SQUARESIZEX , y*SQUARESIZEY, W, H);
            }
            else if(maze[y][x]== J ||  maze[y][x]== L){
                sc = PORTALC;
                drawRect(sc, x*SQUARESIZEX , y*SQUARESIZEY, W, H);
            }
            
            
        }
    }
    
    
    drawRect(MPC, px*SQUARESIZEX , py*SQUARESIZEY, W, H);
    
    
    render_graphics();
    
    return;
}
コード例 #4
0
void render_game(Game* G)
{
    render_graphics(G->graphics);
    draw_ui(G->ui);
}