 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Koba
Joined: 29 Sep 2005 Posts: 59
|
Posted: Mon Jan 23, 2006 2:20 pm Post subject: New lua project |
|
|
| hey, i'm working on a gunbound game right now and would like to know if anybody knows how to create gravity in lua? |
|
| Back to top |
|
 |
youresam
Joined: 06 Nov 2005 Posts: 87
|
Posted: Mon Jan 23, 2006 2:55 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Koba
Joined: 29 Sep 2005 Posts: 59
|
Posted: Mon Jan 23, 2006 3:34 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
booger
Joined: 03 Jul 2005 Posts: 16 Location: El Segundo CA
|
Posted: Mon Jan 23, 2006 5:58 pm Post subject: |
|
|
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). |
|
| 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
|