from livewires import games, color
#Creating and validating the pygame screen.
scrwidth = 640
scrheight = 480
fps = 50
myscr = games.Screen(scrwidth, scrheight)
#Loading an image into memory to create an image object
wall_image = games.load_image("wall.jpg", transparent = False)
myscr.set_background (wall_image)
#Printing Arbitary Score
texty = games.Text(value = "Score: 2048321",
size = 70,
color = color.black,
x = 400,
y = 30)
myscr.add(texty)
myscr.mainloop()
Pour une raison quelconque, je suis incapable d'imprimer la chaîne de score dans la position que je l'ai assigné à. Quand j'ai fait la même chose sans assigner de variables aux objets donnés, j'ai réussi à le faire avec succès, mais maintenant je ne suis pas en train de l'assigner à une variable.programme Python Debugging pygame
Toute contribution serait appréciée. Merci d'avance.
EDIT: Comme demandé, le code de travail.
from livewires import games, color
games.init(screen_width = 640, screen_height = 480, fps = 50)
wall_image = games.load_image("wall.jpg", transparent = False)
games.screen.background = wall_image
score = games.Text(value = 1756521,
size = 60,
color = color.black,
x = 550,
y = 30)
games.screen.add(score)
games.screen.mainloop()
Nous y sommes! Code de travail:
from livewires import games, color
#Creating and validating the pygame screen.
scrwidth = 640
scrheight = 480
fpsy = 50
games.init(screen_width = scrwidth, screen_height =scrheight, fps = fpsy)
myscr = games.screen
#Loading an image into memory to create an image object
wall_image = games.load_image("wall.jpg", transparent = False)
myscr.background = wall_image
#Printing Arbitary Score
texty = games.Text(value = "Score: 2048321",
size = 70,
color = color.black,
x = 400,
y = 30)
myscr.add(texty)
myscr.mainloop()
Pouvez-vous fournir la version du code vous parlez, où vous "avez fait la même chose sans assigner de variables aux objets donnés", et cela a fonctionné? –
pouvez-vous poster le code initial avant d'attribuer des variables, qui a fonctionné? –
Bien sûr, affiché juste sous le code qui ne fonctionne pas. Vérifiez dans une seconde. – Louis93