I am trying to make a monopoly game. But some display problems occur. When someone buy the house or something, its money will update to a new value. And the screen displace of the money will change. But in my code, the previous display value will not be covered or disappear, and the current value and previous value will display on the screen at the same time. The Render_mulit_line
import pygame
size = (1400, 924)
screen = pygame.display.set_mode(size)
class related_information_about_player():
def __init__(self, player, x_pos, y_pos):
self.name = player.name
self.money = player.money
self.player = player
self.x_pos = x_pos
self.y_pos = y_pos
self.text_input = (f"name: {self.name}\nmoney: {self.player.money}")
def update(self):
self.text_input = (f"name: {self.name}\nmoney: {self.player.money")
def render_multi_line(text, x, y, fsize):
global screen
lines = text.split("\n")
for i, l in enumerate(lines):
screen.blit(main_font.render(l, True, white), (x, y + size*i))
#main function and I have deleted other irrelated code
information1.update()
information2.update()
information3.update()
information4.update()
render_multi_line(information1.text_input,
information1.x_pos, information1.y_pos, 22)
render_multi_line(information2.text_input,
information2.x_pos, information2.y_pos, 22)
render_multi_line(information3.text_input,
information3.x_pos, information3.y_pos, 22)
render_multi_line(information4.text_input,
information4.x_pos, information4.y_pos, 22)
[enter image description here](https://i.stack.imgur.com/KP2xs.png)
I hope to see that the previous value will disappear after updating