- [NEW] spr_r per a rotar sprites (retalla cantos)

- [NEW] sspr admet un nou paràmetre "invert", per a invertir la x i la y.
This commit is contained in:
2024-02-07 14:20:12 +01:00
parent 63eaaa857e
commit 8618e922c8
4 changed files with 44 additions and 35 deletions

40
lua.cpp
View File

@@ -160,30 +160,6 @@ extern "C" {
}
return 0;
}
/* static int cpp_pal(lua_State *L) {
int numargs = lua_gettop(L);
switch (numargs) {
case 0: pal(); return 0;
case 1: luaL_error(L, "not enough arguments"); return 0;
}
uint8_t c0 = luaL_checkinteger(L, 1);
uint8_t c1 = luaL_checkinteger(L, 2);
uint8_t p = luaL_optinteger(L, 3, 0);
pal(c0, c1, p);
return 0;
}
static int cpp_palt(lua_State *L) {
int numargs = lua_gettop(L);
switch (numargs) {
case 0: palt(); return 0;
case 1: uint16_t bits = luaL_checkinteger(L, 1); palt(bits); return 0;
}
uint8_t col = luaL_checkinteger(L, 1);
bool t = lua_toboolean(L, 2);
palt(col, t);
return 0;
}*/
static int cpp_pset(lua_State *L) {
int x = luaL_checknumber(L, 1);
@@ -436,7 +412,20 @@ extern "C" {
int dh = luaL_optnumber(L, 8, 0);
bool flip_x = lua_toboolean(L, 9);
bool flip_y = lua_toboolean(L, 10);
sspr(sx, sy, sw, sh, dx, dy, dw, dh, flip_x, flip_y);
bool invert = lua_toboolean(L, 11);
sspr(sx, sy, sw, sh, dx, dy, dw, dh, flip_x, flip_y, invert);
return 0;
}
static int cpp_spr_r(lua_State *L) {
int sx = luaL_checknumber(L, 1);
int sy = luaL_checknumber(L, 2);
int sw = luaL_checknumber(L, 3);
int sh = luaL_checknumber(L, 4);
int dx = luaL_checknumber(L, 5);
int dy = luaL_checknumber(L, 6);
float a = luaL_checknumber(L, 7);
spr_r(sx, sy, sw, sh, dx, dy, a);
return 0;
}
@@ -934,6 +923,7 @@ void push_lua_funcs() {
lua_pushcfunction(L,cpp_sget); lua_setglobal(L, "sget");
lua_pushcfunction(L,cpp_spr); lua_setglobal(L, "spr");
lua_pushcfunction(L,cpp_sspr); lua_setglobal(L, "sspr");
lua_pushcfunction(L,cpp_spr_r); lua_setglobal(L, "spr_r");
lua_pushcfunction(L,cpp_tline); lua_setglobal(L, "tline");
lua_pushcfunction(L,cpp_thline); lua_setglobal(L, "thline");
lua_pushcfunction(L,cpp_tvline); lua_setglobal(L, "tvline");