• PyGame (python) won't draw [need help]
    2 replies, posted
Hi. I need help with a program I'm making. It's a version of Conway's Game of Life. This game is right now made out of 3 files: main.py, cellBoard.py, cell.py main.py takes care to instance cellboard and make it update its data, give it mouse input, and tell it to draw itself (an instance of the pygame surface is given to it, which handles it to the cells which are the actual ones that draw themselves) cellboard.py creates a list of cells based off their size and the screen's size, to fill it properly. It's a 2D list. When it creates the cells it sets their state (alive currently) and handles them an instance of its instance of the original surface instance. cell.py contains all the things a cell can do: die, live, be toggled, be drawn. In fact, when I need to draw the whole board I just call cellBoard's own draw() and it should take care of calling each cell's draw. And it does. The execution gets to the point where the cell should be drawn (checked with prints) and the pixel filling function is executed (using a for loop to cover an area). But nothing is actually drawn to the screen, or at least nothing is visible. I have no idea what is causing this. I checked the code multiple times, I've even rewritten the whole program from scratch to make it more tidy (and I had the same problem as now) What is causing this? My idea would be that somehow the instance of surface Cell gets is not good anymore to work because something happened to it (it goes through cellboard before getting to each cell, could that be the problem?) Here's the source code (all 3 files, they are very short and barebones so they should be easy to read) [url]http://dl.dropbox.com/u/2951174/src.zip[/url] Thanks in advance to anyone who feels like helping. I need to complete this project very fast so your help would be greatly appreciated.
I moved the screen fill to be called before the cellBoard draw, otherwise it would be filling over the pixels and removed the two prints from the cell draw function and got this: [IMG]http://i55.tinypic.com/2j50yt2.png[/IMG]
[QUOTE=LilDood;26186859]I moved the screen fill to be called before the cellBoard draw, otherwise it would be filling over the pixels and removed the two prints from the cell draw function and got this: [img_thumb]http://i55.tinypic.com/2j50yt2.png[/img_thumb][/QUOTE] Thank you very much, that was it! It's pretty dumb if I think about it, yeah I shouldnt make programs at 1am I think.
Sorry, you need to Log In to post a reply to this thread.