python - Constructing borders for rectangles in Game of life -


i started first programming course in python , i'm having trouble understanding what's wrong code game of life. our task create grid game play in can't understand wrong code (see below).

def paint(target_window, grid):      height = len(grid)     width = len(grid[0])      target_window.setcoords(0,height,width,0)       row in range(height):         col in range(width):             rect = rectangle(point(row,col),point(row + 1, col + 1))         rect.draw(target_window)     target_window.update() 

more specific grid supposed "infinite" game isn't restricted. think .setcoords may have what's wrong.

in case using this graphics library, indeed call of setcoords wrong. try change this

target_window.setcoords(0,0,width,height) 

the documentation says

setcoords(xll, yll, xur, yur) sets coordinate system of window. lower- left corner (xll, yll) , upper-right corner (xur, yur). subsequent drawing done respect altered coordinate system (except forplotpixel).

... , there issue indentation of rect.draw(target_window), mkrieger1 pointed out.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -