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 

Please help, function fallin objects( ? )

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



Joined: 08 Oct 2005
Posts: 9

PostPosted: Mon Oct 10, 2005 2:35 am    Post subject: Please help, function fallin objects( ? ) Reply with quote

I really should appreciate someone helped me with this.

Here I have pictures on examples made in photoshop of it, take a look.

http://photobucket.com/albums/v733/tzoom/?action=view&current=object1.jpg

http://photobucket.com/albums/v733/tzoom/?action=view&current=object2.jpg

And here is the code I' ve done so far, wich only makes a object fallin, and then ramdomize it at the top of the screen and then down again, and again and agin...



Code:
white = Color.new(255, 255, 255)

r0 = 0
r1 = math.random(480)

while true do

pad = Controls.read()

   screen:clear()

   screen:fillRect(r1, r0, 10, 10, white)

   r0 = r0 + 1

   if r0 == 272 then
   r0 = -10


   elseif r0 >= 271 then
   r1 = math.random(480)

   end
   

    screen.flip()
    screen:waitVblankStart(60)

if pad:start() then

      break

   end

end
Back to top
View user's profile Send private message
flattspott



Joined: 22 Aug 2005
Posts: 22

PostPosted: Mon Oct 10, 2005 3:49 am    Post subject: Reply with quote

you need a for loop to loop through the pieces on each draw cycle.
Back to top
View user's profile Send private message
jimjamjahaa



Joined: 03 Oct 2005
Posts: 17

PostPosted: Mon Oct 10, 2005 8:46 am    Post subject: Reply with quote

you want a new "object" each time it gets to the trigger or just jump that one?

if the former, you might concider actually using "objects" (not that they are really propper classes, but they are almost as good)

ie

block = {}
block.x = 10
block.y = 10
block.vspeed = 1

kinda thing
Back to top
View user's profile Send private message
rikardhassel



Joined: 08 Oct 2005
Posts: 9

PostPosted: Mon Oct 10, 2005 8:07 pm    Post subject: Reply with quote

Yes, or ?

A function that makes this falling object, so it can fall more then one.

Sure I can write:

screen:fillRect(r1, r0, 10, 10, white) again and another random number, but I need a function that MAKES a new copie of this object.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Mon Oct 10, 2005 8:43 pm    Post subject: Reply with quote

check my page
rain <-- thats something for you (no images and lot of stuff falling down)

bug: it will never rain in the lower left corner, will fix that ;)
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Mon Oct 10, 2005 9:36 pm    Post subject: Reply with quote

rikardhassel wrote:
Yes, or ?

A function that makes this falling object, so it can fall more then one.

Sure I can write:

screen:fillRect(r1, r0, 10, 10, white) again and another random number, but I need a function that MAKES a new copie of this object.


Perhaps you want to read the Lua book http://www.lua.org/pil/ , especially chaper 2.5. And you'll find in the starfield demo multiple objects, but moving from the center instead of dropping from top.
Back to top
View user's profile Send private message
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