How do I loop 2 images?

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

Moderators: Shine, Insert_witty_name

Post Reply
2Xtremes2004
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

How do I loop 2 images?

Post by 2Xtremes2004 »

I am working on the loading screen for my project and I am having trouble getting the image to display like I want it to.

Here is my current code for the loading scrren:

Code: Select all

function Load()

   local BG = Image.load("Data/Loading/Background.png")
   local Loading1 = Image.load("Data/Loading/Loading1.png")
   local Loading2 = Image.load("Data/Loading/Loading2.png")

   while not Controls.read():start() do
    
      screen:blit(0,0, BG)
      screen:blit(362,254, Loading1)
    
      screen.waitVblankStart()
      screen.flip()

      L2FI()
    
   end
end
I am trying to get it to loop the Loading1 and loading2 files. The loading1 file is just a .png that says loading and the loading2 file is the same but the word was outlined with blue, giving it a glowing effect. Anyone have an idea for what I can do?
I want my money back!?
soulphalanx
Posts: 35
Joined: Mon Aug 22, 2005 7:48 am

Post by soulphalanx »

Code: Select all

function Load()

   local timer = 1
   local BG = Image.load("Data/Loading/Background.png")
   loading = {}
   Loading[1] = Image.load("Data/Loading/Loading1.png")
   Loading[2] = Image.load("Data/Loading/Loading2.png")

   while not Controls.read():start() do
   
      screen:blit(0,0, BG)
      screen:blit(362,254, loading[timer])
      if(timer == 2)  then
            timer = 1
      elseif(timer == 1)  then
            timer = 2
      end
   
      screen.waitVblankStart()
      screen.flip()

      L2FI()
   
   end
end 

if you want a delay between each picture, use "screen.waitVblackStart(#)"
2Xtremes2004
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

Post by 2Xtremes2004 »

Works Perfect! Thanks soulphalanx!
I want my money back!?
2Xtremes2004
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

Post by 2Xtremes2004 »

That one didnt seem to give you much of a challange! =P Here is one I have been having a problem with.

Ok, have you ever loaded linux and seen the way the files load at startup, they scroll down the screen and after each one it says "........Done".
I would like to get all the files, folders and sub-folders in my program directory to be printed to the screen in that way. I can get it to list the files in the first
folder, but it list them all ontop of each other so you cant read them, and it also keep listing them over and over causing it to keep reading from the memory card.
I want my money back!?
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

1) read the files from ms..
2) create an table for the lines you want to print
3) create an loop and print out the table... (top down)
4) add at the end of the loop add one entry from the filelist to the "empty" table [table.insert]
5) repeat step 4 until the table is full
6) remove the first entry from the table... [table.remove]
7) repeat and repeat....
8) done
9) enjoy
10) say thanks

greets
lumo
PS: i think thats what you wanted to?
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

Just for your refrence. People will generally offer ideas to code it not how to do it, but since im nice. I shall provide you with a simple example with what to do.

Code: Select all

--
-- Please refer to the directory first.
--
local dir = System.listDirectory()
local i = 1
for k, v in dir do
	if (not v["directory"]) then
		local len = string.len(v.name)
		if (string.sub(v.name,len-3,len-3) == ".") then
			-- String has an extension.
			if (string.sub(v.name,len-2,len) == "lua") then
				screen:print(0, i*8, "Loading "..v.name, Color.new(255, 255, 255))
				require(v.name)
				screen.waitVblankStart()
				screen.flip()
				i = i+1
			end
		end
	end
end
Please note this is untested code, learn it live it love it.

For each file in the loop. Check if the extension is ".lua" then print out the line where as the y position is moved i*8. (Meaning you setup a var to tell it to go down a line area so it doesnt write over itself).
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Pray tell us what "require(v.name)" command is supposed to do?

Thanks for your kindness.
Geo Massar
Retired Engineer
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

it loads an lua script and executes it...

greets
lumo
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Post Reply