0 Members and 1 Guest are viewing this topic.
I'm using pygame for graphics. I don't really know any of the other onesEDIT: if it matters I'm using python 2.6.2
screen.set_at((x, y), (red, green, blue))
thecolor = screen.get_at((0,0))
screen = pygame.display.set_mode((width, height))
I wanted to know how to do the cellular automata. I also need to be able to do good collision detection and gravity.
Quote from: ruler501 on February 01, 2011, 03:42:16 pmI wanted to know how to do the cellular automata. I also need to be able to do good collision detection and gravity.First off - have you made the concept on your calculator, and does it work?Second, are you well versed with Python and Pygame?Third, can we see some sample code?
Quote from: alberthrocks on February 01, 2011, 03:44:03 pmQuote from: ruler501 on February 01, 2011, 03:42:16 pmI wanted to know how to do the cellular automata. I also need to be able to do good collision detection and gravity.First off - have you made the concept on your calculator, and does it work?Second, are you well versed with Python and Pygame?Third, can we see some sample code? I don't get the first one This is a comp programI'm well versed with python and have done all right with pygameI'm still making up the code, but if you want to see some code I'll post it later. @Builderboy I want to know how to optimize that code and some of the concept
Implementing cellular automata is not too hard. You will want to start with two arrays. These arrays will hold the pixels that represent your element you want to simulate, like water. They will both have the length of the ammount of pixels you want to simulate, and one will hold the X value of a pixel, while the other array will hold the Y value for the pixels. After that, you will want to loop through the array, applying your physics to each pixel as you go along. Remember, physics is as simple as a set of rules like I explained in the other thread
[0, 1, 2, 3, 4, 5 6, 7, 8]
[0, 1, 2, 3, 4, 5, 6, 7, 8]
Could i have an example of some python code for that please. I'm trying to figure out a way to optimize this it would be slow i think if i have to go through most pixels in a nearly if not full screen game. The only reason i might not do full screen is because i want this to be a very fast game that won't glitch up. i think it would be easier if i had a slightly smaller screen size.
a = [[v]*n for x in xrange(n)]
a[y][x] = 1print a[y][x]