forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I loop 2 images?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Fri Dec 30, 2005 8:50 am    Post subject: How do I loop 2 images? Reply with quote

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:

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!?
Back to top
View user's profile Send private message
soulphalanx



Joined: 22 Aug 2005
Posts: 35

PostPosted: Fri Dec 30, 2005 9:01 am    Post subject: Reply with quote

Code:

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(#)"
Back to top
View user's profile Send private message
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Sat Dec 31, 2005 1:23 am    Post subject: Reply with quote

Works Perfect! Thanks soulphalanx!
_________________
I want my money back!?
Back to top
View user's profile Send private message
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Sat Dec 31, 2005 1:54 am    Post subject: Reply with quote

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!?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Sat Dec 31, 2005 6:58 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Sat Dec 31, 2005 9:29 pm    Post subject: Reply with quote

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:

--
-- 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).
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Sun Jan 01, 2006 2:23 am    Post subject: Reply with quote

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

Thanks for your kindness.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Sun Jan 01, 2006 2:45 am    Post subject: Reply with quote

it loads an lua script and executes it...

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group