JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

thing 4 kaleb | JustPaste.app
about 1 month ago0 views
👨‍💻Programming

thing 4 kaleb

import pygame
import sys
import string
import time
import random

pygame.init()

#init functions
def MakeText(pos, text, color, size):
    newText = pygame.font.SysFont("Consolas",size).render(text, True, color)
    newText_rect = newText.get_rect()
    newText_rect.center = pos
    screen.blit(newText, newText_rect)

    return newText_rect


#init le screen
screensize = (500,500)
screen = pygame.display.set_mode(screensize)
centerpos = (screensize[0] // 2, screensize[1] // 2)

pygame.display.set_caption("FOR KALEB")

#init variables
userinput = ""
correctPass = ""
status = "home"
for i in range(0,10):
    correctPass = correctPass + string.ascii_lowercase[random.randint(0,len(string.ascii_lowercase) - 1)]

print(correctPass)

#init colors
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
white = (255,255,255)
black = (0,0,0)
bgColor = (250, 245, 230)

#init rect
btnRect = pygame.Rect(0,0,150,50)
mathRect = pygame.Rect(0,0,150,50)
thingRect = pygame.Rect(0,0,3,25)

gameloop = not not not not 1 == 1

while gameloop:
    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_BACKSPACE and status == "home":
                userinput = userinput[:-1]
            
            
            
            for key_code in range(pygame.K_a, pygame.K_z + 1):
                if pygame.key.get_pressed()[key_code] and status == "home":
                    key_name = pygame.key.name(key_code)
                    userinput = userinput + key_name

                    
    screen.fill(bgColor)
    

    if status == "home":
        btnRect.center = centerpos[0],centerpos[1] + 50
        pygame.draw.rect(screen, green, btnRect)
        MakeText(btnRect.center, "ENTER", white, 30)

        if len(userinput) == 0:
            MakeText((centerpos[0], centerpos[1] - 50), "Type password here", black, 30)
        else:
            input_Display = MakeText((centerpos[0], centerpos[1] - 50), userinput, black, 30)
            thingRect.bottomright = input_Display.bottomright[0] + 10, input_Display.bottomright[1]

            if round(time.time())%2 == 0:
                pygame.draw.rect(screen, black, thingRect)
            else:
                pygame.draw.rect(screen, bgColor, thingRect)
        
    pygame.display.flip()
← Back to timeline