Problem With My Code

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
ohemsted
Posts: 7
Joined: Sat Apr 22, 2006 12:55 am

Problem With My Code

Post by ohemsted »

Hello everyone, I was wondering because I'm a newbie to lua coding why my application was popping up in windows lua then disappearing straight away there is a copy of the cody below can someone please take a look.
-- Images
author = Image.load("images/author.png") -- 480 x 272
luaplayer = Image.load("images/lua.png") -- 480 x 272
premenu = Image.load("images/premenu.png") -- 480 x 272
menu = Image.load("images/menu.png") -- 480 x 272
gameboard = Image.load("images/board.png") -- 480 x 272
icon1 = Image.load("images/icon1.png") -- 30 x 30
icon2 = Image.load("images/icon2.png") -- 30 x 30
-- Color
white = Color.new(255,255,255)



while true do -- Start the loop
screen.flip() -- Screen Buffer
screen.waitVblankStart()
screen:blit(0,0,luaplayer,true)
screen:blit(0,0,author,false)
screen:blit(0,0,premenu,false)
screen:blit(0,0,menu,false)
end
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

screen:flip() goes right before the end of while true do and screen.waitVblankStart goes right before screen:flip
- be2003
blog
ohemsted
Posts: 7
Joined: Sat Apr 22, 2006 12:55 am

I'm confused now...

Post by ohemsted »

I have simplified my code right down and it is still failing, any ideas?
author = Image.load("images/author.png") -- 480 x 272
luaplayer = Image.load("images/lua.png") -- 480 x 272
premenu = Image.load("images/premenu.png") -- 480 x 272
menu = Image.load("images/menu.png") -- 480 x 272
gameboard = Image.load("images/board.png") -- 480 x 272
icon1 = Image.load("images/icon1.png") -- 30 x 30
icon2 = Image.load("images/icon2.png") -- 30 x 30
white = Color.new(255,255,255)


while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,author)
screen.waitVblankStart()
screen.flip()
end
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

right after the screen:blit line make a new line like this:

Code: Select all

screen:print(0,0,"",black)

and define black at the beginning of the file:

black = Color.new(0,0,0)
- be2003
blog
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

add another flip on there.. Its a problem with windows lua player and faster machines. It tries to do double buffering.
ohemsted
Posts: 7
Joined: Sat Apr 22, 2006 12:55 am

Thanks

Post by ohemsted »

Ok I am glad your helping me out but it's still just flashing up and disappearing again.

Here is a sample of my current code
author = Image.load("images/author.png") -- 480 x 272
luaplayer = Image.load("images/lua.png") -- 480 x 272
premenu = Image.load("images/premenu.png") -- 480 x 272
menu = Image.load("images/menu.png") -- 480 x 272
gameboard = Image.load("images/board.png") -- 480 x 272
icon1 = Image.load("images/icon1.png") -- 30 x 30
icon2 = Image.load("images/icon2.png") -- 30 x 30
white = Color.new(255,255,255)
black = Color.new(0,0,0)


while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,author)
screen:print(0,0,"",black)
screen.waitVblankStart()
screen.flip()
screen.flip()
end
I would be very grateful if you could make the code correct and send it back to me in full.

Thanks again.
ohemsted
Posts: 7
Joined: Sat Apr 22, 2006 12:55 am

Support

Post by ohemsted »

I would like some full help with this program so if you would like to help me with this lua program please either PM me or e-mail on
Thanks
ohemsted
Posts: 7
Joined: Sat Apr 22, 2006 12:55 am

So you know

Post by ohemsted »

I have re-written my code and it is all working ok but I need to find a way to make the program watch one image for abuot 3 seconds then change to another for 3 seconds any ideas?
DiabloTerrorGF
Posts: 64
Joined: Fri Jul 15, 2005 11:44 pm

Post by DiabloTerrorGF »

Need a timer.
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

Code: Select all

-- switches between 2 images at 5 sec intervals
temp = 0
tempimg = 0 -- or false
imga = Image.load("jmtjhndb.png")
imgb = Image.load("jmg.png")
topscrn=Image.createEmpty(480,272)

while not Controls.read():start() do
    temp=temp+1
    if temp==3 then temp==1 end
    if temp==1 then
        tempimg=imga
    end
    if temp==2 then
        tempimg=imgb
    end
    topscrn:blit(0,0,tempimg)
    screen:blit(0,0,topscrn)
    screen.waitVblankStart()
    screen:flip()
    System.sleep(300)
end
- be2003
blog
Post Reply