Please help, function fallin objects( ? )

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

Moderators: Shine, Insert_witty_name

Post Reply
rikardhassel
Posts: 9
Joined: Sat Oct 08, 2005 2:19 am

Please help, function fallin objects( ? )

Post by rikardhassel »

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/tzoo ... bject1.jpg

http://photobucket.com/albums/v733/tzoo ... bject2.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: Select all

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
flattspott
Posts: 22
Joined: Mon Aug 22, 2005 4:06 am

Post by flattspott »

you need a for loop to loop through the pieces on each draw cycle.
jimjamjahaa
Posts: 17
Joined: Mon Oct 03, 2005 5:00 am

Post by jimjamjahaa »

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
rikardhassel
Posts: 9
Joined: Sat Oct 08, 2005 2:19 am

Post by rikardhassel »

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.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

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
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

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.
Post Reply