I am developing a small game in Pygame, where I have a stack of rhomboids arranged to create the illusion of a 3D cube. The goal of the game is to move the top rhomboid left or right along the X-axis. Once the rhomboid reaches the edge of the visible game space, it should disappear. After this, the next rhomboid in the stack (which was previously underneath the first one) should automatically become the active rhomboid that the player can move. Currently, there are some issues: When I move the rhomboid left or right, it doesn't disappear once it reaches the edge of the screen. When I press an arrow key to move the rhomboid in the opposite direction, the previous rhomboid appears again from the side, which it shouldn't. I need a solution to fix these problems, ensuring that when a rhomboid reaches the end of the visible space, it disappears and the next rhomboid automatically becomes the one the player can control. # Generate a list of unique colors def generate_color_list(): colors = ["RED", "ORANGE", "BLUE", "WHITE"] available_colors = colors.copy() color_list = [] while len(color_list) < 51: if not available_colors: available_colors = colors.copy() color = random.choice(available_colors) if color_list and color == color_list[-1]: continue color_list.append(color) available_colors.remove(color) return color_list # Draw a stack of rhombus shapes def draw_rhombus_stack(color_list, space, x_pos, plate_over, new_plate): positions = [] top_rhombus_index = 50 colors = ["RED", "ORANGE", "BLUE", "WHITE"] color_list = color_list # Flag to check if the plate is over the window boundary plate_over_window = False # Check if the top plate is over the window boundary if x_pos == -355: plate_over_window = True space += 8 # Move the entire stack up by 8 units for i in range(51): # Calculate the y-position based on the space and index y_position = space + i * 8 # Adjust the x-position only for the top rhombus x_position = x_pos if i == top_rhombus_index else 0 position = draw_rhombus(screen, color_list, x_position, y_position) positions.append(position) print(position) if plate_over_window and not new_plate: color = random.choice(colors) color_list.append(color) position = draw_rhombus(screen, color, 0, space + 408) positions.append(position) new_plate = True del color_list[0] # Odstráni hornú farbu del positions[0] # Odstráni horn return positions, new_plate, plate_over_window problem is in the last part of the function in last condition I think other is there just because context. Continue reading...