pygame is
Simple DirectMedia Layer is
Site Swing
Tetris Project

Tetris Project - 0.2b

David ?hlund (poffpoff)



My first attempt to make a tetris game. And first time doing a game in python. Things to do yet: Redo some graphics Will rewrite the keyhandler for more smoother keypressing.


Added flashing rows Better collision checking More speed A counting scoreboard Scoresystem with combo multiplier Floating combat text You can now Gameover in the game. Will fix it better soon.


Home Page:


click to view original size


Tetris Project - 1.1 - Jan 25, 2008
Tetris Project - 0.3e - Jan 23, 2008
Tetris Project - 0.3d - Jan 16, 2008
Tetris Project - 0.2b - Dec 30, 2007
Tetris Project - 0.1b - Dec 29, 2007 account Comments

If you wish to leave a comment with your account, please sign in first.

February 25, 2008 10:19am - David Ã?hlund - nickname: (poffpoff)
I have alot of studying at the moment. Learning CISCO router algorithms so i dont have alot of spare time to work on this. But soon i will :-)
February 13, 2008 2:18pm - David Ã?hlund - nickname: (poffpoff)
Sourcecode can be downloaded once again. Thanks pymike =)
February 5, 2008 4:29am - David Ã?hlund - nickname: (poffpoff)
MY webserver has been destroyed! Im waiting for new harddrive.
January 27, 2008 12:22pm - David Ã?hlund - nickname: (poffpoff)
Ooo :O yes that could be a problem. if they dont have backward compability. It does? :) I have to try 2.4 then, sounds fun!
January 27, 2008 4:56am - Jordan Trudgett - nickname: (tgfcoder)
File "", line 10, in ?
import scoresystem
ImportError: Bad magic numbe.., not scoresystem.
Line 10 of is "import scoresystem".

Which is what's crashing it, because it can't import it, due to the fact it was compiled on Python 2.5.
Python 2.4 has more libraries, and generally works better with pygame (I think, not sure if it's still the case.)
January 26, 2008 9:55am - David Ã?hlund - nickname: (poffpoff)
Pymike: I only have online hall of fame at the moment
January 26, 2008 9:53am - David Ã?hlund - nickname: (poffpoff)
the source code check the sourcecode checksum against a database. if you change even 1 letter in the code scoresystem will notice it. why are you running old python? line 10 in scoresystem is... try: why do your python crash on that? :P
January 26, 2008 6:30am - Jordan Trudgett - nickname: (tgfcoder)
File "", line 37
class make_block():
SyntaxError: invalid syntax

That 2.4/2.5 incompatibility again. Can you use class make_block: for backwards compatibility? If not, that kinda sucks. Oh, and why is it *class* make_block? Shouldn't it just be class block :P Sorry :P

Okay, removed the () from that...:

Traceback (most recent call last):
File "", line 10, in ?
import scoresystem
ImportError: Bad magic number in /home/jordan/pygame_games/tetris-1.0-src/scoresystem.pyc

Guess 2.4 and 2.5 aren't really that compatible. :(

January 25, 2008 8:07pm - David Ã?hlund - nickname: (poffpoff)
Im undet he influence of alcohol i better not fool around in the sourcecode now :-) Anyway it seems to work. SOmeone named Ronny and my freind Ascii is in the hall of fame. Pymike have 0 points? whats up with that hehe
January 25, 2008 5:22pm - David Ã?hlund - nickname: (poffpoff)
Hmmm! I have noticed! Im at a freind now, he had the bug also!!!
Maybe its only in the window release
January 25, 2008 3:56pm - pymike - nickname: (pymike)
Uh oh...the collision problem happened again.

(btw it happened in the windows release)
January 25, 2008 3:51pm - pymike - nickname: (pymike)
Sure no problem! the source pkg how can I see the highscores? there's no Hall of Fame option in the menu anymore :-(
January 25, 2008 12:44pm - David Ã?hlund - nickname: (poffpoff)
Thanks aloot pymike :-) You been so much help by testing.
January 25, 2008 12:22pm - David Ã?hlund - nickname: (poffpoff)
Should work now if you download the new scoresystem.pyc, it is in the zipfile now
January 25, 2008 12:11pm - David Ã?hlund - nickname: (poffpoff)
Ooo :-D I think i found the problem! Fixing it now.
January 25, 2008 12:06pm - David Ã?hlund - nickname: (poffpoff)

i bet you would get the same error with this code:
import urllib

January 25, 2008 12:03pm - David Ã?hlund - nickname: (poffpoff)
I cant help with that error, it must be your firewall that stops python from making connection to
January 25, 2008 10:49am - pymike - nickname: (pymike) - 5/5
Woah really cool! It's ALOT harder though! Way cool! But unfortunately...scoring didn't work. I got this error:

