• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Apr 9th, 2020 246 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2. import random
3. import pygame as pg
4. pg.init()
5.
6. #init seats
7. seats =  * (7)
8. appr =  * (31)
9. for i in range(7):
10.     seats[i] =  * (5)
11.
12. #init screen
13. width, height = 705, 405
14. screen = pg.display.set_mode((width, height))
15. pg.display.set_caption("Classroom")
16.
17. #init background
18. bg = pg.Surface(screen.get_size())
19. bg = bg.convert()
20. bg.fill((0, 0, 0))
21.
22. #draw game_map
23. def Draw() :
24.     x = 20
25.     y = 20
26.     for i in range(30) :
27.         appr[i+1] = 0
28.     for i in range(7) :
29.         for j in range(5) :
30.             pg.draw.rect(bg, (255,255,255),[i*100+5, j*80+5, 95, 75], 0)
31.             pg.draw.rect(bg, (  0,  0,  0),[i*100+5, j*80+5, 95, 75], 1)
32.             if (i == 0 and j == 0) :
33.                 continue
34.             if (i == 6 and j == 0) :
35.                 continue
36.             if (i == 0 and j == 4) :
37.                 continue
38.             if (i == 3 and j == 4) :
39.                 continue
40.             if (i == 6 and j == 4) :
41.                 continue
42.             tmp = math.ceil(random.random()*30)
43.             while (appr[tmp] == 1) :
44.                 tmp = math.ceil(random.random()*30)
45.             seats[i][j] = tmp
46.             appr[tmp] = 1
47.             font = pg.font.SysFont("simhei", 50)
48.             text = font.render(str(seats[i][j]), True, (0,0,0))
49.             bg.blit(text, (i*100+32, j*80+27))
50.     #show screen
51.     screen.blit(bg, (0,0))
52.     pg.display.update()
53.
54. Draw()
55.
56. #exit
57. running = True
58. while running:
59.     if pg.mouse.get_pressed() :
60.         Draw()
61.     for event in pg.event.get():
62.         if event.type == pg.QUIT:
63.             running = False
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top