我正在尝试创建一个宾果游戏程序,用户输入他们的号码和电路板数量。然后,无论何时调用该号码,他们都会输入并显示在屏幕上。所以它就像一个跟踪程序。无论如何,我试图让这个循环运行,所以程序知道正在调用的是什么数字。问题是它甚至没有运行。它没有问我电话号码。我确信这是我想念的简单事。这是代码的一部分。顺便说一句,这是一种功能。
global previous_numbers_called
previous_numbers_called=[]
for i in range(75):
called=int(input("Enter number called:"))
previous_numbers_called.append(called)
以下是我需要它的全部代码。
import pygame
import math
import color
import sys
import os
import random
import cx_Freeze
import time
import glob
pygame.init()
white=color.white
black=color.black
blue=color.blue
screen_width=800
screen_height=600
gamedisplay=pygame.display.set_mode((screen_width,screen_height))
pygame.display.set_caption('Bingo Tracker')
clock=pygame.time.Clock()
FPS=60
the_x=pygame.image.load('mark.png')
instructions=pygame.image.load('bingotrackerinstructions.png')
bingocard=pygame.image.load('bingocard.png')
arrow=pygame.image.load('arrow.png')
super_smallfont=pygame.font.SysFont("Arial",int(screen_width/80))
smallfont=pygame.font.SysFont("Arial",int(screen_width/32))
mediumfont=pygame.font.SysFont("Arial",int(screen_width/16))
largefont=pygame.font.SysFont("Arial",int(screen_width/10))
def intro_screen():
start_message = mediumfont.render(str("Welcome to Bingo Tracker!!!"), True,black)
gamedisplay.blit(start_message,(screen_width/5.614035088,screen_height/40))
gamedisplay.blit(instructions,(0,-20))
gamedisplay.blit(bingocard,(300,375))
gamedisplay.blit(arrow,(300,250))
pygame.display.update()
def board_1(): #left to right 13 is freespace
square_1=pygame.draw.rect(gamedisplay, black,((0,0),(50,50)),2)
square_2=pygame.draw.rect(gamedisplay, black,((50,0),(50,50)),2)
square_3=pygame.draw.rect(gamedisplay, black,((100,0),(50,50)),2)
square_4=pygame.draw.rect(gamedisplay, black,((150,0),(50,50)),2)
square_5=pygame.draw.rect(gamedisplay, black,((200,0),(50,50)),2)
square_6=pygame.draw.rect(gamedisplay, black,((0,50),(50,50)),2)
square_7=pygame.draw.rect(gamedisplay, black,((50,50),(50,50)),2)
square_8=pygame.draw.rect(gamedisplay, black,((100,50),(50,50)),2)
square_9=pygame.draw.rect(gamedisplay, black,((150,50),(50,50)),2)
square_10=pygame.draw.rect(gamedisplay, black,((200,50),(50,50)),2)
square_11=pygame.draw.rect(gamedisplay, black,((0,100),(50,50)),2)
square_12=pygame.draw.rect(gamedisplay, black,((50,100),(50,50)),2)
square_13=pygame.draw.rect(gamedisplay, black,((100,100),(50,50)),2)
square_14=pygame.draw.rect(gamedisplay, black,((150,100),(50,50)),2)
square_15=pygame.draw.rect(gamedisplay, black,((200,100),(50,50)),2)
square_16=pygame.draw.rect(gamedisplay, black,((0,150),(50,50)),2)
square_17=pygame.draw.rect(gamedisplay, black,((50,150),(50,50)),2)
square_18=pygame.draw.rect(gamedisplay, black,((100,150),(50,50)),2)
square_19=pygame.draw.rect(gamedisplay, black,((150,150),(50,50)),2)
square_20=pygame.draw.rect(gamedisplay, black,((200,150),(50,50)),2)
square_21=pygame.draw.rect(gamedisplay, black,((0,200),(50,50)),2)
square_22=pygame.draw.rect(gamedisplay, black,((50,200),(50,50)),2)
square_23=pygame.draw.rect(gamedisplay, black,((100,200),(50,50)),2)
square_24=pygame.draw.rect(gamedisplay, black,((150,200),(50,50)),2)
square_25=pygame.draw.rect(gamedisplay, black,((200,200),(50,50)),2)
freespace_1 = smallfont.render(str("Free"), True,black)
gamedisplay.blit(freespace_1,(105,110))
gamedisplay.blit(the_x,(100,100))
number_of_x_board_1=1
board_1_first_number=int(input("Enter your numbers for board number 1:"))
board_1_second_number=int(input("Enter your numbers for board number 1:"))
board_1_third_number=int(input("Enter your numbers for board number 1:"))
board_1_forth_number=int(input("Enter your numbers for board number 1:"))
board_1_fifth_number=int(input("Enter your numbers for board number 1:"))
board_1_sixth_number=int(input("Enter your numbers for board number 1:"))
board_1_seventh_number=int(input("Enter your numbers for board number 1:"))
board_1_eighth_number=int(input("Enter your numbers for board number 1:"))
board_1_ninth_number=int(input("Enter your numbers for board number 1:"))
board_1_tenth_number=int(input("Enter your numbers for board number 1:"))
board_1_eleventh_number=int(input("Enter your numbers for board number 1:"))
board_1_twelvth_number=int(input("Enter your numbers for board number 1:"))
board_1_thirdteenth_number=int(input("Enter your numbers for board number 1:"))
board_1_forthteenth_number=int(input("Enter your numbers for board number 1:"))
board_1_fifthteenth_number=int(input("Enter your numbers for board number 1:"))
board_1_sixthteenth_number=int(input("Enter your numbers for board number 1:"))
board_1_seventeenth_number=int(input("Enter your numbers for board number 1:"))
board_1_eighthteenth_number=int(input("Enter your numbers for board number 1:"))
board_1_ninthteenth_number=int(input("Enter your numbers for board number 1:"))
board_1_twentyth_number=int(input("Enter your numbers for board number 1:"))
board_1_twentyfirst_number=int(input("Enter your numbers for board number 1:"))
board_1_twentysecond_number=int(input("Enter your numbers for board number 1:"))
board_1_twentythird_number=int(input("Enter your numbers for board number 1:"))
board_1_twentyforth_number=int(input("Enter your numbers for board number 1:"))
text_board1_1=smallfont.render(str(board_1_first_number), True,black)
gamedisplay.blit(text_board1_1,(13,9)) #x+13,y+9
text_board1_2=smallfont.render(str(board_1_second_number), True,black)
gamedisplay.blit(text_board1_2,(63,9))
text_board1_3=smallfont.render(str(board_1_third_number), True,black)
gamedisplay.blit(text_board1_3,(113,9))
text_board1_4=smallfont.render(str(board_1_forth_number), True,black)
gamedisplay.blit(text_board1_4,(163,9))
text_board1_5=smallfont.render(str(board_1_fifth_number), True,black)
gamedisplay.blit(text_board1_5,(213,9))
text_board1_6=smallfont.render(str(board_1_sixth_number), True,black)
gamedisplay.blit(text_board1_6,(13,59))
text_board1_7=smallfont.render(str(board_1_seventh_number), True,black)
gamedisplay.blit(text_board1_7,(63,59))
text_board1_8=smallfont.render(str(board_1_eighth_number), True,black)
gamedisplay.blit(text_board1_8,(113,59))
text_board1_9=smallfont.render(str(board_1_ninth_number), True,black)
gamedisplay.blit(text_board1_9,(163,59))
text_board1_10=smallfont.render(str(board_1_tenth_number), True,black)
gamedisplay.blit(text_board1_10,(213,59))
text_board1_11=smallfont.render(str(board_1_eleventh_number), True,black)
gamedisplay.blit(text_board1_11,(13,109))
text_board1_12=smallfont.render(str(board_1_twelvth_number), True,black)
gamedisplay.blit(text_board1_12,(63,109))
text_board1_13=smallfont.render(str(board_1_thirdteenth_number), True,black)
gamedisplay.blit(text_board1_13,(163,109))
text_board1_14=smallfont.render(str(board_1_forthteenth_number), True,black)
gamedisplay.blit(text_board1_14,(213,109))
text_board1_15=smallfont.render(str(board_1_fifthteenth_number), True,black)
gamedisplay.blit(text_board1_15,(13,159))
text_board1_16=smallfont.render(str(board_1_sixthteenth_number), True,black)
gamedisplay.blit(text_board1_16,(63,159))
text_board1_17=smallfont.render(str(board_1_seventeenth_number), True,black)
gamedisplay.blit(text_board1_17,(113,159))
text_board1_18=smallfont.render(str(board_1_eighthteenth_number), True,black)
gamedisplay.blit(text_board1_18,(163,159))
text_board1_19=smallfont.render(str(board_1_ninthteenth_number), True,black)
gamedisplay.blit(text_board1_19,(213,159))
text_board1_20=smallfont.render(str(board_1_twentyth_number), True,black)
gamedisplay.blit(text_board1_20,(13,209))
text_board1_21=smallfont.render(str(board_1_twentyfirst_number), True,black)
gamedisplay.blit(text_board1_21,(63,209))
text_board1_22=smallfont.render(str(board_1_twentysecond_number), True,black)
gamedisplay.blit(text_board1_22,(113,209))
text_board1_23=smallfont.render(str(board_1_twentythird_number), True,black)
gamedisplay.blit(text_board1_23,(163,209))
text_board1_24=smallfont.render(str(board_1_twentyforth_number), True,black)
gamedisplay.blit(text_board1_24,(213,209))
#the input numbers go here,
#then you can get text right in here also.
#then you can just make more of the boards and based on what number of
#boards, then it will run the required number of board functions.
#Use 2 loops to take care of memory retain information
def gameloop():
gamedisplay.fill(white)
pygame.display.update()
while True:
try:
number_of_boards=int(input("How many boards do you have?:"))
except ValueError:
print("Please enter a valid board number.")
number_of_boards=int(input("How many boards do you have?:"))
if number_of_boards<1:
print("Sorry, you must enter a number of 1 or greater.")
number_of_boards=int(input("How many boards do you have?:"))
else:
break
if number_of_boards==1:
board_1()
pygame.display.update()
stop=True
while stop==True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
stop=False
pygame.quit()
sys.exit()
quit()
pygame.display.update()
pygame.display.update()
global previous_numbers_called
previous_numbers_called=[]
for i in range(75):
called=int(input("Enter number called:"))
previous_numbers_called.append(called)
pygame.display.update()
gamedisplay.fill(white)
pygame.display.update()
intro_screen()
are_you_done_reading=input("Enter y once you're done reading:").lower()
while not are_you_done_reading=='y':
pass
gameloop()