May-22-2018, 10:45 PM
(This post was last modified: May-22-2018, 10:46 PM by GrumpyOgre.)
Hi there, I am working on creating a simple text class where you could create a text object, define the text, text size, location, colour (and eventually duration on scree).
I'm obviously having a brain fart here. My message isn't rendering. I've no errors. But the message doesn't display. Can anyone see what obviously silly mistake I've made? This is driving me bonkers!!
I'm obviously having a brain fart here. My message isn't rendering. I've no errors. But the message doesn't display. Can anyone see what obviously silly mistake I've made? This is driving me bonkers!!
#GrumpyOgre #Text Class import pygame, sys from pygame.locals import * # set up the window and environment pygame.init() iFPS = 160 # frames per second setting fpsClock = pygame.time.Clock() frmWindow = pygame.display.set_mode((600, 600), 0, 32) pygame.display.set_caption('Text Demo') # pen inks clrBlack = (0, 0, 0) clrRed = (255, 0, 0) clrGreen = (0, 255, 0) clrBlue = (0, 0, 255) clrWhite = (255, 255, 255) class text: def __init__(self): self.x = 0 self.y = 0 self.colour = clrBlack self.size = 12 self.duration = 10 self.text = "" self.font = pygame.font.Font('comic.ttf', self.size) self.surface = self.font.render(self.text , 1, self.colour) def define(self, x, y, colour, size, duration, message): self.x = x self.y = y self.colour = colour self.size = size self.duration = duration self.text = message def display(self): frmWindow.blit( self.surface, (self.x,self.y)) message = text() message.define(200, 200, clrBlack, 12, 20, 'boom') frmWindow.fill(clrWhite) while True: # the main game loop for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() message.display() pygame.display.update() fpsClock.tick(iFPS)Thx for any tips in advance.