Hi all,
I'm trying to help my nephew build a top down scroller racing game. Basically like the DriveMyCar program, but the road is much simpler. It simple goes straight. We will be including obstacles and power ups etc.. for the game play.
I'm trying to build it myself first to get a clear understanding of the features in kpl, which is pretty amazing by the way. I'm a professional .NET developer, so I definitely know my way around code.
I couldn't really follow exactly how the DriveMyCar program handles this situation, so I was hoping I could get some help from here.
I put a bunch of road sprites on the screen that stack to fill the full vertical space. With every pass through the main game loop, we move it down by a certain Y value(called 'speed'). When a sprite is completely off the bottom of the screen, its moved to the top. This way we can get the full effect using about 15 sprites. Its pretty much like a treadmill. The end result is it looks like the road is moving down the screen. With a car placed at the base of the screen that can be moved left and right, we've got a pretty good first step.
Here's where the problem is. We want to be able to vary speed. The issue is, when speed is increased, the amount the road sprites are moved is more than the last pass through the loop, so we end up with a little gap of a few pixels in the road. I'm pretty sure this has to do with the "treadmill" strategy, but I can't really figure it out.
What is the general strategy for scrolling games to handle changes in speed? Am I just doing something silly?
If needed, I can post the code.
Thanks