I'm a beginner and I'm having some trouble setting up a defined function in pygame. Here's the code:
import random, pygame, sys, time
from pygame.locals import *
pygame.init()
WINDOWWIDTH=600
WINDOWHEIGHT=600
TEXTCOLOR=255,255,255
BACKGROUNDCOLOR=0,0,0
windowSurface=pygame.display.set_mode((int(WINDOWWIDTH/2), int(WINDOWHEIGHT/2)),0,32)
Stren=0
End=0
Dev=0
Awar=0
Int=0
Wil=0
Agi=0
Luk=0
att=[Stren, End, Dev, Awar, Int, Wil, Agi, Luk]
def displayText(text, font, surface, x, y):
textobj=pygame.font.render(text, font, TEXTCOLOR)
textrect=textobj.get_rect()
textrect.topleft=(x, y)
surface.blit(textobj, textrect)
displayText('''From where dost thou hail?
1)Caresh
2)Tenin
3)Heartlands
4)Swamplands
5)Sub-Tenin Desert''', None, windowSurface, (WINDOWWIDTH/2), (WINDOWHEIGHT/2))
And here's the resultant error:
Traceback (most recent call last):
File "C:/Python Prog/CharRolling.py", line 31, in <module>
5)Sub-Tenin Desert''', None, windowSurface, (WINDOWWIDTH/2), (WINDOWHEIGHT/2))
File "C:/Python Prog/CharRolling.py", line 21, in displayText
textobj=pygame.font.render(text, font, TEXTCOLOR)
AttributeError: 'module' object has no attribute 'render'
I've got no idea why this won't work. I was following some instructions from a python programming lesson book (as far as the def statement is concerned). Please help me.