Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import random
- import pygame as pg
- pg.init()
- #init seats
- seats = [0] * (7)
- appr = [0] * (31)
- for i in range(7):
- seats[i] = [0] * (5)
- #init screen
- width, height = 705, 405
- screen = pg.display.set_mode((width, height))
- pg.display.set_caption("Classroom")
- #init background
- bg = pg.Surface(screen.get_size())
- bg = bg.convert()
- bg.fill((0, 0, 0))
- #draw game_map
- def Draw() :
- x = 20
- y = 20
- for i in range(30) :
- appr[i+1] = 0
- for i in range(7) :
- for j in range(5) :
- pg.draw.rect(bg, (255,255,255),[i*100+5, j*80+5, 95, 75], 0)
- pg.draw.rect(bg, ( 0, 0, 0),[i*100+5, j*80+5, 95, 75], 1)
- if (i == 0 and j == 0) :
- continue
- if (i == 6 and j == 0) :
- continue
- if (i == 0 and j == 4) :
- continue
- if (i == 3 and j == 4) :
- continue
- if (i == 6 and j == 4) :
- continue
- tmp = math.ceil(random.random()*30)
- while (appr[tmp] == 1) :
- tmp = math.ceil(random.random()*30)
- seats[i][j] = tmp
- appr[tmp] = 1
- font = pg.font.SysFont("simhei", 50)
- text = font.render(str(seats[i][j]), True, (0,0,0))
- bg.blit(text, (i*100+32, j*80+27))
- #show screen
- screen.blit(bg, (0,0))
- pg.display.update()
- Draw()
- #exit
- running = True
- while running:
- if pg.mouse.get_pressed()[0] :
- Draw()
- for event in pg.event.get():
- if event.type == pg.QUIT:
- running = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement