pygame - python display a character at a time -


so i'm recreating part of pokemon yellow (trying make close original possible) , 2 days i'm searching smart , efficient way render , display string 1 character @ time in textbox, pokemon games!(by way i'm using pygame , python). know way of achieving this? i've tried many things when rendering 1 character @ time, there inadequate space between them. sorry long question! cheers, alex

(edit) interest guys!!! i'm not sure if know correct way display code here, if should copy paste in here or upload in dropbox or somewhere else..

(edit2) clarify, use font @ size 28, way i'm trying render characters right now, make list every element has format (character_to_render,x_pos_to_render,y_pos_to_render). next character (character2_to_render,x_pos_to_render + 28,y_pos_to_render). approaching problem way, leaves inadequate space between characters , others fine.

(edit 3) : answers guys ! after closely observing emulator, noticed inadequate spacing between rendered characters apparent there well! i'll ignore issue andover on project !! cheers , have nice day!

ok here best solution have come far.

you want able display string, want 1 character @ time. strings can string[0:len(string)] return whole string. thinking , please correct me if i'm wrong, lower fps couple seconds, or if not want because still want accept user input skip text.

so have while loop, , check if text being displayed. if is, want add new letter string displaying screen. recommend using class text displayed on screen.

surf = pygame.surface(80, 80) text = textboxstring("hello world") font = pygame.font.sysfont("arial", 18) while true:     event in pygame.event.get():         if event.type == quit:             pygame.quit()             exit()         elif event.type == mousebuttonup:             text.showall()     surf.fill((0,0,0))     text = font.render(text.currentstring, (0,0,0))     surf.blit(text, (0,0))     text.addon()   class textboxstring:     def __init__(self, string):         #string dealing         self.totalstring = string         self.currentstring = string[0]         #how many characters want shown screen         self.length = 0         #this means every 4 times through your          #while loop new char displayed         self.speed = 4     def addon(self) #adds 1 loop num , checks if loop num equals speed         self.loopnum += 1         if self.loopnum == self.speed:             self.length += 1             self.loopnum=0         self.currentstring = totalstring[0: self.length]     def showall(self):         self.length = len(self.totalstring)         self.currentstring = [0: self.length] 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -