PyTetris() is a Tetris clone for Python and pygame.
- Home Page
Pygame.org account Comments
Jouni Järvinen 2011-10-27 15:51:30
You need to use the §elif§ statement too: you see, repeating code like
§if fullscreen == 1
if fullscreen == 2§
is complete waste of performance.
Next, the Ternary Conditional Operation is a good and speedful way to decrease code. Note, however, that you need at least Python 2.6.1 or 2.6.2. http://en.wikipedia.org/wiki/T...
If you ever come to use the §print§ statement, make sure to use brackets, else the code won't run under Python 3; §print SOMETHING§ won't work, so it must be §print(SOMETHING)§
feeflxf fgdkjglkvb 2011-10-28 07:53:46
Thanks for your tips :)
Yeah your totally right about that, I'll also make it compatible for python 3.
wez 2011-10-28 09:22:50
well done, I like it. I got to level 10, 103 lines, 38111 points!
near that level I got tiny pauses as the blocks touched down, may just be my netbook but look out for build-up of memory usage just in case. in setlevel() you could replace your if-statements with something like: "self.time = level_time_list[self.level]", thinking ahead you can even generate this list using a log function, ie the rate increase slows down near the end (like you tried doing with if self.level > 10 and self.level < 12).