Traceback (most recent call last):
File "C:\Documents and Settings\Michael\Desktop\tetris-1.0-src\tetris-1.0-src\", line 521, in <module>
File "C:\Documents and Settings\Michael\Desktop\tetris-1.0-src\tetris-1.0-src\", line 351, in menu
File "C:\Documents and Settings\Michael\Desktop\tetris-1.0-src\tetris-1.0-src\", line 459, in main
File "C:\Documents and Settings\Michael\Desktop\tetris-1.0-src\tetris-1.0-src\", line 98, in update
File "C:\Python25\tetris\", line 10, in onlinescoreboardentry
File "C:\Python25\lib\", line 82, in urlopen
File "C:\Python25\lib\", line 190, in open
return getattr(self, name)(url)
File "C:\Python25\lib\", line 325, in open_http
File "C:\Python25\lib\", line 856, in endheaders
File "C:\Python25\lib\", line 728, in _send_output
File "C:\Python25\lib\", line 695, in send
File "C:\Python25\lib\", line 679, in connect
raise socket.error, msg
IOError: [Errno socket error] (10061, 'Connection refused')
January 25, 2008 6:57am - David Ã?hlund - nickname: (poffpoff)
Woo i did it! :-) Here comes a huge release!
January 25, 2008 5:07am - David Ã?hlund - nickname: (poffpoff)
I dont know .pyc file :-( How can i do it?
January 24, 2008 6:08pm - pymike - nickname: (pymike)
When you release source you may consider importing the score system from a .pyc file so people can't see how to hack into the database. :-)
January 24, 2008 4:21pm - David Ã?hlund - nickname: (poffpoff)
Thank you ^^Glad you like it. Just to be safe i rewrote ALOT of the code today! It could have been a very rare bug. Better safe then sorry! :-) I also change the logic behind jumping between menu and the game. It can crash sometimes in 0.3e. In 0.4(not released yet) i have added Online Hall Of Fame. So the score go to database on my webserver. Untill i have 2 versions, offline- and onlineversion, i wont release any sourcecode. So there be no cheating! :-)
January 24, 2008 12:52pm - pymike - nickname: (pymike) - 5/5
Ahh...I played windows version. REALLY nice. Didn't come across that bug again! Nice job!
January 24, 2008 10:46am - David Ã?hlund - nickname: (poffpoff)
Im going so manually recreate it for safety's sake ^^
January 24, 2008 10:39am - David Ã?hlund - nickname: (poffpoff)
Wierd bug! I cant seem to recreate it, perhaps it is gone in my newest version.
January 24, 2008 10:12am - David Ã?hlund - nickname: (poffpoff)
The source is old. I have added pause feature and menu in the executable! woo thx alot i will look at the screenshot =)
January 24, 2008 9:07am - pymike - nickname: (pymike)
Hey this is great! One probably oughta include the data in the source package as well. (I had to download both to play the source). Also ran into one 'lil 'ol bug here. One of the blocks got caught on the corner of the other. I took a screenshot and uploaded it to my page. Take a look:

Otherwise this is really cool! You might want to add a pause feature, and highscores and a simple menu, but I guess all that is planned :-)
January 24, 2008 1:21am - David Ã?hlund - nickname: (poffpoff)
Im sorry , i turn of webserver so i can sleep sometimes =) Its up and running again now.
January 23, 2008 10:45pm - pymike - nickname: (pymike)
Link won't work :-( Looks cool though. Sorry about giving code out, but Andy really wanted to play it.
January 20, 2008 5:15pm - David Ã?hlund - nickname: (poffpoff)
I cant host sourcecodes directly, because my webserver try to run code when you click on it :P
January 20, 2008 5:10pm - David Ã?hlund - nickname: (poffpoff)
Fun to hear! He gave his word he wouldnt give it to others.
I am going to post the code when i have done more work on it =)
At the moment the code can be found at my webpage that is going under alot of work.
January 18, 2008 5:38pm - Andy Sommerville - nickname: (aksommerville) - 5/5
If you're curious, it runs great in Linux! pymike was kind enough to give me the source; you should really post it. :)
January 16, 2008 7:22pm - David Ã?hlund - nickname: (poffpoff)
Mike: Oh i see! Dont know much about linux hehe :D I will take a look at PySetup! Thanks for the tip! Hmm not sure why they play randomly for you! That they can be loud i have noticed =) Will look into that.
January 16, 2008 1:27pm - pymike - nickname: (pymike) - 5/5
Downloaded new version and I love the music! Sounds are kinda weird. They randomly play at an awkward time and are kinda loud. Otherwise very nice! Can I recommend that you use PySetup ( for making executables? It compresses stuff very nicely. :-)
January 16, 2008 1:19pm - pymike - nickname: (pymike)
David: If you want to release it to linux just release the source code.
January 16, 2008 12:43pm - David Ã?hlund - nickname: (poffpoff)
Mike: I will add scoreboard and menu with some options like, soundoptions, difficulty, newgame and such. In a near future! Got alot of tv to watch, i have the entire six feet under series dvdboxes! ^^
January 16, 2008 12:37pm - David Ã?hlund - nickname: (poffpoff)
Allan: I would! But im afraid i dont know much about releasing for linux. I need someone to guide me to do that
January 16, 2008 12:37pm - David Ã?hlund - nickname: (poffpoff)
Mike: Thx =) Hehe im sorry, i found out that it could crash after i tested it more. It did crash random when get new rows! I found the cause of the problem and fixed it in 0.3d.
January 16, 2008 6:55am - Allan Lavell - nickname: (flummoxed)
Are you gonna release this for linux?
January 15, 2008 5:54pm - pymike - nickname: (pymike) - 5/5
Awesome new release!! Speed problem seems to be gone. Great new colors! One thing though...when you lose it keeps saying game over repeatedly. And...after I got a row of blocks it crashed. Dunno whassup with that! Otherwise awesome! Keep it up!
January 15, 2008 3:34pm - David Ã?hlund - nickname: (poffpoff)
ruabana: Thank you! I suggest you test my new version, its more colorful, runs better too. =) Hehe i have been thinking about making one for i dont know how long. Would never had happen if i didnt learn basic python at the university. it made me want to start making games again =)
January 15, 2008 3:30pm - David Ã?hlund - nickname: (poffpoff)
Sure Mike! I think i overwrite the 0.2b version sourcecode tho when i try fix the problems :( I think i managed to fix it tho. I did some major changes to the screen update and the mainloop and timers.
January 2, 2008 11:49am - Dylan J. Raub - nickname: (dylanjraub)
I haven't tried it yet, but it looks preety impressive. Actually, I was thinking about making my own when I saw yours! I hate you!(just kidding)
December 30, 2007 4:14pm - pymike - nickname: (pymike)
Can you send me the source code at [email protected]? I'd like to look into it and run it from source to see if it runs any differently. When exporting source to windows executables I've ran into some problems from time to time. Happy New Year to you to!
December 30, 2007 1:03pm - David Ã?hlund - nickname: (poffpoff)
Yaay =) Glad you liked it. Hmm i will look into the stuttering. I am using time.clock() in the time module to handle framerate. Different colors is coming up soon! Taking a small break it wook a while to do the flashing =) Happy new year!
December 30, 2007 10:46am - pymike - nickname: (pymike) - 4/5
Yes!!! You can push the blocks down instantly now! But when they're falling down they seem to stutter... Well, I restarted the app and it didn't stutter anymore. Hoe are you handling your framerate? It's awesome the way the blocks flash when you get a row!!! Next you should add some different colors to the blocks! Very nice!!!
December 30, 2007 10:45am - David Ã?hlund - nickname: (poffpoff)
It go really fast with the down arrow now!
The rows flash for 0.5 seconds before they get destroyed.
Did very basic flashing :) draw them or not to draw them = flashing !
Hope you like the flashing :) I think next step is to add more color to the game and a menu system. And something more has to happen when gameover. Maybe a highscore table!
December 29, 2007 4:53pm - David Ã?hlund - nickname: (poffpoff)
Thank you :) I am planing on making it dynamic so it goes faster and faster, but have not got there yet. I am thinking on adding a 1 second "touchdown" delay of the blocks. I can try to make the rows flash, thats a great idea! :)

I would need to refine my code if i was to release it. So it is readable, im a selfteached programmer so i do not follow any particular rule when im programming :( It looks like a mess sometimes..

Tomorrow i think there will be another release :)
December 29, 2007 10:45am - pymike - nickname: (pymike) - 3/5
Very cool! Some things you may want to look into:

Have the blocks descend a little faster, and have them go down really fast when you press the down arrow. Game feels a little to slow.

Have a bit of a delay when you get a row of blocks. Maybe have the blocks in that row flash a few times and then disappear.

Release your source code.

Can't wait for the next release!

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Jan 19, 2017

Jan 18, 2017

Jan 7, 2017

Dec 30, 2016

Dec 21, 2016

Dec 8, 2016

Nov 28, 2016

Nov 27, 2016

Nov 24, 2016

Nov 20, 2016

Nov 14, 2016

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)