import time
import pygame
import random
import math
n=50
m=6
WIDTH = 1200
HEIGHT = 675
FPS = 30
namelist=list(range(n))
namelistnew=list()
# define colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
# initialize pygame and create window
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("安阳县二中附中电脑派位系统演示程序")
# 加载图片
image = "background.jpg"
bg_img = pygame.image.load(image).convert() # 加载方式1(适用于任何普通图像)
screen.blit(bg_img, (0, 0))
pygame.display.flip()
clock = pygame.time.Clock()
# pygame.mouse.set_visible(False)
myfont = pygame.font.Font("C:\Windows\Fonts\msyhbd.ttc",20)
textImage1 = myfont.render("结束", True, WHITE)
start1=random.randint(1,n)
start0=start1
step1=random.randint(3,8)
# Game loop
running = True
count = 0
start = time.time()
count1=0
while running:
# keep loop running at the right speed
clock.tick(FPS)
# Process input (events)
for event in pygame.event.get():
if event.type == pygame.KEYDOWN or event.type==pygame.MOUSEBUTTONDOWN:
if len(namelistnew)>m:
# listImage4 = myfont.render('END', True, WHITE)
textImage1 = myfont.render("本次演示结束,按任意键或鼠标点击重新开始演示", True, WHITE)
screen.blit(textImage1, (10, 400))
pygame.display.flip()
namelist = list(range(n))
namelistnew = list()
start1 = random.randint(1, n)
start0=start1
step1 = random.randint(3, 8)
continue
count+=1
screen.fill(BLACK)
flag=len(namelistnew)
while len(namelistnew) <= flag:
pick = start1
if pick not in namelist:
start1=(start1+step1)% n
continue
listImage5 = myfont.render(str(start0), True, GREEN)
textImage2=myfont.render("如果起始号为:",True,GREEN)
screen.blit(listImage5, (150, 60))
screen.blit(textImage2, (10, 60))
textImage6 = myfont.render("如果间隔号为:", True, GREEN)
listImage6 = myfont.render(str(step1), True, GREEN)
screen.blit(listImage6, (150, 90))
screen.blit(textImage6, (10, 90))
len1=len(namelist)
dot=2*math.pi/len1
textImage3 = myfont.render("所有待抽取的学生的编号首尾相接", True, GREEN)
screen.blit(textImage3, (660, 160))
r=4.27*len1
for i in range(len1):
text1=namelist[i]
if text1==pick:
listImage1 = myfont.render(str(text1), True, RED)
screen.blit(listImage1, (800 + r * math.cos(dot * i), 400 + r * math.sin(dot * i)))
else:
listImage1 = myfont.render(str(text1), True, WHITE)
screen.blit(listImage1, (800+r*math.cos(dot*i), 400+r*math.sin(dot*i))) # 输出现在总队列#
textImage4 = myfont.render("目前选中的学生的编号:", True, GREEN)
screen.blit(textImage4, (10, 200))
listImage2 = myfont.render(str(pick), True, RED)
screen.blit(listImage2, (230, 200)) # 输出过程中挑选出的人员
namelistnew.append(pick)
namelist.remove(pick)
textImage4 = myfont.render("已经选出的学生的编号:", True, GREEN)
screen.blit(textImage4, (10, 300))
listImage3 = myfont.render(str(namelistnew), True, WHITE)
screen.blit(listImage3, (230, 300)) # 输出挑选出的人员
textImage4 = myfont.render("目前已经选出:", True, GREEN)
screen.blit(textImage4, (10, 350))
listImage3 = myfont.render(str(len(namelistnew)), True, WHITE)
screen.blit(listImage3, (150, 350))
start1=(start1 +step1) % n
pygame.display.flip()
if count>count1:
count1+=1
continue
# check for closing window
if event.type == pygame.QUIT:
running = False
pygame.quit()
import pygame
import random
import math
n=50
m=6
WIDTH = 1200
HEIGHT = 675
FPS = 30
namelist=list(range(n))
namelistnew=list()
# define colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
# initialize pygame and create window
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("安阳县二中附中电脑派位系统演示程序")
# 加载图片
image = "background.jpg"
bg_img = pygame.image.load(image).convert() # 加载方式1(适用于任何普通图像)
screen.blit(bg_img, (0, 0))
pygame.display.flip()
clock = pygame.time.Clock()
# pygame.mouse.set_visible(False)
myfont = pygame.font.Font("C:\Windows\Fonts\msyhbd.ttc",20)
textImage1 = myfont.render("结束", True, WHITE)
start1=random.randint(1,n)
start0=start1
step1=random.randint(3,8)
# Game loop
running = True
count = 0
start = time.time()
count1=0
while running:
# keep loop running at the right speed
clock.tick(FPS)
# Process input (events)
for event in pygame.event.get():
if event.type == pygame.KEYDOWN or event.type==pygame.MOUSEBUTTONDOWN:
if len(namelistnew)>m:
# listImage4 = myfont.render('END', True, WHITE)
textImage1 = myfont.render("本次演示结束,按任意键或鼠标点击重新开始演示", True, WHITE)
screen.blit(textImage1, (10, 400))
pygame.display.flip()
namelist = list(range(n))
namelistnew = list()
start1 = random.randint(1, n)
start0=start1
step1 = random.randint(3, 8)
continue
count+=1
screen.fill(BLACK)
flag=len(namelistnew)
while len(namelistnew) <= flag:
pick = start1
if pick not in namelist:
start1=(start1+step1)% n
continue
listImage5 = myfont.render(str(start0), True, GREEN)
textImage2=myfont.render("如果起始号为:",True,GREEN)
screen.blit(listImage5, (150, 60))
screen.blit(textImage2, (10, 60))
textImage6 = myfont.render("如果间隔号为:", True, GREEN)
listImage6 = myfont.render(str(step1), True, GREEN)
screen.blit(listImage6, (150, 90))
screen.blit(textImage6, (10, 90))
len1=len(namelist)
dot=2*math.pi/len1
textImage3 = myfont.render("所有待抽取的学生的编号首尾相接", True, GREEN)
screen.blit(textImage3, (660, 160))
r=4.27*len1
for i in range(len1):
text1=namelist[i]
if text1==pick:
listImage1 = myfont.render(str(text1), True, RED)
screen.blit(listImage1, (800 + r * math.cos(dot * i), 400 + r * math.sin(dot * i)))
else:
listImage1 = myfont.render(str(text1), True, WHITE)
screen.blit(listImage1, (800+r*math.cos(dot*i), 400+r*math.sin(dot*i))) # 输出现在总队列#
textImage4 = myfont.render("目前选中的学生的编号:", True, GREEN)
screen.blit(textImage4, (10, 200))
listImage2 = myfont.render(str(pick), True, RED)
screen.blit(listImage2, (230, 200)) # 输出过程中挑选出的人员
namelistnew.append(pick)
namelist.remove(pick)
textImage4 = myfont.render("已经选出的学生的编号:", True, GREEN)
screen.blit(textImage4, (10, 300))
listImage3 = myfont.render(str(namelistnew), True, WHITE)
screen.blit(listImage3, (230, 300)) # 输出挑选出的人员
textImage4 = myfont.render("目前已经选出:", True, GREEN)
screen.blit(textImage4, (10, 350))
listImage3 = myfont.render(str(len(namelistnew)), True, WHITE)
screen.blit(listImage3, (150, 350))
start1=(start1 +step1) % n
pygame.display.flip()
if count>count1:
count1+=1
continue
# check for closing window
if event.type == pygame.QUIT:
running = False
pygame.quit()