| I'm having trouble with a small project. Here's what it needs to do: Has variables for window width and window height and creates a window of that size. Has variables which control the number of columns and number of rows. From this, create a checkboard pattern which evenly fills the window. On approximately 10% of the squares (chosen at random) draw an image which is sized to just fit inside a checkboard square (use the smallest dimension). Keep the program open for 3 seconds and then quit. I've attached the code I have so far. "Pic" is just a place holder for an actual image. Not sure what to do with the while statements that are empty in the code. Thanks for the help, Brett |
# Lab 3: Game Board import pygame import time
pygame.display.init()
WinH = 600
WinW = 800
num_rows = 8
num_cols = 12
screen = pygame.display.set_mode((WinW,WinH))
screen.fill((128,128,128))
markSurf = pygame.image.load("#Pic")
color = (0,0,0)
cell_width = WinW/num_cols
cell_height = WinH/num_rows
while #...
while #...
pygame.draw.rect(screen, color, (cell_width,cell_height), 0)
if color == (0,0,0):
color = (0,255,0)
else:
color = (0,0,0)
curRow = 0
while curRow < #....:
if curRow %2 = 0:
color = (0,0,0)
else:
color = (0,255,0)
curRow +=1
pygame.display.update()
time.sleep(3)
pygame.display.quit()
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
