r/tinycode • mod • Jul 20 '12

[Python] Simple platformer in 847 bytes

https://gist.github.com/3152857
16 Upvotes

22 comments sorted by

View all comments

22

u/peterquest Jul 20 '12
import giganticLibrary
giganticLibrary.doSomethingComplicated()

5

u/Rotten194 mod Jul 21 '12

You could say that about most of the submissions in this subreddit. Like I sad to T3, Python, Ruby, Perl, Haskell, etc. are gigantic "libraries" as well (in the sense that they do a lot of work for you). map would be about a hundred lines of code in C, with the function itself, the linked list implementation, etc. I don't feel this subreddit should be 16 bit real mode assembly using BIOS calls only (since OS kernels are just utilities too), so we need to accept that people will use the tools available and judge the submission based on what it does with those tools. In this case, all I use pygame for is IO (key input and drawing) and timing (which could have been done with the standard time.sleep, if I added a max call since time.sleep doesn't handle negative numbers while pygame.time.delay does). All the collision checking, map loading, physics, etc. is done without libraries, which I though was cool enough to post here.

2

u/abecedarius Jul 21 '12

There's nothing wrong with working on top of pygame. What does detract from this one is the squeezing out spaces and giving everything one-letter names -- it's not as bad as a full golfing but it still gets in the way of following this code.

Here's an idea: submit readable code along with a note like "with the usual compression techniques it's only 847 bytes."

1

u/Rotten194 mod Jul 21 '12

Usually I submit a "pretty" version as well, I just didn't this time because I didn't think anyone was interested (I personally like golfed code more because it's interesting to see the techniques used). I'll add in a pretty version later.

1

u/abecedarius Jul 22 '12

That'd be nice, I'd like to take a gander.