A simple typewrite effect on the console. This could be nice and also useful when you want to crate some interaction with the user through a command line interface, to focus more on the message you want to send to the user, so that it is not just an estetic matter, but it also lead to a more clear impact on the clearness of the path the user must follow in order to use the program.
import sys, time
def texttime(words):
for c in words:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.1)
texttime("Hello World\n")
Random velocity
import sys, time
from random import randrange
def texttime(words):
for c in words:
sys.stdout.write(c)
sys.stdout.flush()
# if c == " ":
if randrange(1, 5) == 3:
time.sleep(0.1)
text = """
import pygame, sys, random
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird_movement = 0
bird_movement -= 12
flap_sound.play()
if event.key == pygame.K_SPACE and game_active == False:
game_active = True
pipe_list.clear()
bird_rect.center = (100,512)
#bird_movement = 0
score = 0
pygame.display.update()
clock.tick(30)
"""
texttime(text)
Here is an example of the output.
Have fun.
Subscribe to the newsletter for updates
Tkinter templatesTwitter: @pythonprogrammi - python_pygame
Claude's Games
1. Memory gameVideos
Speech recognition gamePygame's Platform Game