I'm trying to create an infinite scrolling background for a simple 'dodge the incoming objects' game with python's arcade library. I've managed to get the background to move, but I can't seem to create another. I've been looking at a lot of example code, and I understand the basic idea is I have a list that removes the background when x = 0 and then append another at the starting value.
I have trouble with this in execution. :/
self.background_sprite = arcade.sprite.Sprite("resources/Background.png")
self.background_sprite.center_x = 600
self.background_sprite.center_y = 300
self.background_list.append(self.background_sprite)
for self.background_sprite in self.background_list:
self.background_sprite.change_x -= BACKGROUND_SPEED
def update_order(self):
self.background_update
self.player_update()
def on_draw(self):
""" Render the screen. """
arcade.start_render()
self.player_list.draw()
for self.background_sprite in self.background_list:
self.background_sprite.draw()
def background_update(self, delta_time):
for self.background_sprite in self.background_list:
x = self.background_sprite.center_x - BACKGROUND_SPEED
self.background_list.update()
if x == 0:
self.background_list.remove(self.background_sprite)
self.background_list.append(self.background_sprite)
repeat_count_x = 2
self.background_list.update()