diff --git a/data/game.lua b/data/game.lua index 701e050..ae1ca79 100644 --- a/data/game.lua +++ b/data/game.lua @@ -17,7 +17,9 @@ function normal_update() view(10,10,140,100) cls(3) prnt("HOLA",0,0) - prnt(text,x,60) + origin(70,50) + prnt("ORIGIN",0,0) + prnt(text,x,10) if btnp(keyRight) then x=x+1 end if btnp(keyLeft) then x=x-1 end if btnp(KEY_SPACE) then diff --git a/lua.cpp b/lua.cpp index 34143ab..21500f3 100644 --- a/lua.cpp +++ b/lua.cpp @@ -291,6 +291,13 @@ extern "C" { return 0; } + static int cpp_origin(lua_State *L) { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + origin(x, y); + return 0; + } + static int cpp_circ(lua_State *L) { int x = luaL_checknumber(L, 1); int y = luaL_checknumber(L, 2); @@ -855,6 +862,7 @@ void push_lua_funcs() { lua_pushcfunction(L,cpp_clip); lua_setglobal(L, "clip"); lua_pushcfunction(L,cpp_camera); lua_setglobal(L, "camera"); lua_pushcfunction(L,cpp_view); lua_setglobal(L, "view"); + lua_pushcfunction(L,cpp_origin); lua_setglobal(L, "origin"); lua_pushcfunction(L,cpp_circ); lua_setglobal(L, "circ"); lua_pushcfunction(L,cpp_circfill); lua_setglobal(L, "circfill"); lua_pushcfunction(L,cpp_oval); lua_setglobal(L, "oval"); diff --git a/mini.cpp b/mini.cpp index 6cc2a2b..3de529d 100644 --- a/mini.cpp +++ b/mini.cpp @@ -9,7 +9,7 @@ #include #endif -extern DECLSPEC int SDLCALL (*event_handler_ptr)(SDL_Event*) = &SDL_PollEvent; +DECLSPEC int SDLCALL (*event_handler_ptr)(SDL_Event*) = &SDL_PollEvent; #pragma pack(1) @@ -671,6 +671,11 @@ void view() { ds::clp[0] = ds::clp[1] = 0; ds::clp[2] = screen_width-1; ds::clp[3] = screen_height-1; } +void origin(int x, int y) { + ds::cam[0] = -(ds::clip[0]+x); + ds::cam[1] = -(ds::clip[1]+y); +} + void _drawcirc(int xc, int yc, int x, int y) { pset(xc+x, yc+y); pset(xc-x, yc+y); diff --git a/mini.h b/mini.h index e9d33fc..0e96f09 100644 --- a/mini.h +++ b/mini.h @@ -2,7 +2,7 @@ #include -#define MINI_VERSION "0.9.32d" +#include "version.h" #define KEY_UNKNOWN 0 #define KEY_A 4 @@ -170,6 +170,7 @@ void clip(); void camera(int x, int y); void view(int x, int y, int w, int h); void view(); +void origin(int x, int y); void circ(int x, int y, uint8_t r = 4); void circ(int x, int y, uint8_t r, uint8_t color); diff --git a/version.h b/version.h new file mode 100644 index 0000000..e9fad5a --- /dev/null +++ b/version.h @@ -0,0 +1,3 @@ +#pragma once + +#define MINI_VERSION "0.9.64d"