- [NEW] tolocal(x,y) converteix coordenades de pantalla en coordenades de camera

This commit is contained in:
2023-09-11 11:39:14 +02:00
parent d1f13a0036
commit 663a4af6cb
4 changed files with 20 additions and 1 deletions

View File

@@ -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");

View File

@@ -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
View File

@@ -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);

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define MINI_VERSION "0.9.80d" #define MINI_VERSION "0.9.81d"