【问题标题】:Allegro 5 : Handling small sprite dimension in big resolution displayAllegro 5:在大分辨率显示中处理小精灵尺寸
【发布时间】:2016-12-09 07:26:27
【问题描述】:

我是游戏编程的新手。在这里,我有一些精灵,比如精灵表中的马里奥精灵。每个精灵只有 32 x 32 像素。一个精灵包含一个动作,马里奥的全身。不幸的是,我必须至少使用 800 x 640 显示器。正如您可能猜到的那样,马里奥的展示变得如此渺小。 到目前为止,我只是在 GIMP2 中缩放精灵表,这样马里奥在屏幕上看起来不像蚂蚁。 有什么办法可以处理吗?也许 Allegro 有一些我不知道的东西。 我已经在文档中搜索过了。

【问题讨论】:

    标签: c++ allegro allegro5


    【解决方案1】:

    听起来您想要一种在 allegro 中缩放图像的方法。有两种方法可以实现这一点:

    1. 使用al_draw_tinted_scaled_rotated_bitmap_region。将您的比例因子(例如2.0)作为xscale 和yscale 参数传递。
    
    void al_draw_tinted_scaled_rotated_bitmap_region(ALLEGRO_BITMAP *bitmap,
       0, 0, 32, 32,              // draw the first 32x32 sprite in the sheet
       al_map_rgb(255, 255, 255), // don't tint the sprite
       16, 16,                    // the origin is 16, 16, half the 32x32 size
       200, 200,                  // draw at the point 200, 200 on the display
       2.0, 2.0,                  // scale by 2 in the x and y directions
       0, 0);                     // don't apply any angle or flags
    
    1. 使用transform 缩放您的图像。
    
    ALLEGRO_TRANSFORM trans;
    
    al_identity_transform(&trans);
    al_scale_transform(&trans, 2, 2); // scale by a factor of 2
    al_use_transform(&trans);
    
    // draw here
    

    请注意,在任何情况下(包括缩放 spritesheet 的原始解决方案),放大图像都会使其看起来更加像素化。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多