 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
rikardhassel
Joined: 08 Oct 2005 Posts: 9
|
Posted: Mon Oct 10, 2005 2:35 am Post subject: Please help, function fallin objects( ? ) |
|
|
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¤t=object1.jpg
http://photobucket.com/albums/v733/tzoom/?action=view¤t=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 |
|
 |
flattspott
Joined: 22 Aug 2005 Posts: 22
|
Posted: Mon Oct 10, 2005 3:49 am Post subject: |
|
|
| you need a for loop to loop through the pieces on each draw cycle. |
|
| Back to top |
|
 |
jimjamjahaa
Joined: 03 Oct 2005 Posts: 17
|
Posted: Mon Oct 10, 2005 8:46 am Post subject: |
|
|
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 |
|
 |
rikardhassel
Joined: 08 Oct 2005 Posts: 9
|
Posted: Mon Oct 10, 2005 8:07 pm Post subject: |
|
|
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 |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Mon Oct 10, 2005 8:43 pm Post subject: |
|
|
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 |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Oct 10, 2005 9:36 pm Post subject: |
|
|
| 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 |
|
 |
|
|
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
|