I'm making a racing game in python and I kind of wrote myself into a corner. This for loop:
for i in objects: if i.name == "road": if i.y == 0: road = Road(road_x,-20,road_width,20) objects.append(road)
is how I generate new road tiles as the old ones move down the screen. When a block spawns 20 pixels offscreen, it falls down until its top left corner hits 0 and then a new block spawns above it. if you run this code: https://github.com/hailfire006/economy_game/blob/master/racing%20game you can see that it works great, right up until the player accelerates by pressing up or "w", at which point the road stops spawning.
What I think is happening is that the road is skipping the 0 mark and that's why no new road is spawning, but increasing the acceleration in the code doesn't seem to mess it up, it's only when it's changed dynamically in game. Can soneone explain what's happening here because nothing I try is working and I've been stuck on this for days...