May-27-2019, 07:18 PM
I decided to start it from scratch. I fro one wanted your opinion on how I am starting and I also need to know how to fix one of my problems. Originally I had the login and two text boxes. The button was only detecting clicks at certain times though so I separated it to give it a bigger range of detection. It still won't work though.
Here is the full code if you could take a quick scan and grade it
Here is the full code if you could take a quick scan and grade it
import pygame, random, os, sys from functools import partial from pathlib import Path from DestinationFunc import Screen_Display as SD, Button as BT, TextBox as TB pygame.init() width = 800 height = 800 fps = 80 Screen = pygame.display.set_mode((width, height)) clock = pygame.time.Clock() UserData = {'Sheepposu' : {'password' : 'password'}} class Player(): def __init__(): pass class Enemy(): def __init__(): pass def SignIn(): #Intro sizeVar = 1 OrganizationTup = (((205, 0, 0), 405, 295), ((215, 0, 0), 404, 296), ((225, 0, 0), 403, 297), ((235, 0, 0), 402, 298), ((245, 0, 0), 401, 299), ((255, 0, 0), 400, 300)) while sizeVar < 120: for event in pygame.event.get(): if event.type == pygame.QUIT: EndGame(True) sizeVar += 1 Screen.fill((0, 0, 255)) for x in OrganizationTup: SD.message_display(Screen, 'Destination', sizeVar, x[0], x[1], x[2]) pygame.display.update() clock.tick(fps) Logging = True while Logging: #Login username = TB((200, 500, 400, 100), 'Type Username', 50, (0, 0, 255)) password = TB((200, 650, 400, 100), 'Type Password', 50, (0, 0, 255)) login = BT((650, 550, 100, 50), 'Log In', 40, (0, 0, 255)) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: EndGame(True) username.start(Screen, (255, 0, 0), 20) password.start(Screen, (255, 0, 0), 20) if username.text != '' and password.text != '': break pygame.display.update() clock.tick(fps) #Verification done = False while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: EndGame() login.draw(Screen, (0, 255, 0)) done = login.optClick(Screen, (0, 200, 0), (0, 255, 0)) pygame.display.update() clock.tick(fps) UserName = username.text PassWord = password.text for name in UserData: if UserName.lower() == name.lower(): if PassWord == UserData[name]['password']: Logging = False else: pygame.draw.rect(Screen, (0, 0, 255), (0, 350, 800, 50)) SD.message_display(Screen, 'Invalid Password', 40, (255, 0, 0), 400, 450) else: pygame.draw.rect(Screen, (0, 0, 255), (0, 350, 800, 50)) SD.message_display(Screen, 'Invalid Username', 40, (255, 0, 0), 400, 450) def LevelMaker(): pass def Main(): SignIn() def EndGame(leaving=None): if leaving: pass else: pass Main() pygame.quit() sys.exit()Button Code -
for event in pygame.event.get(): clicked = pygame.mouse.get_pressed() if event.type == pygame.MOUSEBUTTONDOWN and clicked[0] == 1 and pygame.Rect((200, 650, 400, 100)).collidepoint(pygame.mouse.get_pos()): #code