Reputation: 95
import pygame
import math
def StoryLine():
pygame.init()
width = 1104
height = 644
white = 255,255,255
red = 255,0,0
color = 255,0,0
black = 0,0,0
cyan = 0,255,255
gameDisplay = pygame.display.set_mode((width,height))
pygame.display.set_caption('War Games 3')
Map = pygame.image.load('Map3Cut.png')
Map = pygame.transform.scale(Map, (1104,644))
stop = False
while not stop:
gameDisplay.blit(Map, (0,0))
StoryText = pygame.font.SysFont("monospace",25)
StoryFont = StoryText.render('Click ENTER to continue...',5,(red))
gameDisplay.blit(StoryFont,(50,500))
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
mainGame()
if event.type == pygame.QUIT:
pygame.quit()
quit()
pygame.display.update()
Here I have some text that tells the user to click enter to continue. I was wondering how I could blit only one index of the string for example I could blit
StoryFont[1] and that would only blit 'l' to the screen. I did try this and it did not work. Thank you for any help.
Upvotes: 0
Views: 68
Reputation: 680
As far as I know, you can't edit a pygame render instance. However, you could create a variable that contains a normal string, then render that. For instance:
while not stop:
original_txt = 'Click ENTER to continue...'
text_to_be_displayed = original_txt[1]
gameDisplay.blit(Map, (0,0))
StoryText = pygame.font.SysFont("monospace",25)
StoryFont = StoryText.render(text_to_be_displayed,5,(red))
gameDisplay.blit(StoryFont,(50,500))
Hope this helped.
Upvotes: 1