Exemple #1
0
void AllegroGUIRenderer::fillPartialRoundedRect(int x, int y, int width,
  int height, int radius,partialRoundedRect part, const GUIColor& color)
{
    adjustPoint(x, y);
    switch(part)
    {
    case prr_top:
        circlefill(target, x+radius, y+radius, radius, color);
        circlefill(target, x+width-radius-1, y+radius, radius, color);
        rectfill(target, x, y+radius, x+width-1, y+height-1, color);
        rectfill(target, x+radius, y, x+width-radius-1, y+radius-1, color);
        break;
    case prr_bottom:
        circlefill(target, x+radius, y+height-radius-1, radius, color);
        circlefill(target, x+width-radius-1, y+height-radius-1, radius, color);
        rectfill(target, x, y, x+width-1, y+height-radius-1, color);
        rectfill(target, x+radius, y+height-radius, x+width-radius-1, y+height-1, color);
        break;
        
    case prr_topRight:
        break;
        
    case prr_bottomRight:
        break;
    }
}
Exemple #2
0
// highlight: animate the placement of the stone
void highlight(int en, int side)
{
	int i;

	scare_mouse();
	if (side == 1)
	{
		for (i = 0; i < 20; ++i)
		{
			// go from blackground color to black
			circlefill(screen, 50*file(en), 45 + 50*rank(en), 15,
				makecol(0, 200 - i*10, 0));
			rest(10);
		}
	}
	else
	{
		for (i = 0; i < 20; ++i)
		{
			// go from background color to white
			circlefill(screen, 50*file(en), 45 + 50*rank(en), 15,
				makecol(i*10, 200 + 55*i/20, i*10));
			rest(10);
		}
	}
	unscare_mouse();
}
void PutGrid(BITMAP * dc)
{
	double yr = TO_RAD(Form1->TrackBarTilt->Position);
	float sin_y = Sin(ANGLE_Y);
	float cos_y = Cos(ANGLE_Y);

	float ScaleV_Y = sin_y;
	float ScaleV_XZ = cos_y;
	float sin_x = Sin(ANGLE_X);
	float cos_x = Cos(ANGLE_X);
	int PenCol;
	SET_PEN(dc,128,0,0);
	LINE(dc,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y,
			CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y,PenCol);
	LINE(dc,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ,
			CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ,PenCol);
	LINE(dc,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y,
			CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y,PenCol);

	LINE(dc	,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y
			,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y			,PenCol);
	LINE(dc	,CENTER+XGRID_2*cos_x,CENTER-XGRID_2*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y
			,CENTER+XGRID_2*cos_x,CENTER-XGRID_2*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y			,PenCol);
	LINE(dc	,CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y
			,CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y			,PenCol);
	LINE(dc	,CENTER-XGRID_2*cos_x,CENTER+XGRID_2*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y
			,CENTER-XGRID_2*cos_x,CENTER+XGRID_2*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y			,PenCol);

	float sin_z = cos_x;//Sin(ANGLE_Z);
	float cos_z = sin_x;//Cos(ANGLE_Z);

	SET_PEN(dc,0,96,96);//                SelectObject(dc,PenYellow);
	LINE(dc,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ - XGRID_2*ScaleV_Y,
			CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ - XGRID_2*ScaleV_Y,PenCol);
	LINE(dc,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ,//*ScaleV_Y    ,
			CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ /**ScaleV_Y*/    ,PenCol);
	LINE(dc,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ +XGRID_2*ScaleV_Y,
			CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ +XGRID_2*ScaleV_Y,PenCol);

	LINE(dc,CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ-XGRID_2*ScaleV_Y
		   ,CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ+XGRID_2*ScaleV_Y			,PenCol);
	LINE(dc	,CENTER-XGRID_2*cos_z,CENTER-XGRID_2*sin_z*ScaleV_XZ-XGRID_2*ScaleV_Y
			,CENTER-XGRID_2*cos_z,CENTER-XGRID_2*sin_z*ScaleV_XZ+XGRID_2*ScaleV_Y			,PenCol);
	LINE(dc,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ-XGRID_2*ScaleV_Y
		   ,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ+XGRID_2*ScaleV_Y			,PenCol);
	LINE(dc	,CENTER+XGRID_2*cos_z,CENTER+XGRID_2*sin_z*ScaleV_XZ-XGRID_2*ScaleV_Y
			,CENTER+XGRID_2*cos_z,CENTER+XGRID_2*sin_z*ScaleV_XZ+XGRID_2*ScaleV_Y			,PenCol);

	SET_PEN(dc,64,64,64);//                SelectObject(dc,PenYellow);
	LINE(dc,CENTER,CENTER-XGRID_2*ScaleV_Y,
			CENTER,CENTER+XGRID_2*ScaleV_Y,PenCol);
	circlefill(dc,
			CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ //*sin_y
			,3,makecol24(0,128,0));
	circlefill(dc,
			CENTER,CENTER-XGRID_2*ScaleV_Y
			,3,makecol24(128,128,0));
}
Exemple #4
0
void moveBall(){

    ball_tempX = ball_x;
    ball_tempY = ball_y;

    if (dir == 1 && ball_x > 5 && ball_y > 5){
     
         if( ball_x == p1_x + 15 && ball_y >= p1_y && ball_y <= p1_y + 60){
                  dir = rand()% 2 + 3;
         }else{    
                 --ball_x;
                 --ball_y;
         }    
              
    } else if (dir == 2 && ball_x > 5 && ball_y < 475){

         if( ball_x == p1_x + 15 && ball_y >= p1_y && ball_y <= p1_y + 60){
                  dir = rand()% 2 + 3;
         }else{    
                 --ball_x;
                 ++ball_y;
         }

    } else if (dir == 3 && ball_x < 635 && ball_y > 5){

         if( ball_x + 5 == p2_x && ball_y >= p2_y && ball_y <= p2_y + 60){
                  dir = rand()% 2 + 1;
         }else{    
                 ++ball_x;
                 --ball_y;
         }

    } else if (dir == 4 && ball_x < 635 && ball_y < 475){

         if( ball_x + 5 == p2_x && ball_y >= p2_y && ball_y <= p2_y + 60){
                  dir = rand()% 2 + 1;
         }else{    
                 ++ball_x;
                 ++ball_y;
         }

    } else { 

        if (dir == 1 || dir == 3)    ++dir;
        else if (dir == 2 || dir == 4)    --dir;

    }    
    
    acquire_screen();
    circlefill ( buffer, ball_tempX, ball_tempY, 5, makecol( 0, 0, 0));
    circlefill ( buffer, ball_x, ball_y, 5, makecol( 128, 255, 0));
    draw_sprite( screen, buffer, 0, 0);
    release_screen();
    
    rest(5);

}    
void draw_road( BITMAP *targ, BITMAP *blankMap, int x1, int y1, int x2, int y2 ) 
{
	int x[4], y[4];
	float c[4];

	float xx = (x2-x1);
	float yy = (y2-y1);

	// bezier control points
	x[0] = x1; y[0] = y1;
	x[1] = x1 + xx*0.25; y[1] = y1 + yy*0.25;
	x[2] = x1 + xx*0.75; y[2] = y1 + yy*0.75;
	x[3] = x2; y[3] = y2;

	// jitter the middle points
	int jitterAmt = 50;
	x[1] += random( -jitterAmt, jitterAmt ); y[1] += random( -jitterAmt, jitterAmt );
	x[2] += random( -jitterAmt, jitterAmt ); y[2] += random( -jitterAmt, jitterAmt );

	//circlefill( targ, x[1], y[1], 5, makecol( 0, 255, 255 ) );
	//circlefill( targ, x[2], y[2], 5, makecol( 0, 255, 255 ) );



	// draw the curve
	// c(t) = p0 * (1-t)^3  + p1*3*t*(1-t)^2 + p2*3*t^2*(1-t) + p3*t^3
	float steps = sqrt( xx*xx + yy*yy ) / 2.0;
	int lastx = x1, lasty = y1;
	float xt, yt;
	for (int pass=0; pass <2; pass++) {
		for (float t=0.0; t < 1.0; t += (1.0/steps) ) {
			c[0] = pow( (1.0-t), 3.0 );
			c[1] = 3.0*t*pow( (1.0-t), 2.0 );
			c[2] = 3.0*pow(t, 2.0)*(1.0-t);
			c[3] = pow( t, 3.0 );

			xt = x[0]*c[0] + x[1]*c[1] + x[2]*c[2] + x[3]*c[3];
			yt = y[0]*c[0] + y[1]*c[1] + y[2]*c[2] + y[3]*c[3];

			//line( targ, lastx, lasty, (int)xt, (int)yt, makecol( 0, 255, 255 ) );

			if (pass==0) {
				circlefill( targ, (int)xt, int(yt), 4+random(2), makecol( 115, 41, 2 ) );		
			} else {
				circlefill( targ, (int)xt, int(yt), 2+random(2), 
					getpixel( blankMap, (int)xt, (int)yt ) );
			}

			lastx = (int)xt; lasty = (int)yt;
		}
	}



}
Exemple #6
0
void Editor::draw()
{
  // Background
  rectfill(buffer, 0, 0, SCREEN_W, SCREEN_H, makecol(255,255,255));

  if( saving){
    //Create gui
    textprintf_centre_ex(buffer,font,640,310, makecol(0,0,0),-1,"Save Map Name");

    //Input rectangle
    rectfill(buffer, 400, 408, 892, 452, makecol(0,0,0));
    rectfill(buffer, 402, 410, 890, 450, makecol(255,255,255));

    // Output the string to the screen
    textout_ex(buffer, font, edittext.c_str(), 410, 410, makecol(0,0,0), -1);

    // Draw the caret
    vline(buffer, text_length(font, edittext.c_str()) + 410 - text_length(font, ".txt") , 412, 448, makecol(0,0,0));
  }
  else if( opening){
    //Create gui
    textprintf_centre_ex(buffer,font,640,310, makecol(0,0,0),-1,"Open Map Name");

    //Input rectangle
    rectfill(buffer, 400, 408, 892, 452, makecol(0,0,0));
    rectfill(buffer, 402, 410, 890, 450, makecol(255,255,255));

    // Output the string to the screen
    textout_ex(buffer, font, edittext.c_str(), 410, 410, makecol(0,0,0), -1);

    // Draw the caret
    vline(buffer, text_length(font, edittext.c_str()) + 410 - text_length(font, ".txt") , 412, 448, makecol(0,0,0));
  }
  else{
    // Draw tiles
    tile_map -> draw_map( buffer);
    exampleTile -> draw_tile( buffer, 0, 0, 0);

    // Map info
    textprintf_ex(buffer,font,0,80,makecol(255,255,255),makecol(0,0,0),"height-%i width-%i", tile_map -> height, tile_map -> width);

    if(layer == 1){
      textprintf_ex(buffer,font,0,130,makecol(255,255,255),makecol(0,0,0),"Editing Mode: Foreground");
    }
    else if(layer == 0){
      textprintf_ex(buffer,font,0,130,makecol(255,255,255),makecol(0,0,0),"Editing Mode: Background");
    }

    // Cursor
    circlefill(buffer, mouse_x , mouse_y , 10, makecol(0,0,0));
    circlefill(buffer, mouse_x , mouse_y, 8, makecol(255,255,255));
  }
  // Draw buffer
  stretch_sprite( screen, buffer, 0, 0, SCREEN_W, SCREEN_H);
}
Exemple #7
0
void explosion2(BITMAP *bmp, int x,int y,int finalcolor)
{
     int color,size;
     for (n=0; n<20; n++)
     {
                color = makecol(rand()%255,rand()%255,rand()%255);
                size = 20+rand()%20;
                circlefill(bmp, x, y, 350, color);
                rest(2);
     }
     circlefill(bmp, x, y, 350, finalcolor);
}
Exemple #8
0
void bubbles()
{
     int r, c, b;
     int size;
     int centerx, centery;
     int outradius, inradius, midradius;
     int bubblesx, bubblesy; /* number of bubbles in a row or column */
     int numbubbles;

     clear_invert_map();

     /*
     * outer is the main bubble
     * inner is the black dot in the bubble
     * what's the middle??
     */

     size = (map.sec_width > map.sec_height ? map.sec_width : map.sec_height);
     outradius = rand_num(size/3, size);
     inradius  = rand_num(outradius/1.5, outradius*(7.0/8.0));
     midradius = (outradius + inradius) / 2;

     midradius = (midradius == 0 ? 1 : midradius);


     bubblesx = map.sec_width  / midradius;
     bubblesy = map.sec_height / midradius;
     numbubbles = (bubblesx * bubblesy);

     numbubbles = (numbubbles == 0 ? 1 : numbubbles);


     for( r = 0; r < map.num_row; r++ )
     {
          for( c = 0; c < map.num_col; c++ )
          {
               for( b = 0; b < numbubbles; b++ )
               {
                    rand_point_section_offset(&centerx, &centery, r, c, 0);

                    /*
                    *centerx *= (centerx / bubblesx);
                    *centery *= (centery / bubblesy);
                    */

                    circlefill(map.map, centerx, centery, outradius, 255);
                    circlefill(map.map, centerx, centery, inradius, 0);
               }
          } /* for(c..) */
     } /* for(r..) */

return;
}
Exemple #9
0
void AllegroGUIRenderer::fillRoundedRect(int x, int y, int width, int height,
  int radius, const GUIColor& color)
{
    adjustPoint(x, y);
    circlefill(target, x+radius, y+radius, radius, color);
    circlefill(target, x+width-radius-1, y+radius, radius, color);
    circlefill(target, x+radius, y+height-radius-1, radius, color);
    circlefill(target, x+width-radius-1, y+height-radius-1, radius, color);
    rectfill(target, x, y+radius, x+radius, y+height-radius-1, color);
    rectfill(target, x+width-radius, y+radius, x+width-1, y+height-radius-1, color);
    rectfill(target, x+radius, y, x+width-radius-1, y+height-1, color);
}
void Explosion::draw(const GraphicsContext &gc)
{
	int x = getx() - parent->getViewPort()->getx();
	int y = gety() - parent->getViewPort()->gety();

	drawing_mode (DRAW_MODE_TRANS, NULL, 0, 0);
	set_trans_blender (0, 0, 0, 128);

	circlefill (gc.buffer, x, y, size, RED);
	circlefill (gc.buffer, x, y, size * 2 / 3, YELLOW);

	drawing_mode (DRAW_MODE_SOLID, NULL, 0, 0);
}
Exemple #11
0
void drawingThings() {
    makeScreenBlack();

    // draw the bricks
    for(int i=0;i<BRICKS_VERTICALLY;i++) {
      for(int ii=0;ii<BRICKS_HORIZONTALLY;ii++) {
        if(bricks[i][ii] != 0) {
          rectfill(screenBuffer, 
            ii*BRICK_WIDTH, i*BRICK_HEIGHT, 
            (ii+1)*BRICK_WIDTH-BRICK_GAP, (i+1)*BRICK_HEIGHT-BRICK_GAP, 
            makecol(255, 0, 0));
        }
      }
    }

    // draw the player
    circlefill(screenBuffer, 
          ball.x, ball.y, 
          8, makecol(255, 255, 0));

    // draw the player
    rectfill(screenBuffer, 
          playerPaddleEdgeX, PADDLE_POSITION_Y, 
          playerPaddleEdgeX+PADDLE_WIDTH, 
          PADDLE_POSITION_Y+PADDLE_HEIGHT, makecol(255, 255, 255));
          
    textprintf_ex(screenBuffer, font, 10, 10, makecol(255, 255, 0),
                    -1, "Player Position (playerPaddleEdgeX is %i)", playerPaddleEdgeX);
    textprintf_ex(screenBuffer, font, 10, 20, makecol(255, 255, 255),
                    -1, "ball (x,y) position is (%i, %i)", ball.x, ball.y);

}
Exemple #12
0
void Bola::desenhaBola(BITMAP *buffer){//, Ponto p){
	int r, g, b;
	int d = getD();
	Ponto p = getP();
	Cor_bola c = getCor();
	switch(c){
		case AMARELO:
			r = 255;
			g = 255;
			b = 0;
			break;
		case VERDE:
			r = 0;
			g = 255;
			b = 0;
			break;
		case AZUL:
			r = 0;
			g = 0;
			b = 255;
			break;
		default: // VERMELHO:
			r = 255;
			g = 0;
			b = 0;
			break;
	}
	circlefill(buffer, p.x, p.y, d/2, makecol(r, g, b));

}
Exemple #13
0
void Canhao::desenhaCanhao(BITMAP *buffer, bool podeRecarregar){
	if(!podeRecarregar) return;
	Cor_bola c = proxBola->getCor();
	int r, g, b;

	switch(c){
		case AMARELO:
			r = 255;
			g = 255;
			b = 0;
			break;
		case VERDE:
			r = 0;
			g = 255;
			b = 0;
			break;
		case AZUL:
			r = 0;
			g = 0;
			b = 255;
			break;
		case VERMELHO:
			r = 255;
			g = 0;
			b = 0;
			break;
		default:
			r = 0;
			g = 0;
			b = 0;
	}

	circlefill(buffer, proxBola->getP().x, proxBola->getP().y, proxBola->getD()/2, makecol(r, g, b));

}
Exemple #14
0
void draw_bloodpools(void)
{
	int i;
	float j;
	float dec;
	float alpha;
	float temp;

	for(i=0;i<BLOODPOOL_NUM;i++)
		if(bloodpool[i].used)
			if(object_is_in_player_los(bloodpool[i].x-bloodpool[i].size, bloodpool[i].y-bloodpool[i].size, bloodpool[i].size*2,bloodpool[i].size*2,0,0))
			{
				temp = bloodpool[i].size*0.5;
				
				circlefill(virt, bloodpool[i].x-map_x, bloodpool[i].y-map_y, temp*2, bloodpool[i].color );

				dec = (255)/(bloodpool[i].size*0.5);
				alpha = 255;

			 
				drawing_mode(DRAW_MODE_TRANS,NULL,0,0);
				for(j=temp;j<bloodpool[i].size;j+=1)
				{
					set_trans_blender(0,0,0,(int)alpha);
					circle(virt, bloodpool[i].x-map_x, bloodpool[i].y-map_y, temp+j, bloodpool[i].color);
					alpha-=dec;
					if(alpha<0)alpha=0;
				}
				drawing_mode(DRAW_MODE_SOLID,NULL,0,0);
			}
}
Exemple #15
0
int main(void)
{
    BITMAP *tmp;

    allegro_init();
    install_keyboard();

    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);

    /* set up a temp bitmap to so we can fade back later */
    if (!(tmp = create_bitmap(SCREEN_W, SCREEN_H))) exit(1);
    
    /* create a test screen */
    rectfill(screen, 0,0, SCREEN_W,SCREEN_H, makecol(255,255,255));
    circlefill(screen, 75,75, 25, makecol(255,0,0));

    /* save this test screen so we can fade_in to it later */
    blit(screen, tmp, 0,0, 0,0, SCREEN_W, SCREEN_H);
    readkey();
    
    highcolor_fade_out(16);
    readkey();

    highcolor_fade_in(tmp, 16);
    readkey();

    destroy_bitmap(tmp);
    return 0;
}
Exemple #16
0
int main(){
    
    declarevalues();
 
 
    allegro_init();
    install_keyboard();
    install_mouse();
    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, Screen.getwidth(), Screen.getheight(), 0, 0);
    
    buffer = create_bitmap(Screen.getwidth(), Screen.getheight());


