开发者

Lua - fast changing images

I'm not a programmer, even amateur, I just wanted a program that would change PSP screen (whole) color as fast as possible infinitely. I made something:

rdupa = Image.load("red.png")
gdupa = Image.load("green.png")
bdupa = I开发者_运维技巧mage.load("blue.png")
screen:clear()
while true do
screen:blit(0, 0, rdupa, false)
screen:clear()
screen:blit(0, 0, gdupa, false)
screen:clear()
screen:blit(0, 0, bdupa, false)
screen:clear()
end

Using Google, but that doesn't work. What did I do wrong (I have *.png images in the same folder as script)? Ready script would be seen veeeeeeery nicely.


I'm not sure about your environment but I'd guess it's most likely unable to update its main window or whatever as it's essentially stuck executing the Lua code snipped (unless that's executed in a separate thread).


Lua is a small and concise programming language and provides only few core functions (see this list).

Lua does not provide any functions to work with screen and images by default, so without knowing what library/framework are you using, there is little we can do to help.


For this answer, I'm operating under the assumption that you're using Lua Player (consider adding a luaplayer tag?). From what I can see in the documentation, you should be using

screen.flip()

instead of

screen:clear()

whenever you want to update the screen. Unfortunately, I do not have CFW on my PSP, so I cannot test this myself.


To be honest, I wouldn't even consider using images.

something like this would do :)

(This is using PGELua but can easily be adapted for LuaPlayer)

while pge.running() do
    color = pge.gfx.createcolor(pge.math.rand(255),pge.math.rand(255),pge.math.rand(255))
    pge.gfx.startdrawing()
    pge.gfx.drawrect(0,0,480,272,color)
    pge.gfx.enddrawing()
    pge.gfx.swapbuffers()
end

if you want defined colours, maybe something like.

red = pge.gfx.createcolor(255,0,0)
gre = pge.gfx.createcolor(0,255,0)
blu = pge.gfx.createcolor(0,0,255)
loop = 1
while pge.running() do
    pge.gfx.startdrawing()
    if loop==1 then
         pge.gfx.drawrect(0,0,480,272,red)
    elseif loop==2 then
         pge.gfx.drawrect(0,0,480,272,gre)
    elseif loop==3 then
         pge.gfx.drawrect(0,0,480,272,blu)
    end
    loop=loop+1
    if loop>4 then
        loop=1
    end
    pge.gfx.enddrawing()
    pge.gfx.swapbuffers()
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