New lua project

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

Moderators: Shine, Insert_witty_name

Post Reply
Koba
Posts: 59
Joined: Thu Sep 29, 2005 10:57 am

New lua project

Post by Koba »

hey, i'm working on a gunbound game right now and would like to know if anybody knows how to create gravity in lua?
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

gravity?
like... 3d?

Look, if your asking how to do gravity, you shouldnt even try something as complicated as gunbound. Try some simple games, then try that.

Oh, and there is none. If its 2D, just use variables that change values for the coordinate.
Koba
Posts: 59
Joined: Thu Sep 29, 2005 10:57 am

Post by Koba »

hmmm, well i'm not an ubernoob at lua, but gravity is somthing i've never done, yes its 2d, but for somthing like shooting a bullet, and it arcing, or going as far as the power is, i have yet to learn how to do that.i'm not creating an online gunbound btw... it would be way to easy to cheat with a lua made online gunbound. and if you cheat on the offline version, then who cares, your the only one who is losing out.
booger
Posts: 16
Joined: Sun Jul 03, 2005 11:19 pm
Location: El Segundo CA
Contact:

Post by booger »

Just give your projectile a y-acceleration variable (let's call it 'yaccel'). Every pass, add a small amount to the yaccel, you'll have to tweak this to get it to look the way you want. Start with a really small number though, like 0.05. Also, every pass add yaccel to the y position of your projectile. This will make your projectile drop a little at first, and then more as gravity accelerates it's fall. This technique even works if you're shooting it straight up in the air. It'll gradually slow and then start to fall.

Edit: Oh, just remember, if you're shooting it up in the air have the initial yaccel value reflect the direction of fire. You'll have to calculate this somehow. Most people use trig, but any technique you want to use to slap it together will be fine, I suppose. You should probably have an xaccel value as well, to tell the bullet how far to travel horizontaly each pass... though the xaccel value won't be modified each turn as the yaccel value is (unless you want to get creative or something).
Post Reply