Loadproperties();


while (!key[KEY_ESC]) // Here is the game loop.
{

    declarearray();
    create_world();
     
     
     circlefill(buffer, mouse_x, mouse_y, 5, makecol(255, 0, 0));
    
    
        textprintf_ex(buffer, font, 10, 10, makecol(255, 100, 200), -1, "%s", testchar.testname.c_str() );
        
               
    blit(buffer, screen, 0, 0, 0, 0, Screen.getwidth(), Screen.getheight());
    clear_bitmap(buffer);
}   
    return 0;   
}   
void make_circle(BITMAP *dest, KOORD *city)
{
    int x, y;
    x = (int) city->x;
    y = (int) city->y;
    circlefill(dest, x+2, y+2, RADIUS, makecol(0, 255, 0));
}
Exemple #18
0
void Menu::draw(BITMAP *bmp)
{
    static char *options[4] = { "play", "widescreen", "fullscreen", "quit" };
    int x = 32;
    int y = 64;

    clear_to_color(bmp, makecol(0, 0, 32));

    masked_stretch_blit(m_logo, bmp, 0, 0, m_logo->w, m_logo->h, 2, 2, m_logo->w*2, m_logo->h*2);

    for (int c=0; c<m_options; ++c) {
        Menu::draw_item(bmp, x, y, options[c], (m_selected == c));
        if ((c == 1 && gfx_widescreen) ||
                (c == 2 && gfx_fullscreen))
            circlefill(bmp, x-8, y+6, 2, makecol(190, 0, 0));
        y += 12;
        x -= 2;
    }

    draw_text_r(bmp, bmp->w-3, bmp->h-14, makecol(0, 180, 200), "(C) 2007 David Capello");

    draw_sprite(bmp, MEDIA_BITMAP(DISQUAL_PCX),
                bmp->w-32-MEDIA_BITMAP(DISQUAL_PCX)->w,
                bmp->h/2-MEDIA_BITMAP(DISQUAL_PCX)->h);
}
void Background::init()
{
	texture = create_bitmap (TILEW, TILEH);
	assert (texture);

	int c1 = WHITE;
	int c2 = GREY;
	clear_to_color (texture, c1);
	circlefill(texture, TILEW / 2, TILEW / 2, 60, c2);
	circlefill (texture, TILEW / 2, TILEH / 2, 30, c1);
	
	drawing_mode (DRAW_MODE_TRANS, NULL, 0, 0);
	set_trans_blender (0, 0, 0, 160);
	rectfill (texture, 0, 0, TILEW, TILEH, BROWN);
	solid_mode();
}
Exemple #20
0
/* draws one of the path nodes */
void draw_node(int n)
{
   circlefill(screen, nodes[n].x, nodes[n].y, 2, palette_color[1]);

   textprintf_ex(screen, font, nodes[n].x-7, nodes[n].y-7,
		 palette_color[255], -1, "%d", n);
}
TileMap *create_bubble( std::vector<TileMap*> &landChunks )
{
	int ndx = ((float)rand() / (float)RAND_MAX) * landChunks.size();
	TileMap *bub = new TileMap( landChunks[ndx]->m_size );
	bub->bub_age = (float)rand() / (float)RAND_MAX;

	bub->paste( landChunks[ndx], 0, 0 );

	int sz = bub->m_size * 12;
	BITMAP *tmpBmp = create_bitmap( sz, sz );
	rectfill( tmpBmp, 0, 0, sz, sz, makecol( 0xff, 0x00, 0xff) );

	bub->draw( tmpBmp, 0, 0, emptyObjs );

	bub->bub_bmp = create_bitmap( 20, 20 );
	stretch_blit( tmpBmp, bub->bub_bmp, 0, 0, 
	  		  	  tmpBmp->w, tmpBmp->h, 0, 0, 
				bub->bub_bmp->w, bub->bub_bmp->h );
	destroy_bitmap( tmpBmp );

	circle( bub->bub_bmp, 10, 10, 9, makecol( 0x66, 0xee, 0xff ) );
	circlefill( bub->bub_bmp, 6, 6, 2, makecol( 0xff, 0xff, 0xff ) );

	hline( bub->bub_bmp, 2, 17, 18, makecol( 155, 193, 212 ) );
	hline( bub->bub_bmp, 2, 18, 18, makecol( 0xff, 0x00, 0xff ) );
	hline( bub->bub_bmp, 2, 19, 18, makecol( 0xff, 0x00, 0xff ) );

	return bub;
}
Exemple #22
0
void circuit()
{
     int r, c;
     int do_cut;
     int radius;
     int centerx, centery;


     clear_invert_map();

     grid = (char **) new_grid(map.num_row, map.num_col, sizeof(char));
     count = (int *) new_array(map.num_row, sizeof(int));

     radius = (map.sec_width > map.sec_height ? map.sec_width : map.sec_height)/4.0;
     radius = (radius == 0 ? 1 : radius );

     line_size = (map.sec_width > map.sec_height ? map.sec_width : map.sec_height)/4.0;
     line_size = (line_size == 0 ? 1 : line_size);

     for( r = 0; r < map.num_row; r++ )
     {
          count[r] = 0;
          for( c = 0; c < map.num_col; c++ )
          {
               if( (r == 0 || r == map.num_row-1)
               && (c == 0 || c == map.num_col/2 || c == map.num_col-1) )
                    do_cut = 1;
               else
                    do_cut = rand()%4;

               if( do_cut != 1 )
               {
                    grid[r][c] = 0;
                    continue;
               }

               section_center(&centerx, &centery, r, c);
               circlefill(map.map, centerx, centery, radius, 255);

               grid[r][c] = 1;
               count[r]++;
          }
     }


     connect_rows();
     connect_front();
     connect_back();
     connect_mid();

     delete_grid((void **)grid, map.num_row);
     delete_array(count);

     /* redraw outline */
     /* TODO: once in a while if cuts off the edge.. */
     rect(map.map, 0, 0, map.width-1, map.height-1, 0);

return;
}
Exemple #23
0
//The default RADAR.  Shows ships, planets, and asteroids.
void ZRadar::Paint(BITMAP *Slate, Vector2 T)
{
	STACKTRACE;
	for(std::list<SpaceLocation*>::iterator i=physics->item.begin();i!=physics->item.end();i++) {
		int xpos=0,ypos=0;

		SpaceLocation *o=*i;
		double Scale = Slate->w/(2.*size);

		xpos=(int)shiftscale(T.x,Slate->w/2,Scale,o->pos.x);
		ypos=(int)shiftscale(T.y,Slate->w/2,Scale,o->pos.y);

		if (o->isShip())           circle(Slate,xpos,ypos,2,makecol(255,0,0));
		else if (o->isAsteroid())  circlefill(Slate,xpos,ypos,1,makecol(174,131,66));
		else if (o->isPlanet())        circlefill(Slate,xpos,ypos,4,makecol(200,200,200));
	}
}
void PrimaryWindow::RenderBall()
{
    if (!ballAlive_)
    {
        return;
    }

	circlefill(_backBuffer, (int)ballX_, (int)ballY_, ballRadius_, ballColor_);
}
Exemple #25
0
+=j!=I&&i!=J&&i!=I&&j!=J&&*c(I,J)&&q(p(i),p(j),p(I),p(J));return f;}main(){int i
,I,j,J,f,F,a,b,s=-1,X,Y,H,h;BITMAP*B;SAMPLE*S;allegro_init();*c(0,1)=*c(0,2)=*c(
0,3)=1;set_gfx_mode(GFX_AUTODETECT_WINDOWED,w,w,0,0);install_sound(DIGI_DIRECTX(
0),MIDI_NONE,0);B=create_bitmap(w,w);install_keyboard();install_mouse();*c(2,3)=
*c(1,2)=*c(1,3)=1;text_mode(-1);S=create_sample(8,0,9999,9999);for(i=0;i<9999;i
++){((unsigned char*)S->data)[i]=(((i+(fixsin(i<<13)>>13))%100+(i)%152)*i)/9000;
}for(l=4;l<99;l++){play_sample(S,255,55,1600,0);play_sample(S,255,200,1604,0);
for(i=0;i<l;i++){x[i]=((fixcos((i<<24)/l)*w/3)>>16)+w/2;y[i]=((fixsin((i<<24)/l)
*w/3)>>16)+w/2;}do{F=0;key[KEY_ESC]?exit(0):0;clear_to_color(B,15);for(i=0;i<l;i
++){for(j=0;j<l;j++){f=0;if(*c(j,i)){f=M(i,j);for(a=-1;a<2;a++)for(b=-1;b<2;b++)
line(B,a+p(i)+b,a+p(j)+b,f?12:10);}F|=f;}}for(i=0;i<l;i++){circlefill(B,p(i),8,0
);circlefill(B,p(i),6,s==i?7:8);s=mouse_b?s:-1;if(mouse_b&&s<0&&_(mouse_x-x[i],-
7,7)&&_(mouse_y-y[i],-7,7))s=i;}if(s>=0){x[s]=mouse_x;y[s]=mouse_y;}textprintf(B
,font,10,10,0,"Level %d",l-3);draw_sprite(B,mouse_sprite,mouse_x,mouse_y);blit(B
,screen,0,0,0,0,w,w);}while(F||mouse_b);H=0;for(j=0;j<2000;j++){h=0;x[l]=rand()%
w*2-w/2;y[l]=rand()%w*2-w/2;for(i=0;i<l;i++){h+=M(i,l)==0;}if(h>H){H=h;X=x[l];Y=
y[l];}}x[l]=X;y[l]=Y;for(i=0;i<l;i++){*c(i,l)=M(i,l)==0;*c(rand()%l,rand()%l)=0;
}}}END_OF_MAIN();///////////////////////////////////////////////////////////////
void		snakeAllegro::displayMap(map_t const &map)
{
  t_mapiter	iter;

  rectfill(screen, 0, 0, this->_height * 50, this->_width * 50, this->_colorMap);
  for (iter = map.snake.begin(); iter != map.snake.end(); iter++)
    {
      if (iter == map.snake.begin())
	circlefill(screen, ((*iter).x * 50) + 25 , ((*iter).y * 50) + 25, 25, this->_colorHead);
      else
	circlefill(screen, ((*iter).x * 50) + 25, ((*iter).y * 50) + 25, 25, this->_colorSnake);
    }
  for (iter = map.others.begin(); iter != map.others.end(); iter++)
    {
      if ((*iter).type == Case::FOOD)
	circlefill(screen, ((*iter).x * 50) + 25, ((*iter).y * 50) + 25, 10, this->_colorSnake);
    }
}
void Basic_char::DrawTrail( BITMAP * buffer ) // DRAW THE PARTICLE TRAIL
{

	for( int i = 0; i <= 5; i++ )
	{
		circlefill( buffer, trailArr[i][0], trailArr[i][1], i*5 + trailTimer, circle_color ); // 4TH PARAMETER - THE RADIUS DEPENDS ON THE PLACE IN THE ARRAY
	}

}
Exemple #28
0
void shape_menu()
{
 circle( screen, 50, 20, 20, makecol( 0,0,255));
 circlefill( screen, 50, 80, 20, makecol( 0,0,255));

 rect( screen,10,120,90,160,makecol( 0,0,255));
 rectfill( screen, 10, 180, 90, 220,makecol( 0,0,255));

 line( screen, 110, 0, 110, 479,makecol( 255,255,255));
}
void Basic_char::Draw( DATAFILE * sprites, BITMAP * buffer  )
{

    if ( alive )
    {
    circlefill( buffer, x, y, 32+bubbles_collected*10, circle_color ); // DRAW THE FILLED CIRCLE
	masked_blit( (BITMAP*)sprites[1].dat, buffer, 0, 0, x - 24, 700 - 8, 48, 16); // DRAW SHADOW
    circle( buffer, x, y, 32+bubbles_collected*10, makecol( 64, 186, 217 ) ); // DRAW THE OUTLINE
    masked_blit( (BITMAP*)sprites[0].dat, buffer, (int)anim_frame*64, is_breathing*64, x-32, y-32, 64, 64 ); // DRAW THE FACE
    }
}
void BarCounter::paint() {
	if(loader->needsDisplay())
		return;
	scare_mouse();
	for(int i = 0; i < 4; i++) {
		int c = (bars==i)?COLOR_BAR_PASSED:COLOR_BAR_DUE;
		circlefill(screen, x + 23 * i, y, 10, c);
		circle(screen, x + 23 * i, y, 10, 0);
	}
	unscare_mouse();
}