what did you set your text sizes to so i can replicate?
I am not sure what all the possible outcome text could be from that...but your positioning of your text objects is over complex than what it should be. A proper text object position to the center would be using the screen's rect center attribute. And if you had too much you would need to account for line wrapping, or always use two lines for simplicity.
I have more of a feeling its hard coding text positions when you dont know the size dimensions yet such as:
The proper way to handle text objects positioning. You dont need to do anyhting other than
have all your string as text, text_rect is your rect of the current text updated every frame, and draw that object to the center of the screen. Then it wouldnt matter what size the text is.
This doesnt change the size of the text, but it does change the text string itself. And it would do the same if the size was changed each time. The text object is always centered on the screen. Regardless of whether the string is 1 digit or 10 digits, size of text, font style, etc.
https://github.com/metulburr/pygame_code...r_timed.py
To be honest your whole code is quite sloppy. If i did it i would replace 90% of your code. You should use format method instead of concatenating strings. I would use a class for the number to clean up some of the code.
I am not sure what all the possible outcome text could be from that...but your positioning of your text objects is over complex than what it should be. A proper text object position to the center would be using the screen's rect center attribute. And if you had too much you would need to account for line wrapping, or always use two lines for simplicity.
I have more of a feeling its hard coding text positions when you dont know the size dimensions yet such as:
Quote:This first line places the drawing x position at 118 pixels...but you dont account for the width of the text. So you are just arbitrarily drawing it on the screen somewhere if you change the text sizes.text_pos = text.get_rect(); text_pos.y = pos2; text_pos.x = 118 ... pos+=65 pos2+=65 ... text_pos = text.get_rect(); text_pos.y = pos; text_pos.x = 98 ... text_pos.x = 15
The proper way to handle text objects positioning. You dont need to do anyhting other than
text_rect.center = screen_rect.center
have all your string as text, text_rect is your rect of the current text updated every frame, and draw that object to the center of the screen. Then it wouldnt matter what size the text is.
This doesnt change the size of the text, but it does change the text string itself. And it would do the same if the size was changed each time. The text object is always centered on the screen. Regardless of whether the string is 1 digit or 10 digits, size of text, font style, etc.
https://github.com/metulburr/pygame_code...r_timed.py
To be honest your whole code is quite sloppy. If i did it i would replace 90% of your code. You should use format method instead of concatenating strings. I would use a class for the number to clean up some of the code.
Recommended Tutorials: