I asked a similar question about two weeks ago, and have since updated my code to no avail. It absolutely boggles my mind how convoluted it is to simply render some text in PyGame.
Here is the method for the UI I'm attempting to implement:
def gui(self):
self.hpdisplay = self.font.render('HP: 100', True, white)
self.hpdisplay_rect = self.hpdisplay.get_rect(x=10, y=10)
self.screen.blit(self.hpdisplay, self.hpdisplay_rect)
According to PyGame documentation, this is exactly how I'm supposed to do this, and it's even identical to some text I managed to render successfully in a different part of my code which I'll show here:
title = self.font.render('Cambria', True, white)
title_rect = title.get_rect(x=10, y=10)
self.screen.blit(title, title_rect)
The UI that isn't working is supposed to appear when I call this new() method:
def new(self):
self.playing = True
self.all_sprites = pygame.sprite.LayeredUpdates()
self.tiles = pygame.sprite.LayeredUpdates()
self.blocks = pygame.sprite.LayeredUpdates()
self.buildings = pygame.sprite.LayeredUpdates()
self.player = Player(self, self.startx, self.starty)
self.enemies = pygame.sprite.LayeredUpdates()
self.attacks = pygame.sprite.LayeredUpdates()
self.triggers = pygame.sprite.LayeredUpdates()
self.TileCreate()
self.gui()
This method renders all the sprites, TileCreate arranges all the sprites in the tilemap loading system, and gui() is SUPPOSED to render some text at the top of the screen, yet no matter what I do, it simply refuses to render ANYTHING.