- [NEW] tolocal(x,y) converteix coordenades de pantalla en coordenades de camera
This commit is contained in:
9
lua.cpp
9
lua.cpp
@@ -329,6 +329,14 @@ extern "C" {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_tolocal(lua_State *L) {
|
||||||
|
int x = luaL_checknumber(L, 1);
|
||||||
|
int y = luaL_checknumber(L, 2);
|
||||||
|
lua_pushinteger(L, x+camx());
|
||||||
|
lua_pushinteger(L, y+camy());
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
static int cpp_circ(lua_State *L) {
|
static int cpp_circ(lua_State *L) {
|
||||||
int x = luaL_checknumber(L, 1);
|
int x = luaL_checknumber(L, 1);
|
||||||
int y = luaL_checknumber(L, 2);
|
int y = luaL_checknumber(L, 2);
|
||||||
@@ -896,6 +904,7 @@ void push_lua_funcs() {
|
|||||||
lua_pushcfunction(L,cpp_camera); lua_setglobal(L, "camera");
|
lua_pushcfunction(L,cpp_camera); lua_setglobal(L, "camera");
|
||||||
lua_pushcfunction(L,cpp_view); lua_setglobal(L, "view");
|
lua_pushcfunction(L,cpp_view); lua_setglobal(L, "view");
|
||||||
lua_pushcfunction(L,cpp_origin); lua_setglobal(L, "origin");
|
lua_pushcfunction(L,cpp_origin); lua_setglobal(L, "origin");
|
||||||
|
lua_pushcfunction(L,cpp_tolocal); lua_setglobal(L, "tolocal");
|
||||||
lua_pushcfunction(L,cpp_circ); lua_setglobal(L, "circ");
|
lua_pushcfunction(L,cpp_circ); lua_setglobal(L, "circ");
|
||||||
lua_pushcfunction(L,cpp_circfill); lua_setglobal(L, "circfill");
|
lua_pushcfunction(L,cpp_circfill); lua_setglobal(L, "circfill");
|
||||||
lua_pushcfunction(L,cpp_oval); lua_setglobal(L, "oval");
|
lua_pushcfunction(L,cpp_oval); lua_setglobal(L, "oval");
|
||||||
|
|||||||
8
mini.cpp
8
mini.cpp
@@ -702,6 +702,14 @@ void origin(int x, int y) {
|
|||||||
ds::cam[1] = -(ds::clip[1]+y);
|
ds::cam[1] = -(ds::clip[1]+y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int camx() {
|
||||||
|
return ds::cam[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
int camy() {
|
||||||
|
return ds::cam[1];
|
||||||
|
}
|
||||||
|
|
||||||
void _drawcirc(int xc, int yc, int x, int y) {
|
void _drawcirc(int xc, int yc, int x, int y) {
|
||||||
pset(xc+x, yc+y);
|
pset(xc+x, yc+y);
|
||||||
pset(xc-x, yc+y);
|
pset(xc-x, yc+y);
|
||||||
|
|||||||
2
mini.h
2
mini.h
@@ -174,6 +174,8 @@ void camera(int x, int y);
|
|||||||
void view(int x, int y, int w, int h);
|
void view(int x, int y, int w, int h);
|
||||||
void view();
|
void view();
|
||||||
void origin(int x, int y);
|
void origin(int x, int y);
|
||||||
|
int camx();
|
||||||
|
int camy();
|
||||||
|
|
||||||
void circ(int x, int y, uint8_t r = 4);
|
void circ(int x, int y, uint8_t r = 4);
|
||||||
void circ(int x, int y, uint8_t r, uint8_t color);
|
void circ(int x, int y, uint8_t r, uint8_t color);
|
||||||
|
|||||||
Reference in New Issue
Block a user