AS3 car race game? - actionscript-3

I am trying to make a racing game with an overhead view looking down. There will be a separate mc for the ground and another separate mc for the players car. How can I do this? O ya and just in case i am thinking the way I did:
I tried to "rotate" the ground but when the car moves down the ground it moves away from the registration point, so therefore it rotates non relative to the car i want to make this game in as3.

Put the car on top of a separate holder movieclip, and put the graphics for the ground inside the ground holder. As the car moves and rotates, apply rotations to the holder MC, but apply movement to the ground inside the holder. This way, rotations will always take place relative to the registration point of the holder, but the ground graphics can still move relative to that point.

Not quite sure what you are looking for. In the meantime, you can look at the online Risk Game I helped built. Once in the site, click Super Commuter. If this game is similar to what you are trying to build, you can ask questions relating to what you observe there.

Related

How to create car collision in AS3?

I have a background with a top view motorway and forest on the sides and I want it so that when the car touches the green forest area the game changes to another scene. I have tried to put a line on the forest area and make it so that if the car hits the line switch to another scene but I have failed. I'm using action scrip 3. Thanks.
One solution might be to put the track pavement graphic in a separate sprite that sits on top of the green forest. Then you can hit test to see when your car is not touching the road. That would mean it's in the forest.
There's a simple top-down racing game in this book that uses a similar technique: AS3 Game Programming University (site)
Taking a look at that book might be really helpful if you are just starting out with games.

AS3 - zooming in and out with mousewheel at mouse position

I'm making a little game for school that takes place in space. I have multiple stars with orbiting planets. Moving around is slow as it's hard to see where the other stars are, so i decided that zooming in and out is an easy way to resolve this problem.
I've placed the stars and their planet children inside an objectHolder movieclip. I can move this movieclip to simulate the planets and stars moving.
To zoom in and out, i used scaleX and scaleY together with the mousewheel.delta event. This works, but it scales around the top left part of the objectHolder movieclip.
I have absolutely no idea as of how to aproach this problem. Google got me some answers, but non seemed to work for me.
Any ideas?
You need to do some math here. Get the localx and localy, multiple or divide it by the zoom factor (in this case scalex and scaley) and then move the objectHolder with respect to the calculation.

AS3: having problems implementing correct rotation with atan2

I have the following scenario: player is in the middle of the screen and never moves from those coordinates. If I click with the mouse on the far right of the screen, the A* script kicks in and moves the background the player is on according with its own walkable/not walkable criteria, so for example if there is an obstacle in between the center of the screen where the player always is in the far right of the screen, the background correctly moves in the opposite direction And when needed moves around the obstacle, so you have the illusion of player walking, but instead only the background moves.
my problem is that I don't know how to rotate my player to simulate that he is following the path that the actual background is making. For example, in the beginning, the player is facing down. If I click on the right side of the screen, the player should face right. When an obstacle is present, the player should face the direction of the path around the obstacle and so on
but again technically my player never moves, so I don't know what coordinates should I have the atan2 use. In my mind I thought that the player should rotate toward the center of the next best hop in the array of best path created during the A* script, but for some reason I can't figure out the correct coordinates y and x for the atan2 command
I bet this is a simple thing I overlooked, but apparently my mind is in shutdown mode, so I can use a new fresh perspective :-)
thanks!
First, do not code in brain shutdown mode, this can save you lots of brainhurt time.
You don't need atan2() in this scenario, since your player is technically on a grid instead of on the screen. Give the player internal coordinates on the grid that will be updated as the player walks around the world, and use them in your A* script. The A* script generates a sequence of tiles the player should walk, thus you derive player's facing from current and next tile, for example, if the next tile to walk is adjacent upwards, you make the player face up and continue moving.

Box2D AS3 - Refreshing the Shape or Hitbox?

I'm currently trying to implement a "crouch" function in my game. I'm using WCK with Box2D.
I have something rather basic, I generate my main character as an extension of a shape. This means that collision is automatically generated from the getgo. This is wonderful for a lot of things, but not everything.
I have a crouch/roll function. The problem is that the hitbox for crouching and standing are the same, so if a box drops onto you while crouching it "levitates" ontop of you since the hitbox is still the standing hitbox.
How would I go about "refreshing" the shape collision? Is there a way to delete the collision and make Box2D recalculate?
It's possible to filter contacts and prevent them from happening (using a contact listener or iterating the world's contact list) but I think there are better ways to do what you want.
You could split the body in two parts, and connect them with a prismatic joint (limits and motor enabled, collideConnected disabled). Standing up you'd have the motor push the parts apart to the upper limit and when crouching you'd pull them together to the lower limit thus reducing the height.
If you need really different shapes (e.g. a rectangle when standing and a circle for rolling around metroid style) this might work: Add both shape's fixtures to the body and use mask filtering to prevent the one you don't need from colliding with anything.

AS3 for moving a movieclip along a path

I am looking for a simple AS3 script to move/follow a movieclip (arrrow) along a manually drawn path in flash. Like.. it moves for the start point if the line to the end point of the line, also should rotate at curves automatically.
Also is it possible to duplicate this movieclip (arrrow) tho specific distance, like a ground of arrows moving along a path continuously with specific distance from eachother?
I am working on few infoGraphs and need this arrows animation to show the workflow.
I desperately needs this, pls help!
Cheers,
bp
There could be libraries that help with this, as George Profenza mentions in his comment, and it is certainly possible to calculate points along a bezier.
However, a much simpler solution is to do what people have done since Flash 4. Draw the curve in Flash, then create a motion tween along the curve using an empty MovieClip. At runtime, you can use addChild() to insert your MovieClip as a child of the empty one. You will have a lot more manual control this way, compared to the bezier library.