示例#1
0
void mapper_import_tiles(ALLEGRO_BITMAP * bp)
{
	int i, j;
	T3F_ANIMATION * ap = NULL;
	ALLEGRO_BITMAP * newbp = NULL;
	ALLEGRO_STATE old_state;
	ALLEGRO_TRANSFORM identity;

	al_store_state(&old_state, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_BLENDER | ALLEGRO_STATE_TRANSFORM);
	al_identity_transform(&identity);
	al_use_transform(&identity);
	for(i = 0; i < al_get_bitmap_height(bp) / mapper_tile_height; i++)
	{
		for(j = 0; j < al_get_bitmap_width(bp) / mapper_tile_width; j++)
		{
			ap = t3f_create_animation();
			if(ap)
			{
				newbp = al_create_bitmap(mapper_tile_width, mapper_tile_height);
				if(newbp)
				{
					al_set_target_bitmap(newbp);
					al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
					al_draw_bitmap(bp, -j * mapper_tile_width, -i * mapper_tile_height, 0);
					t3f_animation_add_bitmap(ap, newbp);
					t3f_animation_add_frame(ap, 0, 0, 0, 0, mapper_tile_width, mapper_tile_height, 0, 1, 0);
					t3f_add_tile(mapper_tileset, ap);
				}
			}
		}
	}
	al_restore_state(&old_state);
}
void Prog::draw_samples()
{
   ALLEGRO_STATE state;
   al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_BLENDER);
      
   /* Draw a background, in case our target bitmap will end up with
    * alpha in it.
    */
   draw_background(40, 20);
   draw_background(400, 20);
   
   /* Test standard blending. */
   al_set_target_bitmap(target);
   blending_test(false);

   /* Test memory blending. */
   al_set_target_bitmap(target_bmp);
   blending_test(true);

   /* Display results. */
   al_restore_state(&state);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
   al_draw_bitmap(target, 40, 20, 0);
   al_draw_bitmap(target_bmp, 400, 20, 0);
 
   al_restore_state(&state);
}
示例#3
0
static void t3f_render_static_tilemap(T3F_TILEMAP * tmp, T3F_TILESET * tsp, int layer, int tick, float ox, float oy, float oz, ALLEGRO_COLOR color)
{
	ALLEGRO_STATE old_blender;
	int i, j;
	bool held;

	held = al_is_bitmap_drawing_held();
	al_store_state(&old_blender, ALLEGRO_STATE_BLENDER);
	if(tmp->layer[layer]->flags & T3F_TILEMAP_LAYER_SOLID)
	{
		if(held)
		{
			al_hold_bitmap_drawing(false);
		}
		al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
	}
	al_hold_bitmap_drawing(true);
	for(i = 0; i < (t3f_virtual_display_height / tsp->height) + 1; i++)
	{
		for(j = 0; j < (t3f_virtual_display_width / tsp->width) + 1; j++)
		{
			t3f_draw_scaled_animation(tsp->tile[t3f_get_tile(tsp, tmp->layer[layer]->data[i][j], tick)]->ap, color, tick, (float)(j * tsp->width) * tmp->layer[layer]->scale, (float)(i * tsp->height) * tmp->layer[layer]->scale, 0, tmp->layer[layer]->scale, 0);
		}
	}
	if(tmp->layer[layer]->flags & T3F_TILEMAP_LAYER_SOLID)
	{
		al_hold_bitmap_drawing(false);
	}
	al_hold_bitmap_drawing(held);
	al_restore_state(&old_blender);
}
示例#4
0
static void render(void)
{
   double pos = al_get_audio_stream_position_secs(music_stream);
   double length = al_get_audio_stream_length_secs(music_stream);
   double w = al_get_display_width(display) - 20;
   double loop_start_pos = w * (loop_start / length);
   double loop_end_pos = w * (loop_end / length);
   ALLEGRO_COLOR c = al_map_rgb(255, 255, 255);

   al_clear_to_color(al_map_rgb(64, 64, 128));
   
   /* render "music player" */
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
   al_draw_textf(basic_font, c, 0, 0, 0, "Playing %s", stream_filename);
   print_time(8, 24, pos);
   al_draw_textf(basic_font, c, 100, 24, 0, "/");
   print_time(110, 24, length);
   al_draw_filled_rectangle(10.0, 48.0 + 7.0, 10.0 + w, 48.0 + 9.0, al_map_rgb(0, 0, 0));
   al_draw_line(10.0 + loop_start_pos, 46.0, 10.0 + loop_start_pos, 66.0, al_map_rgb(0, 168, 128), 0);
   al_draw_line(10.0 + loop_end_pos, 46.0, 10.0 + loop_end_pos, 66.0, al_map_rgb(255, 0, 0), 0);
   al_draw_filled_rectangle(10.0 + slider_pos - 2.0, 48.0, 10.0 + slider_pos + 2.0, 64.0,
      al_map_rgb(224, 224, 224));
   
   /* show help */
   al_draw_textf(basic_font, c, 0, 96, 0, "Drag the slider to seek.");
   al_draw_textf(basic_font, c, 0, 120, 0, "Middle-click to set loop start.");
   al_draw_textf(basic_font, c, 0, 144, 0, "Right-click to set loop end.");
   al_draw_textf(basic_font, c, 0, 168, 0, "Left/right arrows to seek.");
   al_draw_textf(basic_font, c, 0, 192, 0, "Space to pause.");
   
   al_flip_display();
}
示例#5
0
/* Converts a display bitmap to a memory bitmap preserving its contents.
 * Driver specific resources occupied by the display bitmap are freed.
 * A converted sub bitmap is invalid until its parent is converted.
 */
