- Adaptat exemple a la nova API
- [NEW] viewport.resetClipping()
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
--other = require "other"
|
other = require "other"
|
||||||
|
|
||||||
x=0
|
x=0
|
||||||
|
|
||||||
function mini.init()
|
function mini.init()
|
||||||
--text=other.peiv()
|
text=other.peiv()
|
||||||
--keyRight = tonumber(getconf("keyright")) or KEY_RIGHT
|
keyRight = tonumber(config.getKey("keyright")) or key.RIGHT
|
||||||
--keyLeft = tonumber(getconf("keyleft")) or KEY_LEFT
|
keyLeft = tonumber(config.getKey("keyleft")) or key.LEFT
|
||||||
--_update=normal_update
|
mini.update=normal_update
|
||||||
--turbo(false)
|
--turbo(false)
|
||||||
--local perico = "péricòñ"
|
local perico = "péricòñ"
|
||||||
--print(utf8.len(perico))
|
print(utf8.len(perico))
|
||||||
Ants = 0xc936;
|
ants = 0xc936;
|
||||||
s = surface.load("tiles01.gif")
|
s = surface.load("tiles01.gif")
|
||||||
--surface.source(s)
|
--surface.source(s)
|
||||||
p = palette.load("tiles01.gif")
|
p = palette.load("tiles01.gif")
|
||||||
@@ -30,16 +30,16 @@ function mini.update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if system.isBeat() then
|
if system.isBeat() then
|
||||||
Ants = (Ants >> 12) | ((Ants<<4)&0xffff)
|
ants = (ants >> 12) | ((ants<<4)&0xffff)
|
||||||
end
|
end
|
||||||
surface.cls(5)
|
surface.cls(5)
|
||||||
draw.surface(s, 0, 0, 64, 64, 10, 10)
|
draw.surface(s, 0, 0, 64, 64, 10, 10)
|
||||||
draw.rect(10, 10, 73, 73, 8)
|
draw.rect(10, 10, 73, 73, 8)
|
||||||
draw.setPattern(Ants)
|
draw.setPattern(ants)
|
||||||
draw.rect(10, 10, 73, 73, 0)
|
draw.rect(10, 10, 73, 73, 0)
|
||||||
|
|
||||||
draw.setPattern(0xffff)
|
draw.setPattern(0xffff)
|
||||||
--draw.print(#p,0,0,2)
|
--draw.text(#p,0,0,2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function normal_update()
|
function normal_update()
|
||||||
@@ -60,23 +60,21 @@ function normal_update()
|
|||||||
window.setFullscreen(not window.getFullscreen())
|
window.setFullscreen(not window.getFullscreen())
|
||||||
end
|
end
|
||||||
|
|
||||||
//if x>160 then x=-strlen(text)*4 end
|
if x>160 then x=-utf8.len(text)*4 end
|
||||||
|
|
||||||
viewport.setClippingclip()
|
viewport.resetClipping()
|
||||||
origin(0,0)
|
viewport.setOrigin(0,0)
|
||||||
cls(20)
|
surface.cls(20)
|
||||||
clip(10,10,140,100)
|
viewport.setClipping(10,10,140,100)
|
||||||
cls(3)
|
surface.cls(3)
|
||||||
color(5)
|
draw.text("HOLA",0,0,5)
|
||||||
prnt("HOLA",0,0)
|
viewport.setOrigin(-70,-50)
|
||||||
origin(-70,-50)
|
draw.text("ORÍGIN",0,0,5)
|
||||||
prnt("ORÍGIN",0,0)
|
draw.text(text,x,10,5)
|
||||||
prnt(text,x,10)
|
draw.circFill(20,20,10,15);
|
||||||
color(10)
|
draw.setPattern(0x5a5a);
|
||||||
bcolor(15)
|
draw.circFill(20,20,10,10);
|
||||||
fillp(0x5a5a, false);
|
draw.setPattern(0xffff);
|
||||||
circfill(20,20,10);
|
|
||||||
fillp(0xffff,false);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
redefinekeys = {
|
redefinekeys = {
|
||||||
@@ -86,21 +84,21 @@ redefinekeys = {
|
|||||||
_update=redefinekeys.update
|
_update=redefinekeys.update
|
||||||
end,
|
end,
|
||||||
update = function()
|
update = function()
|
||||||
cls(20)
|
surface.cls(20)
|
||||||
if redefinekeys.state == 0 then
|
if redefinekeys.state == 0 then
|
||||||
prnt("PULSA TECLA PER A DRETA...",0,0)
|
draw.text("PULSA TECLA PER A DRETA...",0,0,10)
|
||||||
local key = btnp();
|
local key = keyboard.keyPressed();
|
||||||
if key ~= 0 then
|
if key ~= 0 then
|
||||||
redefinekeys.state = 1
|
redefinekeys.state = 1
|
||||||
keyRight=key
|
keyRight=key
|
||||||
setconf("keyright", keyRight)
|
config.setKey("keyright", keyRight)
|
||||||
end
|
end
|
||||||
elseif redefinekeys.state == 1 then
|
elseif redefinekeys.state == 1 then
|
||||||
prnt("PULSA TECLA PER A ESQUERRA...",0,0)
|
draw.text("PULSA TECLA PER A ESQUERRA...",0,0,10)
|
||||||
local key = btnp();
|
local key = keyboard.keyPressed();
|
||||||
if key ~= 0 then
|
if key ~= 0 then
|
||||||
keyLeft=key
|
keyLeft=key
|
||||||
setconf("keyleft", keyLeft)
|
config.setKey("keyleft", keyLeft)
|
||||||
_update=normal_update
|
_update=normal_update
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
peiv = function()
|
peiv = function()
|
||||||
palcolor(1, 1, 1, 1)
|
palette.setColor(1, 1, 1, 1)
|
||||||
return "HOLA OTHER UNIT"
|
return "HOLA OTHER UNIT"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
10
lua.cpp
10
lua.cpp
@@ -315,16 +315,17 @@ extern "C" {
|
|||||||
// viewport
|
// viewport
|
||||||
// ===============================================
|
// ===============================================
|
||||||
|
|
||||||
static int cpp_viewport_setClipping(lua_State *L) {
|
static int cpp_viewport_resetClipping(lua_State *L) {
|
||||||
if (lua_gettop(L) == 0) {
|
|
||||||
clip();
|
clip();
|
||||||
} else {
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cpp_viewport_setClipping(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);
|
||||||
int w = luaL_checknumber(L, 3);
|
int w = luaL_checknumber(L, 3);
|
||||||
int h = luaL_checknumber(L, 4);
|
int h = luaL_checknumber(L, 4);
|
||||||
clip(x, y, w, h);
|
clip(x, y, w, h);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,6 +858,7 @@ void push_lua_funcs() {
|
|||||||
lua_setglobal(L, "subpalette");
|
lua_setglobal(L, "subpalette");
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
lua_pushcfunction(L,cpp_viewport_resetClipping);lua_setfield(L, -2, "resetClipping");
|
||||||
lua_pushcfunction(L,cpp_viewport_setClipping); lua_setfield(L, -2, "setClipping");
|
lua_pushcfunction(L,cpp_viewport_setClipping); lua_setfield(L, -2, "setClipping");
|
||||||
lua_pushcfunction(L,cpp_viewport_setOrigin); lua_setfield(L, -2, "setOrigin");
|
lua_pushcfunction(L,cpp_viewport_setOrigin); lua_setfield(L, -2, "setOrigin");
|
||||||
lua_pushcfunction(L,cpp_viewport_getOrigin); lua_setfield(L, -2, "getOrigin");
|
lua_pushcfunction(L,cpp_viewport_getOrigin); lua_setfield(L, -2, "getOrigin");
|
||||||
|
|||||||
@@ -161,6 +161,9 @@ viewport = {}
|
|||||||
---Set the current clipping region
|
---Set the current clipping region
|
||||||
function viewport.setClipping(x, y, w, h) end
|
function viewport.setClipping(x, y, w, h) end
|
||||||
|
|
||||||
|
---reset the current clipping region to the entire window
|
||||||
|
function viewport.resetClipping() end
|
||||||
|
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---Set the current origin position
|
---Set the current origin position
|
||||||
|
|||||||
Reference in New Issue
Block a user