Hello everybody! I'm planning a game where you can build your own spaceship out of iron-cubes (ship body, thrusters and so on). Your ship can collide with other objects (other ships, asteroids, ...) so I want to use the love physic engine.
My question: how I can use this engine that the correct cubes of the ship can be destroyed when crashing in another object? This should be very fast.
Here is an example like I want it:
http://gamedevelopment.tutsplus.com/tut ... medev-2610
Love2d physic for player-designed spaceships
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: Love2d physic for player-designed spaceships
It's also OK if you can show me another physic-engine in Lua.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Love2d physic for player-designed spaceships
It's not the simplest game idea to implement. If this is the first game you have ever programmed, you might be eating more than you can chew. I am not trying to insult you, this is fairly common. If you haven't, I recommend you to do something easier first (like a regular shooter, with no ship parts).
My make-it-work-quickly implementation would be: Each ship part is a a [wiki]Body[/wiki] with a single square-shaped [wiki]Fixture[/wiki], connected to the rest of the ship parts via [wiki]WeldJoint[/wiki]s. Parts of the same ship don't collide with each other, unless they are "separated" from the core. Depending on whether this is fast enough or not, I would consider optimizations later on; I would certainly not attempt something more complex than that on the first go.
Good luck!
If I were to do this, I would go with [wiki]love.physics[/wiki]. It's very well-suited for this kind of project, since the physics are more realistic than, say, a platformer.how I can use this engine that the correct cubes of the ship can be destroyed when crashing in another object? This should be very fast.
My make-it-work-quickly implementation would be: Each ship part is a a [wiki]Body[/wiki] with a single square-shaped [wiki]Fixture[/wiki], connected to the rest of the ship parts via [wiki]WeldJoint[/wiki]s. Parts of the same ship don't collide with each other, unless they are "separated" from the core. Depending on whether this is fast enough or not, I would consider optimizations later on; I would certainly not attempt something more complex than that on the first go.
Good luck!
When I write def I mean function.
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: Love2d physic for player-designed spaceships
No it's not my first game.It's not the simplest game idea to implement. If this is the first game you have ever programmed, you might be eating more than you can chew. I am not trying to insult you, this is fairly common. If you haven't, I recommend you to do something easier first (like a regular shooter, with no ship parts).
how I can use this engine that the correct cubes of the ship can be destroyed when crashing in another object? This should be very fast.
If I were to do this, I would go with love.physics. It's very well-suited for this kind of project, since the physics are more realistic than, say, a platformer.
My make-it-work-quickly implementation would be: Each ship part is a a Body with a single square-shaped Fixture, connected to the rest of the ship parts via WeldJoints. Parts of the same ship don't collide with each other, unless they are "separated" from the core. Depending on whether this is fast enough or not, I would consider optimizations later on; I would certainly not attempt something more complex than that on the first go.
Good luck!
I will damage ship parts with the CollisionCallback beginContact(a, b, coll).
How can I get the power of crashing?
Should I simulate thrusters with Body:applyForce ?
Thanks for helping me.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Love2d physic for player-designed spaceships
I realize now that it seems I implied that; that's not what I meant. I meant the first game using love.physics. Sorry about the confusion.Luke100000 wrote:No it's not my first game.
Before doing a complex game with love.physics, you might want to start doing a shooter with ships made of solid bodies first - get them flying around, colliding etc. Then attempt the "ships-made-of-parts" approach.
If you are asking "how do I make one ship part collide with another one", that's also done with CollisionsCallbacks. To box2d, it doesn't matter if one thing is a bullet or not (*). By default it collides everything with everything. In fact what usually happens is that you have to manually trim down what collides with what.Luke100000 wrote: I will damage ship parts with the CollisionCallback beginContact(a, b, coll).
How can I get the power of crashing?
(*) There is a difference, in that bullets tend to move much faster than regular objects, and their collisions have to be calculated differently. Some versions of box2d have a `setBullet` method to take this into account.
Yes. But remember to make that force proportional to dt.Luke100000 wrote:Should I simulate thrusters with Body:applyForce ?
When I write def I mean function.
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: Love2d physic for player-designed spaceships
The faster the more damage the ship part will get by colliding, how can I get this damage? I only get "colliding" or "not colliding".If you are asking "how do I make one ship part collide with another one", that's also done with CollisionsCallbacks.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Love2d physic for player-designed spaceships
Well, before we hade [wiki]Contact:getVelocity[/wiki]. Now it's gone (why? I don't know).
I guess you can still get the relative velocity of the two colliding bodies by substracting their individual velocities:
But I don't know, I haven't used love.physics since 0.8.x. Maybe there is a new way to do this.
I guess you can still get the relative velocity of the two colliding bodies by substracting their individual velocities:
Code: Select all
function getRelativeVelocity(a,b)
local vax, vay = a:getLinearVelocity()
local vbx, vby = b:getLinearVelocity()
return vbx - vax, vby - vay
end
When I write def I mean function.
Who is online
Users browsing this forum: No registered users and 9 guests