I'm working at a game that creates terrain dynamically.
A terrain part is made by a body, with a chain shape, that has around 100-200 points. (so no problem with the 1k limit of Box2D), and is static.
The game has a collection of terrain parts.
Whenever I almost reach the end of the terrain, a new terrain part is added next to it.
Having like let's say, 50-100 terrain parts can be bad ?
My game is targeting mobile platforms only.
Should I destroy a terrain part from the Box2D world when the player is far away from it?
And create it back when he is close?
Thanks.
Related
I am making a 2D platform game using cocos2dx and box2d.
And I am just now making of a player collitions with an attack of enemy.
An attack of enemy is such as a sword or a club, so I want to collition when a player is contacted with an edge of sword(or club) of enemy.
So far I made of a player collitions with a bullet using box2d, but I don't know that how to make the bounding box to an edge of sword(or club) of enemy like the following picture.
How are you making like this collision?
I believe that what you want isn't a bounding box but a collection of bodies, fixtures, and shapes to make a realistic enough simulation of the enemy and player interacting with each other.
To do that, you'll need to partition the pink lined shape (the enemy and its weapons) into a set of convex polygons — just like you'd need to do for the player.
Note that mathematically speaking, any concave shape can be expressed as a combination of convex polygons. From Wikipedia's entry for Concave polygon:
It is always possible to partition a concave polygon into a set of convex polygons.
If there's few enough entities you need to deal with this for, I'd just manually do the partitioning.
For one thing, it looks like you'd need to partition things manually anyway just in order to partition the ideally immutable parts from each other. Parts like the mace (or club), the forearm, the upper arm, etc where structures like metal, wood, or bone make a part rigid enough for the detail of the simulation you want to achieve.
Then you'll need to partition these rigid parts again to match the level of detail of the simulation that you want. So the mace's head, might be represented using something close to a pentagon shaped polygon. The mace's shaft, by just a rectangular polygon. Attach those two convex shapes to a single body for the mace. And so on.
You can use algorithms (or use implementations of those algorithms) to compute the sets of convex polygons that make up concave parts if you'd prefer. Unless you're going to do this for arbitrary shapes however, I'm not sure it's worth it.
AS3 - Detect WHERE a collision occurred and ROTATE everything AFTER the collision point of the object by 90 degrees
DISCLAIMER
The following explanation probably makes no sense, so have a look at http://raphaelhennessy.com/misc/Explanation.png for more information
Essentially, I'm making a game where a lazer shines onto the screen and you have a mirror somewhere on the screen you can drag around. There is also a globe somewhere on the screen. The aim of the game is to direct the light, using the mirror, into the globe. Then, an animation plays of the globe filling with light and you progress to the next level.
After time, the levels get somewhat harder and new obstacles and challenges are introduced.
My problem is this; I got the lazer, mirror & globe all on the stage working fine except that I can't figure out how to programmatically make the lazer 'bounce' off the mirror.
Thanks in advance,
-Raph
I figured out how to do this. If you are interested you can find the code at raphaelhennessy.com/misc/LightStage.zip
I'm making a game similar to 'Run' (http://www.albinoblacksheep.com/games/run) but I can't quite figure out the floor part. I'm not wanting the sides and a ceiling like in 'Run', just the main floor.
I'm new to Flash game development (AS3) but I know the basics. I realise the character isn't moving and is just turning (the level itself moves). How do a make a continuous floor, do I have to make a very long .fla file, or do I have to do this with code?
All ideas and help appreciated, Thanks. =)
You should use Tiles. Basically, a tile game consists of a lot of squared tiles, which are inserted when appear in screen and removed when goes out.
In your case, maybe you could use a big tile, with screen's size.
You can visualize a good example here, also a very good resource for gamedev on Flash.
You need to generate sprites of the edge of the screen and either recycle them when their x < some value or dispose and create new ones.
I think you can just use Bitmap.draw() to draw different pixels on a Bitmap that you've applied a 3D transformation to. You can see the basic concept illustrated here.
I want to create a game where you shoot a rocket into the ground (Sand) and it blows, and moves the sand to the sides...
Is it possible in Box2D? breakable little objects?
It's almost pixel perfect collusion detection.
Thanks!
Yes it's possible, but beware your performance is going to be pretty weak. See the following articles (sorry guys, I normally like to paste in code instead of just link but there is are too much of it).
http://www.emanueleferonato.com/2012/01/17/create-real-explosions-with-box2d-adding-textures/
http://www.emanueleferonato.com/2012/01/05/create-real-explosions-with-box2d-exploding-objects-and-setting-the-center-of-explosion-with-mouse-click/
http://www.emanueleferonato.com/2011/12/08/create-real-explosions-with-box2d/
As far as dirt flying out when the ground breaks, the dirt doesn't have to be physical, you can just fake that with some particle effects. (Lots of tutorials on those things here)
In box2d it's not possible to break an object other than to remove the old one and create many new objects. If you need almost pixel perfect collision detection you'd need lots of objects. A 100x100 square contains 10 000 pixels.
A year ago I created a physical simulation involving many small particle-like objects using box2d. You can find the video here. The number of objects you see there is close to maximum Alchemy version of box2d could handle. AS3 version failed with much less.
You should google how it was done in old-school games like Scorched Earth for example. Or it might be possible to "cut" sand particles in area of effect of your missile from box2d shape, create many small particles, simulate them and join back to main terrain shape. But it sound very complicated.
I'm trying to create a multi-level dungeon adventure in Flash CS4. The layout is an instance created of a symbol called Level, within the symbol are multiple wall subsymbols (wall), instances of Wall. There is a collision routine to stop the player walking through the walls, called from Wall.As.
Level is drawn about the centre point (0,0).
When I create an instance on the stage of Level (level), the collision tester is using the xy coordinates for the walls drawn about 0,0, not the "real" xy where it's appearing on the stage.
So what I need to know, is how to "update" the xy for each wall subsymbol with the live stage information, overriding the XYs drawn in the parent. It has to be updated unfortunately (I can't keep it static), as the levels are big so have to scroll.
Thanks for your advice.
With all due respect forget your approach, you're reinventing the wheel for nothing and probably to end up getting worse performance. What you need is pixel-perfect collision detection and probably including basic physics so already we're talking a huge amount of work. If you want to build levels in a design way for a game, use this, it'll blow your mind how awesome/easy/cool this is:
http://www.gotoandlearn.com/play.php?id=135
Its always a guess when trying to answer questions like this, as there are a lot of unknowns. That being said, in programming, there are always more than a few ways to solve a problem. Examine your collision detection routine - if you worked with hitTestPoint, and the point that was being tested (mouseX,Y or your main actor) with localToGlobal, you likely wouldn't need to test for the x,y variables of your collision objects. Read up on those two subjects and this question might be rendered moot.
At any rate, you could update relative coordinates in your Wall.as instance by leveraging globlaToLocal:
public function get curLoc():Point
{
return globalToLocal(new Point(this.x, this.y));
}
and retrieve them from your parent class as a point you can then test against:
trace(_wall.curLoc);
Hope that helps
I suppose you could accomplish what you're trying to do by manipulating the transform property of the wall symbols, but honestly I would concur with Ascension Systems and just abandon your collision testing routine for something different.
You may not need to go all out with a physics engine for your game, in which case just use hitTestObject to do the collision detection.