2 Worlds: Code Snippet

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Xcmd
Party member
Posts: 211
Joined: Fri Feb 13, 2009 10:45 pm

2 Worlds: Code Snippet

Post by Xcmd »

This is the beginning to an idea I had about how to show off using Love to provide multiple gravity directions with collisions in a single game. This is a VERY rough and early draft, and I haven't at all gone into anything like really showing how this premise might work. Right now I use two worlds, and in each world I have an "original" and a "copy". The original is the original for that world. Gray world has the Gray original, White world has the White original. The copies are copies of the other world's original. Gray world has White's copy, while White world has Gray's copy. The copies positions are set manually, and I give them no mass (although I directly define that they have no mass so they'll appear as solid objects in the game world). I then draw both so I can see if there's much deviation from the positions of copy and original. There is, some, but not enough to make it horrid.

Thus we have layering, multiple gravities and collision. I haven't tested this deeply, but I found the early sample the be rather intriguing, so I thought I'd share it and see if it stimulates greater minds and skills than my own. Enjoy!
Attachments
2worlds.love
(592 Bytes) Downloaded 237 times
We don't borrow, we don't read, we don't rent, we don't lease, we take the minds!
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: 2 Worlds: Code Snippet

Post by kikito »

Implementing gravity with Box2d is starting to look like the holy grail of physics programming.

Your solution is interesting, but how does it scale? Will you end up with 1 world per object, with copies of everything else inside?
When I write def I mean function.
User avatar
Xcmd
Party member
Posts: 211
Joined: Fri Feb 13, 2009 10:45 pm

Re: 2 Worlds: Code Snippet

Post by Xcmd »

I think it's going to necessarily reduce the number of objects in total you can have in play in the game. The only way I could potentially see that reducing is instead of spawning an entire object, go ahead and track the location and collision rects (your choice in size) of the objects and when you notice that two of them are within the bounding boxes of each-other, quickly spawn a temporary object in the relevant worlds to create the proper collision effect, then destroy the temporary objects after that's happened.

I'll be honest: as per usual, I'm just screwing around and trying to stimulate new ideas in myself and possibly others. I can't think of a practical application for this, except for as a clone of some of the flash games out there that implement things like this. Like Red Remover. Or if you're wanting to implement a game with alternating gravities in a single level and you only want certain objects affected (like the player).
We don't borrow, we don't read, we don't rent, we don't lease, we take the minds!
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 3 guests