⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lua_blit.c

📁 lua脚本语言调用allegro游戏程序库的接口-跨平台
💻 C
📖 第 1 页 / 共 2 页
字号:
   
   return 0;
}

//------------------------------------------------------------------------------------------
//void draw_character_ex(BITMAP *bmp, BITMAP *sprite, int x, int y, color, bg);
static int l_draw_character_ex(lua_State *L)
{
   int c=  lua_tonumber(L,5);
   int b=  lua_tonumber_def(L,6,-1); //transparent background if not specified
   draw_sprite_init();
   
   draw_character_ex(source,dest,x,y,c,b);
   
   return 0;
}



//------------------------------------------------------------------------------------------
//void draw_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
static int l_draw_sprite_v_flip(lua_State *L)
{
   draw_sprite_init();
   
   draw_sprite_v_flip(source,dest,x,y);
   
   return 0;
}

//------------------------------------------------------------------------------------------
//void draw_sprite_h_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
static int l_draw_sprite_h_flip(lua_State *L)
{
   draw_sprite_init();   

   draw_sprite_h_flip(source,dest,x,y);
   
   return 0;
}

//------------------------------------------------------------------------------------------
//void draw_sprite_vh_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
static int l_draw_sprite_vh_flip(lua_State *L)
{
   draw_sprite_init();   
    
   draw_sprite_vh_flip(source,dest,x,y);
   
   return 0;
}


//------------------------------------------------------------------------------------------
//void rotate_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle);
static int l_rotate_sprite(lua_State *L)
{
   fixed angle;
   draw_sprite_init();
   angle =  ftofix(lua_tonumber(L,5)*0.711111111111111111);  //0.7111 = 256/360
  
   rotate_sprite(source,dest,x,y,angle);
   
   return 0;
}

//------------------------------------------------------------------------------------------
//void rotate_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle);
static int l_rotate_sprite_v_flip(lua_State *L)
{
   fixed angle;
   draw_sprite_init();
   angle =  ftofix(lua_tonumber(L,5)*0.711111111111111111);  //0.7111 = 256/360
  
   rotate_sprite_v_flip(source,dest,x,y,angle);
   
   return 0;
}

//------------------------------------------------------------------------------------------
//void rotate_scaled_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle, fixed scale);
static int l_rotate_scaled_sprite(lua_State *L)
{
   fixed angle,scale;
   draw_sprite_init();
   angle =  ftofix(lua_tonumber(L,5)*0.711111111111111111);  //0.7111 = 256/360
   scale =  ftofix(lua_tonumber(L,6)); 
  
   rotate_scaled_sprite(source,dest,x,y,angle,scale);
   
   return 0;
}

//------------------------------------------------------------------------------------------
//void rotate_scaled_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle, fixed scale);
static int l_rotate_scaled_sprite_v_flip(lua_State *L)
{
   fixed angle,scale;
   draw_sprite_init();
   angle =  ftofix(lua_tonumber(L,5)*0.711111111111111111);  //0.7111 = 256/360
   scale =  ftofix(lua_tonumber(L,6)); 
  
   rotate_scaled_sprite_v_flip(source,dest,x,y,angle,scale);
   
   return 0;
}


//------------------------------------------------------------------------------------------
//void pivot_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle);
static int l_pivot_sprite(lua_State *L)
{
   int cx,cy;
   fixed angle;
   draw_sprite_init();
   cx     =  lua_tonumber(L,5);
   cy     =  lua_tonumber(L,6);
   angle  =  ftofix(lua_tonumber(L,7)*0.711111111111111111);  //0.7111 = 256/360
   
   pivot_sprite(source,dest,x,y,cx,cy,angle);
   
   return 0;
}

//---------------------------------------------------------------------------------------------
//void pivot_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle);
static int l_pivot_sprite_v_flip(lua_State *L)
{
   int cx,cy;
   fixed angle;
   draw_sprite_init();
   cx     =  lua_tonumber(L,5);
   cy     =  lua_tonumber(L,6);
   angle  =  ftofix(lua_tonumber(L,7)*0.711111111111111111);  //0.7111 = 256/360
   
   pivot_sprite_v_flip(source,dest,x,y,cx,cy,angle);
   
   return 0;
}

//---------------------------------------------------------------------------------------------
//void pivot_scaled_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle, fixed scale);
static int l_pivot_scaled_sprite(lua_State *L)
{
   int cx,cy;
   fixed angle,scale;
   draw_sprite_init();
   cx     =  lua_tonumber(L,5);
   cy     =  lua_tonumber(L,6);
   angle  =  ftofix(lua_tonumber(L,7)*0.711111111111111111);  //0.7111 = 256/360
   scale  =  ftofix(lua_tonumber(L,6)); 
   
   pivot_scaled_sprite(source,dest,x,y,cx,cy,angle,scale);
   
   return 0;
}

//---------------------------------------------------------------------------------------------
//void pivot_scaled_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle, fixed scale);
static int l_pivot_scaled_sprite_v_flip(lua_State *L)
{
   int cx,cy;
   fixed angle,scale;
   draw_sprite_init();
   cx     =  lua_tonumber(L,5);
   cy     =  lua_tonumber(L,6);
   angle  =  ftofix(lua_tonumber(L,7)*0.711111111111111111);  //0.7111 = 256/360
   scale  =  ftofix(lua_tonumber(L,6)); 
   
   pivot_scaled_sprite_v_flip(source,dest,x,y,cx,cy,angle,scale);
   
   return 0;
}

//---------------------------------------------------------------------------------------------
static const struct luaL_reg allegro_blit_lib [] = {
      {"blit",                          l_blit                         },
      {"masked_blit",                   l_masked_blit                  },
      {"stretch_blit",                  l_stretch_blit                 }, 
      {"masked_stretch_blit",           l_masked_stretch_blit          }, 
      {"draw_sprite",                   l_draw_sprite                  },
      {"draw_trans_sprite",             l_draw_trans_sprite            },
      {"draw_lit_sprite",               l_draw_lit_sprite              },
      {"draw_gouraud_sprite",           l_draw_gouraud_sprite          }, 
      {"stretch_sprite",                l_stretch_sprite               },
      {"draw_character_ex",             l_draw_character_ex            },
      {"draw_sprite_v_flip",            l_draw_sprite_v_flip           },
      {"draw_sprite_h_flip",            l_draw_sprite_h_flip           },
      {"draw_sprite_vh_flip",           l_draw_sprite_vh_flip          },
      {"rotate_sprite",                 l_rotate_sprite                },
      {"rotate_sprite_v_flip",          l_rotate_sprite_v_flip         },
      {"rotate_scaled_sprite",          l_rotate_scaled_sprite         },
      {"rotate_scaled_sprite_v_flip",   l_rotate_scaled_sprite_v_flip  },
      {"pivot_sprite",                  l_pivot_sprite                 },
      {"pivot_sprite_v_flip",           l_pivot_sprite_v_flip          },
      {"pivot_scaled_sprite",           l_pivot_scaled_sprite          },
      {"pivot_scaled_sprite_v_flip",    l_pivot_scaled_sprite_v_flip   },

      {NULL,                            NULL}  /* sentinel */
    };


//-----------------------------------------------------------------------------------------------
int luaopen_allegro_blit(lua_State *L) 
{
   luaL_openlib(L, "allegro",   allegro_blit_lib,   0);
   return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -