Crappy Code 0: Display Resolution

Every programmer knows these moments. You come across those few lines of code that make you think: “Whoops…”. Or better: “Wat.” Most often this code is the result of crazy deadlines or massive refactoring of other parts of the application – or just simple stupidity.

Sometimes this code is your own.

In order to share these great moments with you, I decided to start a series I’d like to call Crappy Code. Should you ever run into any code that you think could fit this category, feel free to send me a mail to crappycode(at)npruehs(dot)de.

Let’s start right away with this little jewel: The first part of this series is about a piece of Python code that is ought to adapt the size of some buttons to the current display resolution.


This is the pure opposite of a resolution-independent UI. In fact this code has been taken from a game that was originally designed to be played with two resolutions, only: 1024×768 and 1280×800. Unfortunately, I got honored by the task to make the game look somehow good on laptops now, which – who’d have thought – includes other resolutions as well.

Second point: Where do all these strange numbers come from? What the frack is 0.352 * 0.95?

Ah. Yes. It’s 0.3344. I see 😉

Author: npruehs

Nick Pruehs is a Co-Founder of Slash Games, Hamburg. In 2009, he graduated as “Best Bachelor” in computer science at Kiel University. Two years later Nick finished his master’s degree in “Sound, Vision, Games” at Hamburg University of Applied Sciences, becoming the Lead Programmer of Daedalic Entertainment shortly after.

2 thoughts on “Crappy Code 0: Display Resolution”

  1. Havent you heard about “magic numbers”. Magic numbers are the Unicorn & Rainbows for your sourcecode:

    Another thing here is, the author has dublicated code just to insert a multiplication by 0.95. Well, thats one way to increase the number of lines of code.

Questions? Comments? Suggestions? Your turn! :)