void _al_win_set_display_icon(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bmp)
{
   ALLEGRO_BITMAP *sm_bmp, *big_bmp;
   HICON sm_icon, big_icon, old_small, old_big;
   ALLEGRO_DISPLAY_WIN *win_display = (ALLEGRO_DISPLAY_WIN *)display;
   ALLEGRO_STATE backup;
   int sm_w, sm_h, big_w, big_h;

   al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER);

   al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
   al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888);

   sm_w = GetSystemMetrics(SM_CXSMICON);
   sm_h = GetSystemMetrics(SM_CYSMICON);
   big_w = GetSystemMetrics(SM_CXICON);
   big_h = GetSystemMetrics(SM_CYICON);

   sm_bmp = al_create_bitmap(sm_w, sm_h);
   al_set_target_bitmap(sm_bmp);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
   al_draw_scaled_bitmap(bmp, 0, 0,
      al_get_bitmap_width(bmp),
      al_get_bitmap_height(bmp),
      0, 0, sm_w, sm_h, 0);

   big_bmp = al_create_bitmap(big_w, big_h);
   al_set_target_bitmap(big_bmp);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
   al_draw_scaled_bitmap(bmp, 0, 0,
      al_get_bitmap_width(bmp),
      al_get_bitmap_height(bmp),
      0, 0, big_w, big_h, 0);

   al_restore_state(&backup);

   sm_icon = _al_win_create_icon(win_display->window, sm_bmp, 0, 0, false, false);
   big_icon = _al_win_create_icon(win_display->window, big_bmp, 0, 0, false, false);

   old_small = (HICON)SendMessage(win_display->window, WM_SETICON,
      ICON_SMALL, (LPARAM)sm_icon);
   old_big = (HICON)SendMessage(win_display->window, WM_SETICON,
      ICON_BIG, (LPARAM)big_icon);

   if (old_small)
      DestroyIcon(old_small);
   if (old_big)
      DestroyIcon(old_big);

   al_destroy_bitmap(sm_bmp);
   al_destroy_bitmap(big_bmp);
}
Esempio n. 2
0
void MonopolyPlayer::animationLogic() {
	// If the player is moving, then increment the x value to the next frame.
	if(m_isMoving)
		m_sourceX += al_get_bitmap_width(m_image) / 3;
	else
		m_sourceX = 32;

	// Ensure the x value isn't outside the width of the image.
	//  If it is, reset it to 0.
	if(m_sourceX >= al_get_bitmap_width(m_image))
		m_sourceX = 0;

	// The y value is based upon the direction of the player.
	m_sourceY = m_dir;
}
void update_background(void)
{
   /* increase time */
   current_time += dt;

   /* calculate new offset from current current_time with some weird trig functions
      change the constants arbitrarily and/or add sin/cos components to
      get more complex animations */
   offx =
      (int)(1.4f * al_get_bitmap_width(tile) * sin(0.9f * current_time + 0.2f) +
            0.3f * al_get_bitmap_width(tile) * cos(1.5f * current_time - 0.4f));
   offy =
      (int)(0.6f * al_get_bitmap_height(tile) * sin(1.2f * current_time - 0.7f) -
            1.2f * al_get_bitmap_height(tile) * cos(0.2f * current_time + 1.1f));
}
Esempio n. 4
0
SpriteSeq SpriteUtil::process(const char * filename, ALLEGRO_COLOR delimiterColor) {

	#ifndef _AL_INIT_IMAGE_ADDON
	#define _AL_INIT_IMAGE_ADDON
	al_init_image_addon();
	#endif

	ALLEGRO_BITMAP *bitmap = al_load_bitmap(filename);

	SpriteSeq spriteSeq(bitmap, 0, 0);

	ALLEGRO_COLOR pixel, lastPixel;
	int lastSource = 0;

	for(int i = 0; i <al_get_bitmap_width(bitmap); i++) {

		pixel = al_get_pixel(bitmap, i, 0);

		if (memcmp(&pixel, &lastPixel, sizeof(ALLEGRO_COLOR))) {

			if (!memcmp(&pixel, &delimiterColor, sizeof(ALLEGRO_COLOR))) {

				i++; // current pixel is the red one, so, advance to next pixel
				
				if (spriteSeq.empty()) {

					spriteSeq.add(Sprite(bitmap, 0, 0, i, al_get_bitmap_height(bitmap)));

				} else {

					spriteSeq.add(Sprite(bitmap, lastSource, 0, i - lastSource, al_get_bitmap_height(bitmap)));
				}

				lastSource = i;
			}

		} else if(i == al_get_bitmap_width(bitmap) - 1) {

			spriteSeq.add(Sprite(bitmap, lastSource, 0, i - lastSource, al_get_bitmap_height(bitmap)));
		}

		lastPixel = pixel;
	}

	al_convert_mask_to_alpha(bitmap, al_map_rgba(255, 0, 0, 255));
	
	return spriteSeq;
}
Esempio n. 5
0
void Menu::GenerateBackground()
{
	backgroundindex = rand() % 3;

	if( background == nullptr )
    {
        background = al_create_bitmap( 1024, 512 );
    }
	DISPLAY->SetTarget( background );

	int iw = al_get_bitmap_width( GameResources::BackgroundTiles.at(backgroundindex) );
	int ih = al_get_bitmap_height( GameResources::BackgroundTiles.at(backgroundindex) );
	int bx = 0;
	int by = 0;

	al_hold_bitmap_drawing( true );
	while( by < 512 )
	{
		while( bx < 1024 )
		{
			al_draw_bitmap( GameResources::BackgroundTiles.at(backgroundindex), bx, by, 0 );
			bx += iw;
		}
		by += ih;
		bx = 0;
	}
	al_hold_bitmap_drawing( false );

	DISPLAY->ClearTarget();
}
Esempio n. 6
0
void    special_effects_update_before (void)
{
return;
	t_skin *skin = Skins_GetCurrentSkin();

	al_lock_bitmap(gui_buffer, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READWRITE);

	al_set_target_bitmap(gui_buffer);
	switch (skin->effect)
	{
		// BLOOD DROPS -------------------------------------------------------------
	case SKIN_EFFECT_BLOOD:
		for (int i = 0; i < MAX_BLOOD_DROP; i ++)
		{
			t_skinfx_particle* p = &g_skinfx_particles[i];
			if (p->v && p->save.a != 0)
				al_put_pixel(p->x, p->y, p->save);
		}
		break;
	case SKIN_EFFECT_HEARTS:
		// Save old graphics --------------------------------------------------
		const int w = al_get_bitmap_width(Graphics.Misc.Heart1);
		const int h = al_get_bitmap_height(Graphics.Misc.Heart1);
		for (int i = 0; i < MAX_HEARTS; i ++)
		{
			t_skinfx_particle* p = &g_skinfx_particles[i];
			al_draw_bitmap_region(hearts_save[i], 0, 0, w, h, p->x, p->y, 0x0000);
		}
		break;
	}
	al_unlock_bitmap(gui_buffer);
}
Player::Player() {

    std::string tmplocation("/tmp/player.png");

    this->dimensions = rectangle( { 0.0f, 0.0f, 0.0f, 0.0f });
    this->forces = point( { 0.0f, 0.0f });

    if (downloadResourceFromInternet(tmplocation,
            "http://force.mjay.me/spritesheetmegaman1.png") == 200) {
        this->sprite = al_load_bitmap(tmplocation.c_str());

        // Next, we make small bitmap.
        this->pImage = al_create_bitmap(60, 64);
        this->dimensions.width = al_get_bitmap_width(this->pImage);
        this->dimensions.height = al_get_bitmap_height(this->pImage);

        al_set_target_bitmap(this->pImage);

        // Make sure, its actually transparent, by creating an alpha channel
        // in the background.
        al_clear_to_color(al_map_rgb(255, 255, 255));
        al_convert_mask_to_alpha(this->pImage, al_map_rgb(255, 255, 255));

        al_draw_bitmap_region(this->sprite, this->dimensions.x,
                this->dimensions.y, this->dimensions.width,
                this->dimensions.height, 0, 0, 0);

    }
}
Esempio n. 8
0
DrawableBitmap::DrawableBitmap(const char* filename)
{
	scale = 1.0f;
	position = vec2(0.0f, 0.0f);

	rotation = 0.0f;

	bitmap = al_load_bitmap(filename);

	if(bitmap == NULL) {
		Print("Couldn't find image:");
		Print(filename);
	}
	else {
		size.x = al_get_bitmap_width(bitmap);
		size.y = al_get_bitmap_height(bitmap);
	}

	hasReflection = false;
	floatingHeight = 0.0f;

	localRotation = 0.0f;
	localScale = 1.0f;

	transparency = 255;

	tintR = 255;
	tintG = 255;
	tintB = 255;
}
Esempio n. 9
0
int main(int argc, char **argv)
{
	al_init();
	al_init_image_addon();

	al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_NO_PREMULTIPLIED_ALPHA);
	al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);

	ALLEGRO_BITMAP *tm = al_load_bitmap("tilemap.png");
	int w = al_get_bitmap_width(tm);
	int h = al_get_bitmap_height(tm);
	int wt = w / 16;
	int ht = h / 16;
	ALLEGRO_BITMAP *b = al_create_bitmap(16, 16);
	al_set_target_bitmap(b);

	for (int y = 0; y < ht; y++) {
		for (int x = 0; x < wt; x++) {
			al_clear_to_color(al_map_rgba_f(0, 0, 0, 0));
			al_draw_bitmap_region(tm, x*16, y*16, 16, 16, 0, 0, 0);
			char name[200];
			sprintf(name, "out/%d-%d.png", x, y);
			al_save_bitmap(name, b);
		}
	}
}
Esempio n. 10
0
static int win_choose_icon_bitmap(const int sys_w, const int sys_h,
   const int num_icons, ALLEGRO_BITMAP *bmps[])
{
   int best_i = 0;
   int best_score = INT_MAX;
   int i;

   for (i = 0; i < num_icons; i++) {
      int bmp_w = al_get_bitmap_width(bmps[i]);
      int bmp_h = al_get_bitmap_height(bmps[i]);
      int score;

      if (bmp_w == sys_w && bmp_h == sys_h)
         return i;

      /* We prefer to scale up smaller bitmaps to the desired size than to
       * scale down larger bitmaps.  At these resolutions, scaled up bitmaps
       * look blocky, but scaled down bitmaps can look even worse due to to
       * dropping crucial pixels.
       */
      if (bmp_w * bmp_h <= sys_w * sys_h)
         score = (sys_w * sys_h) - (bmp_w * bmp_h);
      else
         score = bmp_w * bmp_h;

      if (score < best_score) {
         best_score = score;
         best_i = i;
      }
   }

   return best_i;
}
bool Knight::logic() {
	Vector2 dir;

	float dist;
	bool ret = false;
	
	if (state == 3) return false;

	// Might do some randomness here. Set number in a member however
	if (state != 0) {
		if ((aniCount % 127) == 0) {
			target = Vector2(100 + ((width - 100 - al_get_bitmap_width(image)) * rand() / (RAND_MAX + 1.0)), (480 - al_get_bitmap_height(image)) * rand() / (RAND_MAX + 1.0));
		}

		// Was 157
		if ((aniCount % 67) == 0) {
			ret = true;
		}

		dir = target - pos;
		speed = dir.norm();
		pos += speed;
		dist = target.dst(pos);
		aniCount++;
	}

	return ret;
}
Esempio n. 12
0
void c_minimap::draw(void)
{
	if(!map_list.biome_map)
		return;

	al_draw_bitmap(minimap_bitmap, user_config.res_x - user_config.minimap_size, user_config.res_y - user_config.minimap_size, 0);

	int tempx =  bind_to_range(user_config.map_x + (user_config.map_width / 2) , al_get_bitmap_width(map_list.biome_map));
	int tempy =  bind_to_range(user_config.map_y + (user_config.map_height / 2) , al_get_bitmap_height(map_list.biome_map));

	al_draw_line(
		user_config.res_x - user_config.minimap_size,
		user_config.res_y - user_config.minimap_size + (tempy * scale),
		user_config.res_x,
		user_config.res_y - user_config.minimap_size + (tempy * scale),
		al_map_rgb(255,0,0), 0);
	al_draw_line(
		user_config.res_x - user_config.minimap_size + (tempx * scale),
		user_config.res_y - user_config.minimap_size,
		user_config.res_x - user_config.minimap_size + (tempx * scale),
		user_config.res_y,
		al_map_rgb(255,0,0), 0);
	al_draw_rectangle(
		user_config.res_x - user_config.minimap_size + ((tempx - ((float)user_config.map_width / 2.0)) * scale),
		user_config.res_y - user_config.minimap_size + ((tempy - ((float)user_config.map_height / 2.0)) * scale),
		user_config.res_x - user_config.minimap_size + ((tempx + ((float)user_config.map_width / 2.0)) * scale),
		user_config.res_y - user_config.minimap_size + ((tempy + ((float)user_config.map_height / 2.0)) * scale),
		al_map_rgb(255,0,0), 0);
}
Esempio n. 13
0
void _al_win_set_display_icon(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bmp)
{
   ALLEGRO_BITMAP *scaled_bmp;
   HICON icon, old_small, old_big;
   ALLEGRO_DISPLAY_WIN *win_display = (ALLEGRO_DISPLAY_WIN *)display;
   ALLEGRO_STATE backup;

   al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER);

   al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
   al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888);
   scaled_bmp = al_create_bitmap(32, 32);
   al_set_target_bitmap(scaled_bmp);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgb(255, 255, 255));
   al_draw_scaled_bitmap(bmp, 0, 0,
      al_get_bitmap_width(bmp),
      al_get_bitmap_height(bmp),
      0, 0, 32, 32, 0);

   al_restore_state(&backup);

   icon = _al_win_create_icon(win_display->window, scaled_bmp, 0, 0, false);

   old_small = (HICON)SendMessage(win_display->window, WM_SETICON,
      ICON_SMALL, (LPARAM)icon);
   old_big = (HICON)SendMessage(win_display->window, WM_SETICON,
      ICON_BIG, (LPARAM)icon);

   if (old_small)
      DestroyIcon(old_small);
   if (old_big)
      DestroyIcon(old_big);

   al_destroy_bitmap(scaled_bmp);
}
Esempio n. 14
0
static void     Skins_Background_Draw_Center(ALLEGRO_BITMAP *bmp)
{
    const int   pos_x = (gui.info.screen.x - al_get_bitmap_width(bmp)) >> 1;
    const int   pos_y = (gui.info.screen.y - al_get_bitmap_height(bmp)) >> 1;
    Skins_Background_Redraw_Grid();
	al_draw_bitmap(bmp, pos_x, pos_y, 0x0000);
}
Esempio n. 15
0
static void     Skins_Background_Draw_StretchInteger(ALLEGRO_BITMAP *bmp)
{
    int         size_x;
    int         size_y;
    int         factor = 0;

    // Find best fit factor
	const int w = al_get_bitmap_width(bmp);
	const int h = al_get_bitmap_height(bmp);
    do
    {
        factor += 1;
        size_x = (gui.info.screen.x - w * factor) / 2;
        size_y = (gui.info.screen.y - 2 * (gui.info.bars_height + 2) - h * factor) / 2;
    }
    while (size_x >= 0 && size_y >= 0);
    factor -= 1;

    // Draw grid
    Skins_Background_Redraw_Grid();

    if (factor == 0)
    {
        Msg(MSGT_USER, "%s", Msg_Get(MSG_Theme_Error_BG_Big));
        return;
    }

    {
        int sx = (gui.info.screen.x - w * factor) / 2;
        int sy = (gui.info.screen.y - 2 * (gui.info.bars_height + 2) - h * factor) / 2;
        sy += gui.info.bars_height + 2;
		al_draw_scaled_bitmap(bmp, 0, 0, w, h, sx, sy, w * factor, h * factor, 0x0000);
    }
}
Esempio n. 16
0
void gui_window_create(int length, int height)
{
    /* Variável representando a janela principal */
    window = NULL;
    boat = NULL;
    heart = NULL;

    /* Criamos a nossa janela - dimensões de largura x altura pixels */
    window = al_create_display(length, height);
    boat = al_load_bitmap("b3.png");
    heart = al_load_bitmap("heart.png");
    boat_height = al_get_bitmap_height(boat);
    boat_width = al_get_bitmap_width(boat);

    /* Preenchemos a janela de branco */
    al_clear_to_color(al_map_rgb(255, 255, 255));

    /* Atualiza a tela */
    al_flip_display();
    if (!event_queue)
    {
        fprintf(stderr, "Falha ao criar fila de eventos.\n");
        gui_window_destroy();
    }

    al_set_window_title(window, "Jogo da canoa");

    /* Associa teclado com a janela */
    al_register_event_source(event_queue,
        al_get_display_event_source(window));
}
Esempio n. 17
0
//Creates a mask for pixel perfect collision
Mask *
mask_new(ALLEGRO_BITMAP *btm) {
	Mask *temp;
	int x, y;
	int width = al_get_bitmap_width(btm);
	int height = al_get_bitmap_height(btm);

	ALLEGRO_COLOR pixel;
	temp = mask_create(width, height);

	if (!temp)
		return NULL;

	mask_clear(temp);

	for(x = 0; x < width; x++) {
		for(y = 0; y < height; y++) {
			pixel = al_get_pixel(btm, x, y);
			if (pixel.a != 0) {
				temp->bits[x][y] = 1;
			}
		}
	}
	return temp;
}
Esempio n. 18
0
int main()
{
	al_init();
	al_init_image_addon();

	ALLEGRO_BITMAP *logo = al_load_bitmap("logo_no_alpha.png");
	ALLEGRO_BITMAP *shine = al_load_bitmap("shine.png");
	int w = al_get_bitmap_width(logo);
	int h = al_get_bitmap_height(logo);
	ALLEGRO_BITMAP *buf = al_create_bitmap(w, h);


	for (int i = 0; i < 20; i++) {
		char filename[100];
		sprintf(filename, "frame%02d.png", i);
		al_set_target_bitmap(buf);
		al_clear_to_color(al_map_rgb(0x22, 0x22, 0x22));
		float f = (rand() % 1000) / 1000.0 / 2.0;
		if (rand() % 2) {
			f = f + 0.5;
			al_draw_tinted_bitmap(shine, al_map_rgba_f(f, f, f, f), 0, 0, 0);
		}
		else {
			al_draw_bitmap(shine, 0, 0, 0);
			al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
			al_draw_tinted_bitmap(shine, al_map_rgba_f(f, f, f, f), 0, 0, 0);
			al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
		}
		al_draw_bitmap(logo, 0, 0, 0);
		al_save_bitmap(filename, buf);
	}
}
Esempio n. 19
0
int t3f_animation_add_frame(T3F_ANIMATION * ap, int bitmap, float x, float y, float z, float w, float h, float angle, int ticks, int flags)
{
	ap->frame[ap->frames] = al_malloc(sizeof(T3F_ANIMATION_FRAME));
	if(ap->frame[ap->frames])
	{
		ap->frame[ap->frames]->bitmap = bitmap;
		ap->frame[ap->frames]->x = x;
		ap->frame[ap->frames]->y = y;
		ap->frame[ap->frames]->z = z;
		if(w < 0.0)
		{
			ap->frame[ap->frames]->width = al_get_bitmap_width(ap->bitmaps->bitmap[bitmap]);
		}
		else
		{
			ap->frame[ap->frames]->width = w;
		}
		if(h < 0.0)
		{
			ap->frame[ap->frames]->height = al_get_bitmap_height(ap->bitmaps->bitmap[bitmap]);
		}
		else
		{
			ap->frame[ap->frames]->height = h;
		}
		ap->frame[ap->frames]->angle = angle;
		ap->frame[ap->frames]->ticks = ticks;
		ap->frame[ap->frames]->flags = flags;
		ap->frames++;
		t3f_animation_build_frame_list(ap);
		return 1;
	}
	return 0;
}
Esempio n. 20
0
void Image::print()
{
	ALLEGRO_DISPLAY *display = al_get_current_display();

	switch (mode)
	{
            case IMAGE_MODE_DEFAULT:
	        al_draw_bitmap(image, x, y, flag);
	        break;

	    case IMAGE_MODE_FULLSCREEN:
	    	al_draw_scaled_bitmap(
   			   image,
	    	   0, 0, al_get_bitmap_width(image), al_get_bitmap_height(image),
	    	   0, 0, al_get_display_width(display), al_get_display_height(display), flag);
		    break;

	    case IMAGE_MODE_REGION:
	    	//al_convert_mask_to_alpha(image, al_map_rgb(255,0,255));
	    	al_draw_bitmap_region(
	    	   image,
	    	   region_x, region_y, region_w, region_h,
	    	   x, y, flag);
		    break;
	}
}
Esempio n. 21
0
SHIP *
ship_create(void)
{
  SHIP *ship     = malloc(sizeof(SHIP));
  ship->position = malloc(sizeof(VECTOR));
  ship->velocity = malloc(sizeof(VECTOR));
  ship->missiles = NULL;

  ship->sprite = sprite;
  ship->thrust_sprite = thrust_sprite;

  ship->width       = al_get_bitmap_width(ship->sprite);
  ship->height      = al_get_bitmap_height(ship->sprite);
  ship->angle       = 0.0;
  ship->velocity->x = 0.0;
  ship->velocity->y = 0.0;
  ship->position->x = SCREEN_W / 2;
  ship->position->y = SCREEN_H / 2;
  ship->explosion   = NULL;
  ship->missiles    = NULL;
  ship->thrust_visible = false;
  ship->fire_debounce  = false;

  for(int i = 0; i < MAX_MISSILES; i++)
    ship->missiles = list_append(ship->missiles, missile_create());

  return ship;
}
Esempio n. 22
0
void t3f_3d_draw_rotated_bitmap(ALLEGRO_BITMAP * bp, ALLEGRO_COLOR color, float cx, float cy, float x, float y, float z, float angle, int flags)
{
	/* upper left and bottom right points in 3d */
	float obj_x[2], obj_y[2], obj_z[2], obj_cx, obj_cy;
	float rx, ry;
	
	/* upper left and bottom right points in 2d */
	float screen_w, screen_h;

	obj_x[0] = t3f_3d_project_x(x - cx, z);
	obj_x[1] = t3f_3d_project_x(x + cx, z);
	obj_y[0] = t3f_3d_project_y(y - cy, z);
	obj_y[1] = t3f_3d_project_y(y + cy, z);
	obj_z[0] = z + t3f_3d_current_state->width;
	obj_z[1] = z + t3f_virtual_display_width;
	obj_cx = t3f_3d_project_x(x, z);
	obj_cy = t3f_3d_project_y(y, z);
	
	/* clip sprites at z = 0 */
	if(obj_z[0] > 0)
	{
		screen_w = obj_x[1] - obj_x[0];
		screen_h = obj_y[1] - obj_y[0];
		rx = screen_w / al_get_bitmap_width(bp);
		ry = screen_h / al_get_bitmap_height(bp);
		al_draw_tinted_rotated_scaled_bitmap(bp, color, cx, cy, obj_cx, obj_cy, rx, ry, angle, flags);
	}
}
Esempio n. 23
0
/* function to squeeze a large bitmap to fit within the GPU's maximum texture size */
ALLEGRO_BITMAP * t3f_squeeze_bitmap(ALLEGRO_BITMAP * bp, int * ow, int * oh)
{
	int start_w = al_get_bitmap_width(bp);
	int start_h = al_get_bitmap_height(bp);
	int width = al_get_display_option(t3f_display, ALLEGRO_MAX_BITMAP_SIZE);
	int height = width;

	printf("max size = %d\n", width);
	if(start_w < width)
	{
		width = start_w;
	}
	if(start_h < height)
	{
		height = start_h;
	}
	/* store original bitmap size if pointers passed */
	if(ow)
	{
		*ow = start_w;
	}
	if(oh)
	{
		*oh = start_h;
	}

	/* return original bitmap if it already fits */
	if(start_w <= width && start_h <= height)
	{
		printf("clone (%d, %d) (%d, %d)\n", start_w, start_h, width, height);
		return al_clone_bitmap(bp);
	}
	return t3f_resize_bitmap(bp, width, width);
}
Esempio n. 24
0
static int allua_Bitmap_get_width(lua_State * L)
{
   ALLUA_bitmap bitmap = allua_check_bitmap(L, 1);

   lua_pushinteger(L, al_get_bitmap_width(bitmap));
   return 1;
}
Esempio n. 25
0
static void SkinFx_UpdateHearts()
{
	// Create a new heart
	if (RandomInt(60) == 0)
		gui_applet_blood_create (RandomInt(2), RandomInt(gui.info.screen.x), gui.info.screen.y - gui.info.bars_height);

	// Floating hearts
	for (int i = 0; i < MAX_HEARTS; i ++)
	{
		t_skinfx_particle* p = &g_skinfx_particles[i];
		p->y += p->vy;
		p->sin_phase += p->sin_speed;
		p->x = p->ix + p->sin_amp * sinf(p->sin_phase);
	}

	// Save old graphics
	const int w = al_get_bitmap_width(Graphics.Misc.Heart1);
	const int h = al_get_bitmap_height(Graphics.Misc.Heart1);
	for (int i = 0; i < MAX_HEARTS; i ++)
	{
		t_skinfx_particle* p = &g_skinfx_particles[i];
		al_set_target_bitmap(hearts_save[i]);
		al_draw_bitmap_region(gui_buffer, p->x, p->y, w, h, 0, 0, 0x0000);
	}

	// Draw hearts
	al_set_target_bitmap(gui_buffer);
	for (int i = 0; i < MAX_HEARTS; i ++)
	{
		t_skinfx_particle* p = &g_skinfx_particles[i];
		al_draw_bitmap(p->v ? Graphics.Misc.Heart1 : Graphics.Misc.Heart2, p->x, p->y, 0);
	}
}
Esempio n. 26
0
static void draw_pattern(ALLEGRO_BITMAP *b)
{
   int w = al_get_bitmap_width(b);
   int h = al_get_bitmap_height(b);
   int x, y;
   int format = ALLEGRO_PIXEL_FORMAT_BGR_888;
   ALLEGRO_COLOR light = al_map_rgb_f(1, 1, 1);
   ALLEGRO_COLOR dark = al_map_rgb_f(1, 0.9, 0.8);
   ALLEGRO_LOCKED_REGION *lock;
   lock = al_lock_bitmap(b, format, ALLEGRO_LOCK_WRITEONLY);
   for (y = 0; y < h; y++) {
      for (x = 0; x < w; x++) {
         ALLEGRO_COLOR c = (x + y) & 1 ? light : dark;
         unsigned char r, g, b;
         unsigned char *data = lock->data;
         al_unmap_rgb(c, &r, &g, &b);
         data += y * lock->pitch;
         data += x * 3;
         data[0] = r;
         data[1] = g;
         data[2] = b;
      }
   }
   al_unlock_bitmap(b);
}
Esempio n. 27
0
void Menu::Render()
{
	al_clear_to_color( al_map_rgb( 0, 0 ,0 ) );

	int iw = al_get_bitmap_width( GameResources::BackgroundTiles.at(backgroundindex) );

	al_draw_bitmap( background, -(menutime % iw), 0, 0 );

	titlefont->DrawString( (DISPLAY->GetWidth() / 2) + 4, 24, "Tug Of War!", FontHAlign::CENTRE, al_map_rgb( 0, 0, 0 ) );
	titlefont->DrawString( DISPLAY->GetWidth() / 2, 20, "Tug Of War!", FontHAlign::CENTRE, al_map_rgb( 255, 255, 0 ) );

	int centrepos = (DISPLAY->GetWidth() / 2) - sliderindex;
	RenderQuit( centrepos - (MENU_SPACING) );
	RenderLocal( centrepos );
	RenderNetwork( centrepos + (MENU_SPACING) );
	RenderHelp( centrepos + (MENU_SPACING * 2) );
	RenderSettings( centrepos + (MENU_SPACING * 3) );
	RenderQuit( centrepos + (MENU_SPACING * 4) );
	RenderLocal( centrepos + (MENU_SPACING * 5) );

	if( menutime % FRAMEWORK->GetFramesPerSecond() < (FRAMEWORK->GetFramesPerSecond() / 2) )
	{
		al_draw_bitmap( Input::GetIcon( InputItems::LEFT ), 10, 420, 0 );
		al_draw_bitmap( Input::GetIcon( InputItems::RIGHT ), 740, 420, 0 );
	}

}
void Player::render(int offx, int offy, ALLEGRO_COLOR tint)
{
   if (lives <= 0)
      return;

   int rx = (int)(offx + x), ry = (int)(offy + y);

   if (!isDestructable) {
      al_draw_tinted_rotated_bitmap(trans_bitmap, tint,
         draw_radius, draw_radius, rx, ry,
         angle+(ALLEGRO_PI/2.0f), 0);
   }
   else {
      al_draw_tinted_rotated_bitmap(bitmap,
         tint, draw_radius, draw_radius, rx, ry,
         angle+(ALLEGRO_PI/2.0f), 0);
   }
   if (draw_trail) {
      int tw = al_get_bitmap_width(trail_bitmap);
      int th = al_get_bitmap_height(trail_bitmap);
      float ca = (ALLEGRO_PI*2)+angle;
      float a = ca + ((210.0f / 180.0f) * ALLEGRO_PI);
      float tx = rx + 42.0f * cos(a);
      float ty = ry + 42.0f * sin(a);
      al_draw_tinted_rotated_bitmap(trail_bitmap, tint, tw, th/2,
         tx, ty, a, 0);
      a = ca + ((150.0f / 180.0f) * ALLEGRO_PI);
      tx = rx + 42.0f * cos(a);
      ty = ry + 42.0f * sin(a);
      al_draw_tinted_rotated_bitmap(trail_bitmap, tint, tw, th/2,
         tx, ty, a, 0);
   }
}
Esempio n. 29
0
FloatingObs::FloatingObs()
{
    obstacle = al_load_bitmap("resources/obstacle.png");

    cuadro->width = al_get_bitmap_width(obstacle);
    cuadro->height = al_get_bitmap_height(obstacle);
}
void Player::die(void)
{
   shake();
   reset();

   lives--;
   if (lives <= 0) {
      // game over
      isDestructable = false;
      invincibleCount = 20000;
      ALLEGRO_BITMAP *old_target = al_get_target_bitmap();
      al_set_target_bitmap(highscoreBitmap);
      int w = al_get_bitmap_width(highscoreBitmap);
      int h = al_get_bitmap_height(highscoreBitmap);
      ResourceManager& rm = ResourceManager::getInstance();
      ALLEGRO_FONT *large_font = (ALLEGRO_FONT *)rm.getData(RES_LARGEFONT);
      ALLEGRO_FONT *small_font = (ALLEGRO_FONT *)rm.getData(RES_SMALLFONT);
      al_draw_textf(large_font, al_map_rgb(255, 255, 255), w/2, h/2-16, ALLEGRO_ALIGN_CENTRE, "GAME OVER");
      al_draw_textf(small_font, al_map_rgb(255, 255, 255), w/2, h/2+16, ALLEGRO_ALIGN_CENTRE, "%d Points", score);
      al_set_target_bitmap(old_target);
   }
   else {
      hp = 1;
      isDestructable = false;
      invincibleCount = 3000;
   }
}