Esempio n. 1
0
void DrawObject(BITMAP *target,
	BITMAP *bitmap,
	float angle,
	float objectX,
	float objectY,
	float cameraX,
	float cameraY,
	Params params)
{
	float newObjectX = objectX - cameraX;
	float newObjectY = objectY - cameraY;

	float spaceX = (newObjectX * cos(angle)) + (newObjectY * sin(angle));
	float spaceY = (-(newObjectX * sin(angle))) + (newObjectY * cos(angle));

	int screenX = target->w / 2 + ((params.scaleX / spaceX) * spaceY);
	int screenY = ((params.spaceZ * params.scaleY) / spaceX) - params.horizon;

	screenY*=2;

	int width = bitmap->w * (params.objScaleX / spaceX);
	int height = bitmap->h * (params.objScaleY / spaceX);

	stretch_sprite(target, bitmap, screenX - width / 2, screenY - height, width, height);
}
Esempio n. 2
0
/* draw_object just draws a single object at a fixed position, although
this can easily be modified to allow for more objects.
bmp = bitmap to draw to. obj = sprite for the object.
angle, cx, cy define the camera position.
*/
void draw_object (BITMAP *bmp, BITMAP *obj, fixed angle, fixed cx, fixed cy, MODE_7_PARAMS params)
{
    int width, height;
    int screen_y, screen_x;

    // The object in this case is at a fixed position of (160, 100).
    // Calculate the position relative to the camera.
    fixed obj_x = itofix(160) - cx;
    fixed obj_y = itofix(100) - cy;

    // use a rotation transformation to rotate the object by the camera
    // angle
    fixed space_x = fmul (obj_x, fcos (angle)) + fmul (obj_y, fsin (angle));
    fixed space_y = -fmul (obj_x, fsin (angle)) + fmul (obj_y, fcos (angle));

    // calculate the screen coordinates that go with these space coordinates
    // by dividing everything by space_x (the distance)
    screen_x = bmp->w/2 + fixtoi (fmul (fdiv (params.scale_x, space_x), space_y));
    screen_y = fixtoi (fdiv (fmul (params.space_z, params.scale_y), space_x)) - params.horizon;

    // the size of the object has to be scaled according to the distance
    height = fixtoi (obj->h * fdiv(params.obj_scale_y, space_x));
    width = fixtoi (obj->w * fdiv(params.obj_scale_x, space_x));

    // draw the object
    stretch_sprite (bmp, obj, screen_x - width / 2, screen_y - height, width, height);
}
Esempio n. 3
0
void draw_display_bitmap(display_item *pDI, int undo, BITMAP *pScreen, RECT *pRect)
{
	BITMAP *pContents = (BITMAP*) pDI->pContents;
	BITMAP *pOldContents = pDI->pOldContents;
	BITMAP *p = (BITMAP*) (undo?pOldContents:pContents);
	RECT r = {pDI->x, pDI->y, undo?p->w:pDI->is_scaled?pDI->w:p->w, undo?p->h:pDI->is_scaled?pDI->h:p->h};
	RECT tmp_r;

	// dirty rectangle.
	if (pRect)
	{
		rect_copy(&tmp_r, pRect);

		if (pRect->x == -1)
		{
			rect_copy(pRect, &r);
		} else {
			rect_combine(pRect, &tmp_r, &r);
		}
	}

	if (undo)
	{
		// draw it
		if (pDI->is_saving)
			blit(pOldContents, pScreen, 0, 0, pDI->x, pDI->y, pOldContents->w, pOldContents->h);
	} else {
		// draw it.
		if (pDI->is_scaled)
		{
			if (pDI->is_saving)
				blit(pScreen, pOldContents, pDI->x, pDI->y, 0, 0, pDI->w, pDI->h);

			if (pDI->is_sprite)
			{
				stretch_sprite((BITMAP*) pContents, pScreen, pDI->x, pDI->y, pDI->w, pDI->h);
			} else {
				stretch_blit((BITMAP*) pContents, pScreen, 0, 0, pContents->w, pContents->h, pDI->x, pDI->y, pDI->w, pDI->h);
			}
		} else {
			if (pDI->is_saving)
				blit(pScreen, pOldContents, pDI->x, pDI->y, 0, 0, pContents->w, pContents->h);

			if (pDI->is_sprite)
			{
				draw_sprite(pScreen, pContents, pDI->x, pDI->y);
			} else
			if (pDI->is_translucent)
			{
				pDI->pParent->display_prev_table = color_map;
				color_map = pDI->type==DISPLAY_LIGHT?pDI->pParent->display_light_table:pDI->pParent->display_trans_table;
				draw_trans_sprite(pScreen, pContents, pDI->x, pDI->y);
				color_map = pDI->pParent->display_prev_table;
			} else {
				blit(pContents, pScreen, 0, 0, pDI->x, pDI->y, pContents->w, pContents->h);
			}
		}
	}
}
Esempio n. 4
0
// Fade in
void highcolor_fade_in(BITMAP* bmp_orig, int speed){
  BITMAP* bmp_buff = create_bitmap(SCREEN_W,SCREEN_H);
  BITMAP* str_orig = create_bitmap( SCREEN_W, SCREEN_H);
  stretch_sprite( str_orig, bmp_orig, 0, 0, SCREEN_W, SCREEN_H);

  if ( speed<=0)
    speed=16;

  for(int a=0; a<256; a+=speed){
    clear( bmp_buff);
    set_trans_blender( 0, 0, 0, a);
    draw_trans_sprite( bmp_buff, str_orig, 0, 0);
    vsync();
    stretch_sprite( screen, bmp_buff, 0, 0,  SCREEN_W, SCREEN_H);
  }
  stretch_sprite( screen, str_orig, 0, 0,  SCREEN_W, SCREEN_H);
}
Esempio n. 5
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);
}
Esempio n. 6
0
int d_aphoton_icon_proc(int msg, DIALOG *d, int c)
{
    if (msg == MSG_DRAW) {
	BITMAP *img = (BITMAP *)d->dp;
	
	photon_container(screen, d->x, d->y, d->w, d->h);
	
	stretch_sprite(screen, img, d->x+2, d->y+2, d->w-4, d->h-4);	
	return D_O_K;
    }
    
    return d_aphoton_button_proc(msg, d, c);
}
Esempio n. 7
0
void show_gripdesign(void)
{
	BITMAP *bmp;
	BITMAP *bmp2;
	int end=0;
	int time=0;
	
	int alpha=255;


	bmp2 = load_bitmap("graphic/menu/logo.pcx",NULL);
	bmp = create_bitmap(480,480);
	
	stretch_sprite(bmp,bmp2,0,0,480,480);
		
	speed_counter = 0;
	

	while(!key[KEY_ESC] && !end)
	{
		
		while(speed_counter>0)
		{
			
			time++;

			if(time<350 && alpha>0)
				alpha-=2;

			if(alpha<0)alpha=0;

			if(time>350)
				alpha+=4;
			
			if(alpha>255)alpha=255;

			if(time>450)end=1;

			speed_counter--;
		}
		
		set_trans_blender(0,0,0,0);
		draw_lit_sprite(virt,bmp,0,0,alpha);
		vsync();
		blit(virt,screen,0,0,80,0,480,480);
	}

	destroy_bitmap(bmp);
	destroy_bitmap(bmp2);
}
Esempio n. 8
0
void Menu::draw()
{
  // Draw background to screen
  rectfill( buffer, 0, 0, SCREEN_W, SCREEN_H, makecol( 255,255,255));

  // Draw live background
  tile_map -> draw_map(buffer);

  // Overlay
  draw_trans_sprite(buffer, credits, 0, 0);
  draw_trans_sprite(buffer, menu, 0, SCREEN_H-461);
  draw_trans_sprite(buffer, menuselect, selectorX, selectorY);

  // Level selection
  draw_trans_sprite(buffer, levelSelectLeft, SCREEN_W-180, 80);
  draw_trans_sprite(buffer, levelSelectNumber, SCREEN_W-160, 80);
  textprintf_centre_ex(buffer,font,SCREEN_W-112,73,makecol(0,0,0),-1,"%i",levelOn + 1);
  draw_trans_sprite(buffer, levelSelectRight, SCREEN_W-80, 80);

  // Hover select left
  if(collisionAny(mouse_x,mouse_x,SCREEN_W-180,SCREEN_W-140,mouse_y,mouse_y, 80, 120)){
    draw_trans_sprite(buffer, levelSelectLeft, SCREEN_W-180, 80);
  }
  // Hover select right
  if(collisionAny(mouse_x,mouse_x,SCREEN_W-80,SCREEN_W-40,mouse_y,mouse_y, 80, 120)){
    draw_trans_sprite(buffer, levelSelectRight, SCREEN_W-80, 80);
  }

  // Cursor
  draw_sprite(buffer, cursor[0], mouse_x, mouse_y);

  // Select button
  if (mouse_b & 1 || key[KEY_ENTER] || joy[0].button[0].b){
    if (selectorY==610){
      do{
        draw_sprite(buffer, menu, 0, 0);
        draw_sprite(buffer, help,0,0);
        draw_sprite(screen,buffer,0,0);
      }
      while(!key[KEY_ESC] && !mouse_b & 1 && !joy[0].button[0].b);
    }
  }
  if( menuOpen){
    draw_trans_sprite( buffer,help,0,0);
  }
  draw_trans_sprite(buffer,copyright,SCREEN_W-350,SCREEN_H-40);
  draw_sprite(buffer,cursor[0],mouse_x,mouse_y);
  // Draw buffer
  stretch_sprite( screen, buffer, 0, 0, SCREEN_W, SCREEN_H);
}
Esempio n. 9
0
void update(){
              draw_sprite( screen, buffer, 0, 0);
              draw_sprite( buffer, scene1, 0, 0);
              if(flip==0){draw_sprite(buffer,bobby, 600, 600); flip=1; loop=1;}
              if(flip==1 && loop==0){draw_sprite_h_flip(buffer,bobby, 600, 600); flip=0;}
              loop=0;
              
              angle=angle+5;                      
              rotate_sprite(buffer, bobby, 400, 600, itofix(angle));
              
              stretch_sprite(buffer, bobby, 500, 600, w, h);
              
              stretch_sprite(buffer, bobby, 300, 600, w, 50);
              
              stretch_sprite(buffer, bobby, 200, 600, 50, h);
              
              w++;
              h++;
              
              if(w==75){w=25;}
              if(h==75){h=25;}

              rest(100);
}
Esempio n. 10
0
void Bitmap::StretchBlt(Bitmap *src, const Rect &dst_rc, BitmapMaskOption mask)
{
	BITMAP *al_src_bmp = src->_alBitmap;
	// WARNING: For some evil reason Allegro expects dest and src bitmaps in different order for blit and draw_sprite
	if (mask == kBitmap_Transparency)
	{
		stretch_sprite(_alBitmap, al_src_bmp,
			dst_rc.Left, dst_rc.Top, dst_rc.GetWidth(), dst_rc.GetHeight());
	}
	else
	{
		stretch_blit(al_src_bmp, _alBitmap,
			0, 0, al_src_bmp->w, al_src_bmp->h,
			dst_rc.Left, dst_rc.Top, dst_rc.GetWidth(), dst_rc.GetHeight());
	}
}
Esempio n. 11
0
int
d_abitmap_icon_proc (int msg, DIALOG *d, int c)
{
	if (msg == MSG_DRAW) {
		int b = d->flags & D_SELECTED ? B_ICON_DOWN : B_ICON;
		int px = 0, py = 0;
		abitmap_draw_box (d, b);
		if (d->flags & D_SELECTED) {
			px = theme->textpushx;
			py = theme->textpushy;
		}
		stretch_sprite (gui_get_screen(), d->dp, d->x + 2 + px, d->y + 2 + py,
			d->w - 4 - px, d->h - 4 - py);
		return D_O_K;
	}
	return d_icon_proc (msg, d, c);
}
void Tilemap::Draw(BITMAP* buffer) // Uncomment the code in here to turn fog of war on
{
    for (int i=0; i<(int)tiles.size(); ++i) {
        for (int j=0; j<(int)tiles[i].size(); ++j) {
            //if (visible[i][j] > 0)
                tiles[i][j].Draw(buffer, Vector(tile_dim.XInt()*i, tile_dim.YInt()*j));
        }
    }
    draw_sprite(buffer, grid, 0, 0);

    for (int i=0; i<(int)tiles.size(); ++i) {
        for (int j=0; j<(int)tiles[i].size(); ++j) {
            //if (visible[i][j] == 256)
                tiles[i][j].DrawObjects(buffer, Vector(tile_dim.XInt()*i, tile_dim.YInt()*j));
            /*else {
                set_trans_blender(0, 0, 0, 256 - visible[i][j]);
                drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);
                rectfill(buffer, tile_dim.XInt()*i, tile_dim.YInt()*j, tile_dim.XInt()*(i+1)-1, tile_dim.YInt()*(j+1)-1,  Colour::Black());
                drawing_mode(DRAW_MODE_SOLID, 0, 0, 0);
            }*/
        }
    }

    if (need_to_draw_message) {
        int w = citizen_saved->w * message_scale;
        int h = citizen_saved->h * message_scale;
        int x = scr_w/2 - w/2;
        int y = scr_h/2 - h/2;
        stretch_sprite(buffer, citizen_saved, x, y, w, h);
    }

    if (need_to_draw_blood) {
        set_trans_blender(0, 0, 0, blood_alpha);
        drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);
        draw_trans_sprite(buffer, blood, 0, 0);
        drawing_mode(DRAW_MODE_SOLID, 0, 0, 0);
    }
    if (!need_to_draw_blood && need_fresh_blood && blood != NULL) {
        clear_to_color(blood, Colour::MagicPink());
        int how_many_splatters = 4 + rand() % 6;
        for (int i=0; i<how_many_splatters; ++i)
            draw_sprite(blood, GetBloodSplatter(), rand() % 540, rand() % 300);
        need_fresh_blood = false;
    }
}
Esempio n. 13
0
// Very, very slow ;p
void DrawMode7Stretched(BITMAP *target,
	BITMAP *bitmap,
	float angle,
	float cameraX,
	float cameraY,
	Params params,
	int backgroundColor
	)
{
	int screenX, screenY;

	float distance, horizontalScale;

	int temp1 = bitmap->w - 1;
	int temp2 = bitmap->h - 1;

	float lineDX, lineDY;
	float spaceX, spaceY;

	static BITMAP *temp;
	if (!temp)
		temp = create_bitmap(SCREEN_W / 2, SCREEN_H / 2);

	floodfill(temp, 0, 0, backgroundColor);

	for (screenY = -params.horizon; screenY < temp->h; screenY++) {
		distance = (params.spaceZ * params.scaleY) / (screenY + params.horizon);
		horizontalScale = (distance / params.scaleX);
		lineDX = -sin(angle) * horizontalScale;
		lineDY = cos(angle) * horizontalScale;
		spaceX = cameraX + (distance * cos(angle)) - temp->w * lineDX;
		spaceY = cameraY + (distance * sin(angle)) - temp->w * lineDY;

		for (screenX = 0; screenX < temp->w; screenX++) {
			if ((spaceX<temp1) && (spaceY<temp2) && (spaceX>0) && (spaceY>0))
				putpixel(temp, screenX, screenY, getpixel(bitmap, spaceX, spaceY));

			spaceX += lineDX + lineDX;
			spaceY += lineDY + lineDY;
		}			
	}

	stretch_sprite(target, temp, 0, 0, SCREEN_W, SCREEN_H);
	clear(temp);
}
Esempio n. 14
0
// Fade out
void highcolor_fade_out(int speed){
  BITMAP* bmp_buff = create_bitmap(SCREEN_W,SCREEN_H);
  BITMAP *bmp_orig = create_bitmap( SCREEN_W, SCREEN_H);
  blit(screen,bmp_orig,0,0,0,0,SCREEN_W,SCREEN_H);

  if ( speed<=0)
    speed=16;

  for( int a=255 - speed; a>0; a-=speed){
    clear( bmp_buff);
    set_trans_blender( 0, 0, 0, a);
    draw_trans_sprite( bmp_buff, bmp_orig, 0, 0);
    vsync();
    stretch_sprite( screen, bmp_buff, 0, 0,  SCREEN_W, SCREEN_H);
  }
  destroy_bitmap( bmp_orig);
  rectfill( screen, 0, 0,  SCREEN_W, SCREEN_H, makecol(0,0,0));
}
Esempio n. 15
0
// Draw
void comet::draw( BITMAP* tempBitmap){
  if(!isDead){
    if(image[0] != NULL){
      stretch_sprite( tempBitmap, image[0], x, y, width, height);
    }
  }
  else{
  	if( particles_on){
	    for( int i = 0; i < debris.size(); i++){
	      debris.at(i).draw( tempBitmap);
	    }
	  }
	}

  if(debugMode){
    rect(tempBitmap, x, y, x + width, y + height, makecol(88, 88, 88));
  }
}
Esempio n. 16
0
int d_agtk_icon_proc(int msg, DIALOG *d, int c)
{
    if (msg == MSG_DRAW) {
        BITMAP *bmp = gui_get_screen();
        BITMAP *img = (BITMAP *)d->dp;
        int x;

        if (d->flags & D_SELECTED)
            x = 2;
        else if (d->flags & D_GOTFOCUS)
            x = 1;
        else
            x = 0;
        gtk_box(bmp, d->x, d->y, d->w, d->h, x, d->flags & D_GOTFOCUS);

        stretch_sprite(bmp, img, d->x+2, d->y+2, d->w-4, d->h-4);
        return D_O_K;
    }

    return d_agtk_button_proc(msg, d, c);
}
Esempio n. 17
0
void Game::draw( bool toScreen)
{
  // Black background (just in case)
  rectfill( buffer, 0, 0, 1280, 960, makecol(0,0,0));

  // Draw tiles
  tile_map -> draw_map(buffer);

  // Draw enemies
  for(int i = 0; i < badGuy.size(); i++){
    badGuy.at(i) -> draw(buffer, tile_map -> x, tile_map -> y);
  }

  // Draw character
  character.draw(buffer, tile_map -> x, tile_map -> y);

  // Draw buffer
  if( toScreen){
    stretch_sprite( screen, buffer, 0, 0, SCREEN_W, SCREEN_H);
  }
}