This is my farthest attempt into making a playable game. I have played around with some C++ engine like Orger3D, and have the basics of a game with a server, but I have no 3D talent, so I decided to try Java and 2D game. I have yet to finish and release a game so I am sorry if my questions are obvious or just common knowledge. I have spent at least 1 hour trying to solve the following questions. This is also my first time playing with a physics engine.
I am looking to make some top down 2d game, not sure what I want to make but I have some things I know will need to be done. I currently have the world gravity set to 0, so things just ‘float’ around.
- I have ‘space ship’ movement easy with setDamping(0f), ‘water’ simulation with setDamping(1f) (with my mass of 200) and then addForce(new Vector2f(0,-10000)) every loop. I would like to know the proper way to do person movement. I tried:
(delta = time since last loop)
float distance = (delta * 100) / 1000;
body.move(getX(), getY()+(-1f*distance));
this works fine except I will get a second lag (garbage collection?) and go right over my collision wall. Should I just make sure the movement isn’t over some amount (those with slower computers are slower in game)? I could do more stepping (does it work with move?) but that just adds more jerking in the end. I doubt “creating a line the length of my movement and checking it for collision, if no collision then move” would be a good idea…
-
I was wondering how I could do per pixel collision. In the end I may have a destroyable terrain (think worms).
I notice there is an addBitMap(), setBitMap() … options but not sure how to use them or if I can even use them like that.
If I can’t use bitmask setting, I was thinking of making a collision object the same shape as my image my using lines, like in the gear demo (though gears demo used a formula). I was going to check the image and find the ‘outside’ points and feed the points into a collision object.
Another way is just do circle/square collision, and if collision detected, do my own per pixel doing bitmask compare (examples on net). Problem is I do not think I can use the Phys2D ‘world’, and would have to manage the collision space myself, or is there a way to get around this? -
I might want to have tank(s) or car(s). Water isn’t bad because it does not have ridged turning but ‘slides’. I would like friction on the bottom, not just against other objects (or can I use a collision object to do this?). I could simulate sliding when the energy, other then the direction I am facing, gets to some point, I apply more energy or something… If I made a side scroller it woudl be cool because I could just attach tires to body and then turn the tire.
-
Is world.getContacts(body); function thread safe? I was going to complicate things with threads and make things more interesting.
-
If I make a space shooter I would like planets to have their ‘own’ gravity. I thought I read a comment on this and the solution was to attach springs to every object in range that got stronger the closer they were. I was thinking if there is no built in ‘world’ way to give object gravity, I would just have to check every body and if it is close to a gravity object, apply force based on distance.
Thats it for now and I hope I can still use Phys2D to do some of these. Granted I have no fixed idea what I will be making so I may make a game to fit the requirements than the other way around.