This question is simple, but for me is hard to do! How to implement side (horizontal and vertical) scrolling for (i.e.) a 2d car game ? Both car and background must move. How to ? Thank you!
|
|
Actually, your post indicates a very high level of laziness, but considering my novice days, I guess I might answer this. In a top-down racing game (that is what you call a game that move on all fours, because the view is from the top of the car), basically the car is made to move over the tracks by "faking" track movement. For example: Consider the car is lying on the center of the screen. I push the move up key. We know the car has to move up the track. But what we do in actuality is we dont move the car ,but we move the track downwards. ie. for every movement of the car, the track is moved by the distance to be moved in reverse direction. So when you look at the game from the aerial point of view(top-down) you "believe" the car is moving. This is just the essence of a top-down side-scroller game. And once you have accomplished this, you might want to add a "feel" to the acceleration. This can be done by adding a "braking factor" to the car at every instant in the gameloop also ensuring that the speed doesn't go negative. Hoping you'd achieve what you want. Best wishes |
|||
|
|
|
I don't like moving the background, what I did for my 2d physics engine was:
When you want to move the car, just change it's position relative to the world. Note: With the camera object you can implement zoom and scrolling easily. |
|||
|
|