Ok, so you might find this stupid and yes I am a beginner when it comes to programming but would it be possible to do something like that? My friend tried to execute it with some extra code to make it complete but it couldn't even start. I'm pretty sure I messed the list up so i appreciate tips and corrections :)
import time
character_list = [a,b,c,d] # creating list with characters
buttons_list = [pygame.K_a,pygame.K_b,pygame.K_c,pygame.K_d]#creating list with key-events
while True:
millis = int(round(time.time()*1000))
hours = int(round( millis / 3600000))
# print a letter to the screen with character_list[hours]
necessary_button = buttons_list[hours]
if event.type == pygame.KEYDOWN:
if event.key == necessary_button:
# do some awesome stuff
So here's the code I got from my friend:
import pygame
pygame.init()
display_width = 1600
display_height = 900
white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
green = (0,155,0)
game_display = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('AYYLMAO')
smallfont = pygame.font.SysFont("comicsansms",25)
def text_objects(text,color,size):
if size == "small":
textSurf = smallfont.render(text, True, color)
return textSurf, textSurf.get_rect()
def message_to_screen(msg, color, y_displace = 0,size = "small"):
textSurf, textRect = text_objects(msg,color,size)
textRect.center = (display_width/2), ( display_height/2)+y_displace
game_display.blit(textSurf, textRect)
def gameLoop():
game_display.fill(white)
character_list = ["a","b","c","d","e"]
buttons_list = [pygame.K_a, pygame.K_b, pygame.K_c, pygame.K_d, pygame.K_e]
message_to_screen(character_list[0], red)
pygame.display.update()
necessary_button = buttons_list[0]
if event.type == pygame.KEYDOWN:
if event.key == necessary_button:
message_to_screen(GG, red)
if event.key == pygame.K_ESCAPE:
pygame.QUIT()
gameLoop()
This prints the "a" to the screen at least but i get the error: "line 38, in gameLoop if event.type == pygame.KEYDOWN: NameError: global name 'event' is not defined." I hope this not just another stupid mistake by me :D