error: script.lua:61: can't create image
Here is the script...
Code: Select all
-- USB DISK MODE ACTIVATED FOR DEVELOPMENT
System.usbDiskModeActivate();
-- CLEAR THE SCREEN ON INIT
screen:clear();
-- GENERATE SCREEN BUFFER IMAGE
sBuffer = Image.createEmpty(480, 272);
-- GAP SPACING PARAMS
function init()
--sBuffer:clear();
rSeed = math.random(1, 100);
if rSeed < 50 then
gapW = math.random(1, 480);
gapH = math.random(1, 10);
else
gapW = math.random(1, 10);
gapH = math.random(1, 272);
end;
bW = math.floor(480 / gapW);
bH = math.floor(272 / gapH);
colorRange = 255 / bW;
max = bW * bH;
plots = {};
p = 0;
offsetX = 0;
offsetY = 0;
end;
-- CALL INIT
init();
-- MAIN LOOP
while true do
if p < max then
for p = p, p + bW do
stretch = 272 - offsetY;
if stretch < 1 then stretch = 1; end;
if stretch > 255 then stretch = 255; end; -- !!! WEIRD OPTIMIZATION, > 255 CHOKES UP !!!
colorMax = (p + 1) * colorRange;
rr = math.random(0, colorMax);
rg = math.random(0, colorMax);
rb = math.random(0, colorMax);
--plots[p] = Image.createEmpty(1, stretch);
--plots[p]:fillRect(0, 0, 1, stretch, Color.new(rr, rg, rb));
plots[p] = Image.createEmpty(gapW, stretch);
plots[p]:fillRect(0, 0, gapW, stretch, Color.new(rr, rg, rb));
--plots[p]:clear(Color.new(rr, rg, rb));
sBuffer:blit(offsetX, offsetY, plots[p]);
offsetX = offsetX + gapW;
if offsetX > 480 then
offsetX = 0;
offsetY = offsetY + gapH;
end;
end;
end;
screen:blit(0, 0, sBuffer, 0, 0, 480, 272, false);
screen.waitVblankStart();
screen.flip();
-- READ CONTROLS TO OBJECT 'INPUT'
input = Controls.read();
-- PAD MOVEMENT RE-INITS
if input:up() then init(); end;
if input:down() then init(); end;
if input:left() then init(); end;
if input:right() then init(); end;
-- TERMINATE ON START BUTTON
if input:start() then
break;
end;
-- SAVE SCREENSHOT ON SELECT BUTTON
if input:select() then
Image:save("screen_noise.png");
end;
end;
Code: Select all
plots[p] = Image.createEmpty(gapW, stretch);
Also noticed a funny glitch on the PC lua player... if you alternate these lines (alternate which one is commented out):
Code: Select all
plots[p]:fillRect(0, 0, gapW, stretch, Color.new(rr, rg, rb));
--plots[p]:clear(Color.new(rr, rg, rb));
Any insight is appreciated.