pysand - 1.4
falling sand game clone
A falling sand game clone Instructions: Choose an element on the palette to the left and draw. Sand changes to the color you pick on the palette Press 'c' to clear the screen. Press 'l' to have particles loop around screen Press 's' to save current state Press 'r' to load a state Right click to erase the area under your mouse Thanks to monkjr for getting saving and loading to work Thanks to Khono for helping get network mode run at playable speeds.
Major changes in this release. I've split the game into two different versions. One version uses pygame and the other uses pyglet. The pyglet version is faster, so i recommend playing that one, but i've kept a pygame version if you don't want to install pyglet. **Speed** I've tried everything to speed up the game. First I tried storing coordinates as a string because I read that dictionaries are faster if the keys are strings but converting them to a string wasted too much time. Then I tried hashing the tuple coordinates of a particle and using that as the key but that didn't do anything. Then I tried parallel processing, giving each particle their own process but some error about pickling and objects with pointers in them came up. Then i tried fixing the error but that led to a lot of confusing code which still didn't work. Then I tried using an array to store the particles and another array to keep track of their coordinates but that was even slower. Then I tried storing what objects have interacted into a list and then check if they're in that list they don't interact again but that was even slower too. I finally managed to double the speed of the game by giving each particle a variable telling if it's interacted or not and checking it. If it has interacted then it doesn't interact again, saving some time. And then I doubled it again by using pyglet and using opengl to draw to the screen :D I think the only way to make this any faster is to use a different language. I actually tried this in c++ with SDL a while back but the best i could get was some sand falling on the screen, a weird buggy clearing function, and the sand piling up. Some day I'll get back to it...maybe...And if you have any ideas on how to speed it up please don't hesitate telling me :D I'm completely out of ideas or any kind of clue on how to speed it up. And if you really wanna know the most intensive operations are the draw and interact functions. **New Additions** *Added Steam **Extras** I've made it where the game doesn't try connecting to the server now until you tell it to so that way if the server is down when you start the game it won't freeze. Also I now have it save your game when you exit, and load it when you play again. And one of the times when I gave up on making it faster I decided to finally comment the code. The code is now heavily commented! (except for save and load functions... I have no idea how those work xD I'm terrible with files and strings) And perhaps the best change of all is that you don't have to move the mouse to draw an element now. You can just hold it down and it'll continuously draw it. And if the particles are too big for you, you can change the size by changing the variable 'grid_size' in the particle file in the Particle class.