void _al_convert_to_memory_bitmap(ALLEGRO_BITMAP *bitmap)
{
   ALLEGRO_BITMAP *tmp;
   ALLEGRO_STATE backup;
   size_t old_size;

   /* Do nothing if it is a memory bitmap already. */
   if (bitmap->flags & ALLEGRO_MEMORY_BITMAP)
      return;

   if (bitmap->parent) {
      _al_vector_find_and_delete(&bitmap->display->bitmaps, &bitmap);

      //al_realloc(bitmap, sizeof(ALLEGRO_BITMAP));
      bitmap->display = NULL;
      bitmap->flags |= ALLEGRO_MEMORY_BITMAP;
      return;
   }

   ALLEGRO_DEBUG("converting display bitmap %p to memory bitmap\n", bitmap);

   /* Allocate a temporary bitmap which will hold the data
    * during the conversion process. */

   al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER);

   al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
   al_set_new_bitmap_format(bitmap->format);
   tmp = _al_create_memory_bitmap(bitmap->w, bitmap->h);

   /* Preserve bitmap contents. */
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
   al_set_target_bitmap(tmp);
   al_draw_bitmap(bitmap, 0, 0, 0);
   tmp->cb_excl = bitmap->cb_excl;
   tmp->cr_excl = bitmap->cr_excl;
   tmp->cl = bitmap->cl;
   tmp->ct = bitmap->ct;

   al_restore_state(&backup);

   /* Destroy the display bitmap to free driver-specific resources. */
   if (bitmap->vt)
      bitmap->vt->destroy_bitmap(bitmap);

   _al_vector_find_and_delete(&bitmap->display->bitmaps, &bitmap);

   /* Do not shrink the bitmap object. This way we can convert back to the
    * display bitmap.
    */
   /*al_realloc(bitmap, tmp->size);
     bitmap->size = tmp->size*/

   /* Put the contents back to the bitmap. */
   old_size = bitmap->size;
   memcpy(bitmap, tmp, tmp->size);
   bitmap->size = old_size;

   al_free(tmp);
}
void Menu_Screen::Screen_Lighten()
{
	//TWORZYMY BITMAPE ORAZ KOPIUJEMY OBECNY display
	Screen_Photo = al_create_bitmap( 800 , 600 ) ;
	ALLEGRO_BITMAP *Prev_Target = al_get_target_bitmap() ;

	//USTAWIAMY RYSOWANIE NA NOWEJ BITMAPIE
	al_set_target_bitmap( Screen_Photo ) ;

	al_draw_bitmap( Screen_Bitmap["Menu_Background"] , 0 , 0 , NULL ) ;
	al_draw_bitmap( Screen_Bitmap["Start"] , ScreenWidth / 2 - 100 , 200 , NULL ) ;
	al_draw_bitmap( Screen_Bitmap["Exit"] , ScreenWidth / 2 - 100 , 500 , NULL ) ;

	//USTAWIAMY STARY display (CHODZI O RYSOWANIE JAKBY WYBOR OKNA)
	al_set_target_bitmap( Prev_Target ) ;

	//PETLA RYSUJACA OBRAZ Z CORAZ MNIEJSZA PRZEZROCZYSTOSCIA
	for( float i = 0 ; i <= 1 ; i += 0.001 )
	{
		//ZMIANA KOLORU (JESLI DOBRZE ROZUMIEM) [BEZ TEGO NIE DZIALA TAK JAK TRZEBA]
		al_set_blender( ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA ) ;

		//RYSUJEMY BITMAPE Z ODPOWIEDNIM KANALEM ALPHA (PRZEZROCZYSTOSC)
		al_draw_tinted_bitmap( Screen_Photo , al_map_rgba_f( 1 , 1 , 1 , i ) , 0 , 0 , 0 ) ;

		al_flip_display() ;
		al_clear_to_color(al_map_rgb(0 , 0 , 0)) ;
		//al_rest(5.0) ;
	}
}
示例#7
0
/* Print some text with a shadow. */
static void print(int x, int y, char const *format, ...)
{
   va_list list;
   char message[1024];

   va_start(list, format);
   vsnprintf(message, sizeof message, format, list);
   va_end(list);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgb(0, 0, 0));
   al_draw_text(myfont, x + 2, y + 2, 0, message);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA,
      al_map_rgb(255, 255, 255));
   al_draw_text(myfont, x, y, 0, message);
}
示例#8
0
ALGIF_ANIMATION *algif_load_animation_f(ALLEGRO_FILE *file) {
    ALGIF_ANIMATION *gif = algif_load_raw(file);

    if (!gif)
        return gif;

    al_init_primitives_addon();

    gif->duration = 0;
    ALLEGRO_STATE s;
    al_store_state(&s, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_BLENDER);
    al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
    int n = gif->frames_count;
    int i;
    for (i = 0; i < n; i++) {
        ALGIF_FRAME *f = &gif->frames[i];
        f->rendered = al_create_bitmap(gif->width, gif->height);
        al_set_target_bitmap(f->rendered);
        algif_render_frame(gif, i, 0, 0);
        gif->duration += f->duration;
    }

    al_restore_state(&s);
    return gif;
}
示例#9
0
void Framework::InitialiseDisplay()
{
#ifdef WRITE_LOG
  printf( "Framework: Initialise Display\n" );
#endif

	int scrW = 800;
	int scrH = 480;
	bool scrFS = false;

	if( Settings->KeyExists( "Visual.ScreenWidth" ) )
  {
    Settings->GetIntegerValue( "Visual.ScreenWidth", &scrW );
  }
	if( Settings->KeyExists( "Visual.ScreenHeight" ) )
  {
    Settings->GetIntegerValue( "Visual.ScreenHeight", &scrH );
  }
	if( Settings->KeyExists( "Visual.FullScreen" ) )
  {
    Settings->GetBooleanValue( "Visual.FullScreen", &scrFS );
  }
  if( scrFS )
  {
    al_set_new_display_flags( ALLEGRO_FULLSCREEN_WINDOW );
  }
  al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST);
  displaySurface = al_create_display( scrW, scrH );
  if( displaySurface == 0 )
  {
    return;
  }
  al_set_blender( ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA );
  al_register_event_source( eventQueue, al_get_display_event_source( displaySurface ) );
}
示例#10
0
static void FilledTexturePrimitives(int mode)
{
   static ALLEGRO_VERTEX vtx[21];
   if (mode == INIT) {
      int ii = 0;
      for (ii = 0; ii < 21; ii++) {
         float x, y;
         ALLEGRO_COLOR color;
         if (ii % 2 == 0) {
            x = 150 * cosf((float)ii / 20 * 2 * ALLEGRO_PI);
            y = 150 * sinf((float)ii / 20 * 2 * ALLEGRO_PI);
         } else {
            x = 200 * cosf((float)ii / 20 * 2 * ALLEGRO_PI);
            y = 200 * sinf((float)ii / 20 * 2 * ALLEGRO_PI);
         }
         
         if (ii == 0) {
            x = y = 0;
         }
         
         color = al_map_rgb((7 * ii + 1) % 3 * 64, (2 * ii + 2) % 3 * 64, (ii) % 3 * 64);
         
         vtx[ii].x = x; vtx[ii].y = y; vtx[ii].z = 0;
         vtx[ii].u = 64 * x / 100; vtx[ii].v = 64 * y / 100;
         if(ii < 10)
            vtx[ii].color = al_map_rgba_f(1, 1, 1, 1);
         else
            vtx[ii].color = color;
      }
   } else if (mode == LOGIC) {
      Theta += Speed;
      al_build_transform(&MainTrans, ScreenW / 2, ScreenH / 2, 1, 1, Theta);
   } else if (mode == DRAW) {
      if (Blend)
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
      else
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
  
      al_use_transform(&MainTrans);
      
      al_draw_prim(vtx, 0, Texture, 0, 6, ALLEGRO_PRIM_TRIANGLE_FAN);
      al_draw_prim(vtx, 0, Texture, 7, 13, ALLEGRO_PRIM_TRIANGLE_LIST);
      al_draw_prim(vtx, 0, Texture, 14, 20, ALLEGRO_PRIM_TRIANGLE_STRIP);
      
      al_use_transform(&Identity);
   }
}
static void draw(void)
{
   const float sw = al_get_bitmap_width(bmp);
   const float sh = al_get_bitmap_height(bmp);
   const float dw = al_get_bitmap_width(dbuf);
   const float dh = al_get_bitmap_height(dbuf);
   const float dx = dw / 2.0;
   const float dy = dh / 2.0;
   float db_l;
   float db_r;
   float db;
   float scale;
   float disp;

   /* Whatever looks okay. */
   if (rms_l > 0.0 && rms_r > 0.0) {
      db_l = 20 * log10(rms_l / 20e-6);
      db_r = 20 * log10(rms_r / 20e-6);
      db = (db_l + db_r) / 2.0;
      scale = db / 20.0;
      disp = (rms_l + rms_r) * 200.0;
   }
   else {
      db_l = db_r = db = scale = disp = 0.0;
   }

   al_set_target_bitmap(dbuf);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
   al_draw_filled_rectangle(0, 0, al_get_bitmap_width(dbuf), al_get_bitmap_height(dbuf),
      al_map_rgba_f(0.8, 0.3, 0.1, 0.06));
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
   al_draw_tinted_scaled_rotated_bitmap(bmp,
      al_map_rgba_f(0.8, 0.3, 0.1, 0.2),
      sw/2.0, sh/2.0, dx, dy - disp, scale, scale, theta, 0);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
   al_set_target_backbuffer(display);
   al_draw_bitmap(dbuf, 0, 0, 0);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
   al_draw_line(10, dh - db_l, 10, dh, al_map_rgb_f(1, 0.6, 0.2), 6);
   al_draw_line(20, dh - db_r, 20, dh, al_map_rgb_f(1, 0.6, 0.2), 6);

   al_flip_display();

   theta -= (rms_l + rms_r) * 0.1;
}
示例#12
0
void RenderTarget::copyBox(RenderTarget *src, int32_t sx, int32_t sy, int32_t w, int32_t h, int32_t tx, int32_t ty) {
	setAsCurrent();
	int32_t a, b, c;
	al_get_blender(&a, &b, &c);
	al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);

	if(src->getBitmap() == this->getBitmap()) {
		ALLEGRO_BITMAP *src_clone = al_clone_bitmap(src->getBitmap());
		al_draw_bitmap_region(src_clone, sx, sy, w, h, tx, ty, 0);
		al_destroy_bitmap(src_clone);
	}
	else {
		al_draw_bitmap_region(src->getBitmap(), sx, sy, w, h, tx, ty, 0);
	}

	al_set_blender(a, b, c);
}
示例#13
0
void __character_intro_8 ()
{
    al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(0.4, 0.6, 0.3, 0.4));
    al_draw_textf(global.font_menu, 320, 130, ALLEGRO_ALIGN_CENTRE, "Silk of Nature");
    al_draw_textf(global.font_menu, 130, 180, ALLEGRO_ALIGN_LEFT, "Weapon: ???");
    al_draw_textf(global.font_menu, 130, 210, ALLEGRO_ALIGN_LEFT, "Bomb: ???");
    al_draw_textf(global.font_menu, 130, 240, ALLEGRO_ALIGN_LEFT, "Ability: ???");
}
示例#14
0
void __character_intro_1 ()
{
    al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(0.7, 0.5, 0.4, 0.4));
    al_draw_textf(global.font_menu, 320, 130, ALLEGRO_ALIGN_CENTRE, "Simpleton");
    al_draw_textf(global.font_menu, 130, 180, ALLEGRO_ALIGN_LEFT, "Weapon: Simpleton,s Scatter");
    al_draw_textf(global.font_menu, 130, 210, ALLEGRO_ALIGN_LEFT, "Bomb: Simpleton,s Cloud");
    al_draw_textf(global.font_menu, 130, 240, ALLEGRO_ALIGN_LEFT, "Ability: Simpleton,s Reflection");
    al_draw_textf(global.font_menu, 130, 270, ALLEGRO_ALIGN_LEFT, "Special Ability: Simpleton,s walk");
}
示例#15
0
void __character_intro_2 ()
{
    al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(0.9, 0.6, 0.5, 0.4));
    al_draw_textf(global.font_menu, 320, 130, ALLEGRO_ALIGN_CENTRE, "Hellfire");
    al_draw_textf(global.font_menu, 130, 180, ALLEGRO_ALIGN_LEFT, "Weapon: Hellfire");
    al_draw_textf(global.font_menu, 130, 210, ALLEGRO_ALIGN_LEFT, "Bomb: Hellfire Tide");
    al_draw_textf(global.font_menu, 130, 240, ALLEGRO_ALIGN_LEFT, "Ability: Hellfire Wave");
    al_draw_textf(global.font_menu, 130, 270, ALLEGRO_ALIGN_LEFT, "Special Ability: Annihilation");
}
bool Player::load(void)
{
   ALLEGRO_STATE state;
   al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_BLENDER);

   bitmap = al_load_bitmap(getResource("gfx/ship.tga"));
   if (!bitmap) {
      debug_message("Error loading %s\n", getResource("gfx/ship.tga"));
      return false;
   }

   trans_bitmap = al_create_bitmap(al_get_bitmap_width(bitmap),
      al_get_bitmap_height(bitmap));
   if (!trans_bitmap) {
      debug_message("Error loading %s\n", getResource("gfx/ship_trans.tga"));
      al_destroy_bitmap(bitmap);
      return false;
   }

   /* Make a translucent copy of the ship */
   al_set_target_bitmap(trans_bitmap);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
   al_draw_tinted_bitmap(bitmap, al_map_rgba(255, 255, 255, 160),
      0, 0, 0);
   al_restore_state(&state);

   trail_bitmap = al_load_bitmap(getResource("gfx/trail.tga"));
   if (!trail_bitmap) {
      debug_message("Error loading %s\n", getResource("gfx/trail.tga"));
      al_destroy_bitmap(bitmap);
      al_destroy_bitmap(trans_bitmap);
      return false;
   }

   icon = al_load_bitmap(getResource("gfx/ship_icon.tga"));
   if (!icon) {
      debug_message("Error loading %s\n", getResource("gfx/icon.tga"));
      al_destroy_bitmap(bitmap);
      al_destroy_bitmap(trans_bitmap);
      al_destroy_bitmap(trail_bitmap);
      return false;
   }

   highscoreBitmap = al_create_bitmap(300, 200);
   al_set_target_bitmap(highscoreBitmap);
   al_clear_to_color(al_map_rgba(0, 0, 0, 0));

   al_restore_state(&state);

   draw_radius = al_get_bitmap_width(bitmap)/2;
   radius = draw_radius / 2;

   newGame();
   reset();

   return true;
}
示例#17
0
/* Draw our example scene. */
static void draw(void)
{
   float xs, ys, a;
   double dt = 0;
   double t = al_current_time();
   if (last_time > 0) {
      dt = t - last_time;
   }
   last_time = t;

   al_set_target_bitmap(target);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA,
      al_map_rgba_f(1, 1, 1, 1));

   al_draw_filled_rectangle(x, y, x + RW, y + RH, al_map_rgba_f(1, 0, 0, 1));
   al_draw_filled_rectangle(0, 0, W, H, al_map_rgba_f(1, 1, 0, 0.1));

   x += dx * dt;
   if (x < 0) {
      x = 0;
      dx = -dx;
   }
   if (x + RW > W) {
      x = W - RW;
      dx = -dx;
   }
   y += dy * dt;
   if (y < 0) {
      y = 0;
      dy = -dy;
   }
   if (y + RH > H) {
      y = H - RH;
      dy = -dy;
   }

   al_set_target_bitmap(al_get_backbuffer());
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgba_f(1, 1, 1, 1));
   al_clear_to_color(al_map_rgba_f(0, 0, 1, 1));
   xs = 1 + 0.2 * sin(t * ALLEGRO_PI * 2);
   ys = 1 + 0.2 * sin(t * ALLEGRO_PI * 2);
   a = t * ALLEGRO_PI * 2 / 3;
   al_draw_rotated_scaled_bitmap(target, W / 2, H / 2, 320, 240, xs, ys, a, 0);
}
示例#18
0
void DrawableBitmap::draw() {

	//al_draw_scaled_bitmap(bitmap, 0, 0, size.x, size.y, position.x-(size.x/2.0f)*scale, position.y-(size.y/2.0f)*scale, size.x*scale, size.y*scale, 0);

	float totalScale = scale*localScale;
	float totalRotation = rotation+localRotation;
	float totalRotationComplement = rotation-localRotation;

	al_draw_tinted_scaled_rotated_bitmap(bitmap, al_map_rgba(tintR, tintG, tintB, transparency), size.x/2.0f, size.y/2.0f, position.x, position.y, totalScale, totalScale, totalRotation, 0);

	if(hasReflection) {
		al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);

		//al_draw_tinted_scaled_rotated_bitmap(bitmap, al_map_rgb(100, 100, 100), size.x/2.0f, size.y/2.0f, position.x - sin(rotation)*(scale*size.y+floatingHeight*scale), position.y + cos(rotation)*scale*size.y+floatingHeight*scale, totalScale, totalScale, totalRotationComplement, 2);
		al_draw_tinted_scaled_rotated_bitmap(bitmap, al_map_rgba(0.9f*tintR, 0.9f*tintG, tintB, 100), size.x/2.0f, size.y/2.0f, position.x - sin(rotation)*(scale*size.y+floatingHeight*scale), position.y + cos(rotation)*scale*size.y+floatingHeight*scale, totalScale, totalScale, totalRotationComplement, 2);

		al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
	}
}
示例#19
0
static void TexturePrimitives(int mode)
{
   static ALLEGRO_VERTEX vtx[13];
   static ALLEGRO_VERTEX vtx2[13];
   if (mode == INIT) {
      int ii = 0;
      ALLEGRO_COLOR color;
      for (ii = 0; ii < 13; ii++) {
         float x, y;
         x = 200 * cosf((float)ii / 13.0f * 2 * ALLEGRO_PI);
         y = 200 * sinf((float)ii / 13.0f * 2 * ALLEGRO_PI);
         
         color = al_map_rgb((ii + 1) % 3 * 64, (ii + 2) % 3 * 64, (ii) % 3 * 64);
         
         vtx[ii].x = x; vtx[ii].y = y; vtx[ii].z = 0;
         vtx2[ii].x = 0.1 * x; vtx2[ii].y = 0.1 * y;
         vtx[ii].u = 64 * x / 100; vtx[ii].v = 64 * y / 100;
         vtx2[ii].u = 64 * x / 100; vtx2[ii].v = 64 * y / 100;
         if(ii < 10)
            vtx[ii].color = al_map_rgba_f(1, 1, 1, 1);
         else
            vtx[ii].color = color;
         vtx2[ii].color = vtx[ii].color;
      }
   } else if (mode == LOGIC) {
      Theta += Speed;
      al_build_transform(&MainTrans, ScreenW / 2, ScreenH / 2, 1, 1, Theta);
   } else if (mode == DRAW) {
      if (Blend)
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
      else
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
      
      al_use_transform(&MainTrans);
      
      al_draw_prim(vtx, 0, Texture, 0, 4, ALLEGRO_PRIM_LINE_LIST);
      al_draw_prim(vtx, 0, Texture, 4, 9, ALLEGRO_PRIM_LINE_STRIP);
      al_draw_prim(vtx, 0, Texture, 9, 13, ALLEGRO_PRIM_LINE_LOOP);
      al_draw_prim(vtx2, 0, Texture, 0, 13, ALLEGRO_PRIM_POINT_LIST);
      
      al_use_transform(&Identity);
   }
}
示例#20
0
void __character_intro_3 ()
{
    al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(0.4, 0.8, 0.9, 0.4));
    al_draw_textf(global.font_menu, 320, 130, ALLEGRO_ALIGN_CENTRE, "Jellyfish");
    al_draw_textf(global.font_menu, 130, 180, ALLEGRO_ALIGN_LEFT, "Weapon: Sapphire Laser");
    al_draw_textf(global.font_menu, 130, 210, ALLEGRO_ALIGN_LEFT, "Bomb: ???");
    al_draw_textf(global.font_menu, 130, 240, ALLEGRO_ALIGN_LEFT, "Ability[fast]: Space Bender");
    al_draw_textf(global.font_menu, 130, 270, ALLEGRO_ALIGN_LEFT, "Ability[slow]: Absolute Zero");
    al_draw_textf(global.font_menu, 130, 300, ALLEGRO_ALIGN_LEFT, "Special Ability: Slow Aura");
}
示例#21
0
void init_misc() {
    al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
    al_set_window_title(display, "Pikmin fangame engine");
    if(smooth_scaling) al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR | ALLEGRO_MIPMAP);
    al_reserve_samples(16);
    
    srand(time(NULL));
    
    // TODO the function is always returning 0.
    area_image_size = /*al_get_new_display_option(ALLEGRO_MAX_BITMAP_SIZE, NULL)*/ 800;
}
示例#22
0
/* emulate textout_centre() */
void textout_centre(const ALLEGRO_FONT *font, const char *s, int x, int y, ALLEGRO_COLOR c)
{
   ALLEGRO_STATE state;

   al_store_state(&state, ALLEGRO_STATE_BLENDER);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, c);
   al_draw_text(font, x, y, ALLEGRO_ALIGN_CENTRE, s);

   al_restore_state(&state);
}
示例#23
0
/* Print out the current logo parameters. */
static void print_parameters(void)
{
   int i;
   ALLEGRO_STATE state;
   ALLEGRO_COLOR normal = al_map_rgba_f(0, 0, 0, 1);
   ALLEGRO_COLOR light = al_map_rgba_f(0, 0, 1, 1);
   ALLEGRO_COLOR label = al_map_rgba_f(0.2, 0.2, 0.2, 1);
   int th;

   al_store_state(&state, ALLEGRO_STATE_BLENDER);

   th = al_get_font_line_height(font) + 3;
   for (i = 0; param_names[i]; i++) {
      al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
      al_draw_textf(font, label, 2, 2 + i * th, 0, "%s", param_names[i]);
   }
   for (i = 0; param_names[i]; i++) {
      int y = 2 + i * th;
      al_draw_filled_rectangle(75, y, 375, y + th - 2,
                        al_map_rgba_f(0.5, 0.5, 0.5, 0.5));
      al_draw_textf(font, i == selection ? light : normal, 75, y, 0, "%s", param_values[i]);
      if (i == selection && editing &&
         (((int)(al_get_time() * 2)) & 1)) {
         int x = 75 + al_get_text_width(font, param_values[i]);
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
         al_draw_line(x, y, x, y + th, white, 0);
      }
   }

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
   al_draw_textf(font, normal, 400, 2, 0, "%s", "R - Randomize");
   al_draw_textf(font, normal, 400, 2 + th, 0, "%s", "S - Save as logo.png");

   al_draw_textf(font, normal, 2, 480 - th * 2 - 2, 0, "%s",
                      "To modify, press Return, then enter value, "
                      "then Return again.");
   al_draw_textf(font, normal, 2, 480 - th - 2, 0, "%s",
                      "Use cursor up/down to "
                      "select the value to modify.");
   al_restore_state(&state);
}
示例#24
0
static void print(char const *format, ...)
{
   va_list list;
   char message[1024];
   int th = al_get_font_line_height(ex.font);
   va_start(list, format);
   vsnprintf(message, sizeof message, format, list);
   va_end(list);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
   al_draw_textf(ex.font, ex.text, ex.text_x, ex.text_y, 0, "%s", message);
   ex.text_y += th;   
}
示例#25
0
void FlareManager::Flare::__default_draw(Flare *flare)
{
	float inverse_counter = 1.0 - flare->counter;
	if (flare->bitmap)
	{
		if (flare->blending_mode == BLENDER_ADDITIVE)
			al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);

		al_draw_tinted_scaled_rotated_bitmap(flare->bitmap, al_map_rgba_f(flare->opacity,flare->opacity,flare->opacity,flare->opacity),
			al_get_bitmap_width(flare->bitmap)*flare->align_x, al_get_bitmap_height(flare->bitmap)*flare->align_y,
			flare->x, flare->y, flare->scale, flare->scale, flare->rotation, 0);

		if (flare->blending_mode == BLENDER_ADDITIVE)
			al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
	}
	else
	{
		al_draw_circle(flare->x, flare->y, 30*inverse_counter,
			al_map_rgba_f(flare->counter, flare->counter, flare->counter, flare->counter), 2);
	}
}
示例#26
0
void List::draw()
{
   const Theme & theme = dialog->get_theme();
   SaveState state;

   al_draw_filled_rectangle(x1 + 1, y1 + 1, x2 - 1, y2 - 1, theme.bg);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, theme.fg);
   const int font_height = al_get_font_line_height(theme.font);
   for (unsigned i = 0; i < items.size(); i++) {
      int yi = y1 + i * font_height;

      if (i == selected_item) {
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgb(255, 255, 255));
         al_draw_filled_rectangle(x1 + 1, yi, x2 - 1, yi + font_height - 1,
            theme.highlight);
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, theme.fg);
      }

      al_draw_text(theme.font, x1, yi, 0, items.at(i).c_str());
   }
}
示例#27
0
static void splat(const int x, const int y, bool blend)
{
   double theta;

   al_set_target_bitmap(dbuf);

   fade();
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_ZERO);
   draw_clip_rect();
   red_dot(x, y);

   my_set_clip_rect();
   if (blend) {
      al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
   }
   for (theta = 0.0; theta < 2.0 * ALLEGRO_PI; theta += ALLEGRO_PI/16.0) {
      al_draw_line(x, y, x + 40.0 * cos(theta), y + 40.0 * sin(theta), white, 0);
   }
   reset_clip_rect();

   flip();
}
示例#28
0
static void CustomVertexFormatPrimitives(int mode)
{
   static CUSTOM_VERTEX vtx[4];
   static ALLEGRO_VERTEX_DECL* decl;
   if (mode == INIT) {
      int ii = 0;
      ALLEGRO_VERTEX_ELEMENT elems[] = {
         {ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_SHORT_2, offsetof(CUSTOM_VERTEX, x)},
         {ALLEGRO_PRIM_TEX_COORD_PIXEL, ALLEGRO_PRIM_SHORT_2, offsetof(CUSTOM_VERTEX, u)},
         {ALLEGRO_PRIM_COLOR_ATTR, 0, offsetof(CUSTOM_VERTEX, color)},
         {0, 0, 0}
      };
      decl = al_create_vertex_decl(elems, sizeof(CUSTOM_VERTEX));

      for (ii = 0; ii < 4; ii++) {
         float x, y;
         x = 200 * cosf((float)ii / 4.0f * 2 * ALLEGRO_PI);
         y = 200 * sinf((float)ii / 4.0f * 2 * ALLEGRO_PI);
         
         vtx[ii].x = x; vtx[ii].y = y;
         vtx[ii].u = 64 * x / 100; vtx[ii].v = 64 * y / 100;
         vtx[ii].color = al_map_rgba_f(1, 1, 1, 1);
      }
   } else if (mode == LOGIC) {
      Theta += Speed;
      al_build_transform(&MainTrans, ScreenW / 2, ScreenH / 2, 1, 1, Theta);
   } else if (mode == DRAW) {
      if (Blend)
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
      else
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
      
      al_use_transform(&MainTrans);
      
      al_draw_prim(vtx, decl, Texture, 0, 4, ALLEGRO_PRIM_TRIANGLE_FAN);
      
      al_use_transform(&Identity);
   }
}
示例#29
0
void Label::draw()
{
   const Theme & theme = this->dialog->get_theme();
   SaveState state;

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, theme.fg);
   if (centred) {
      al_draw_text(theme.font, (this->x1 + this->x2 + 1)/2,
         this->y1, ALLEGRO_ALIGN_CENTRE, this->text.c_str());
   }
   else {
      al_draw_text(theme.font, this->x1, this->y1, 0, this->text.c_str());
   }
}
示例#30
0
static void TransformationsPrimitives(int mode)
{
   float t = al_get_time();
   if (mode == INIT) {
   
   } else if (mode == LOGIC) {
      Theta += Speed;
      al_build_transform(&MainTrans, ScreenW / 2, ScreenH / 2, sinf(t / 5), cosf(t / 5), Theta);
   } else if (mode == DRAW) {
      float points[8] = {
         -300, -200,
         700, 200,
         -700, 200,
         300, -200
      };
      
      if (Blend)
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
      else
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
      
      al_use_transform(&MainTrans);
      
      al_draw_line(-300, -200, 300, 200, al_map_rgba_f(0, 0.5, 0.5, 1), Thickness);
      al_draw_triangle(-150, -250, 0, 250, 150, -250, al_map_rgba_f(0.5, 0, 0.5, 1), Thickness);
      al_draw_rectangle(-300, -200, 300, 200, al_map_rgba_f(0.5, 0, 0, 1), Thickness);
      al_draw_rounded_rectangle(-200, -125, 200, 125, 50, 100, al_map_rgba_f(0.2, 0.2, 0, 1), Thickness);
      
      al_draw_ellipse(0, 0, 300, 150, al_map_rgba_f(0, 0.5, 0.5, 1), Thickness);
      al_draw_elliptical_arc(-20, 0, 300, 200, -ALLEGRO_PI / 2, -ALLEGRO_PI, al_map_rgba_f(0.25, 0.25, 0.5, 1), Thickness);
      al_draw_arc(0, 0, 200, -ALLEGRO_PI / 2, ALLEGRO_PI, al_map_rgba_f(0.5, 0.25, 0, 1), Thickness);
      al_draw_spline(points, al_map_rgba_f(0.1, 0.2, 0.5, 1), Thickness);
      al_draw_pieslice(0, 25, 150, ALLEGRO_PI * 3 / 4, -ALLEGRO_PI / 2, al_map_rgba_f(0.4, 0.3, 0.1, 1), Thickness);
      
      al_use_transform(&Identity);
   }
}