Movement is part of a large portion of games. When jumping between platforms, shooting against a horde of enemies, piloting a space ship and running through the streets, we are causing movement and interacting with the game environment, applying action and causing reactions.
This chapter is to describe the basics of moving objects across the screen and their interaction with other elements through collision detection.
Movement
If you are following this series of posts, you already saw an example of movement at the post about the game loop, where we implemented a ball that moves through the screen bouncing around.
Games always connected me with technology since the beginning.
My father and I, we built our first computer (a Pentium 286) and the first thing that I remember to do was to play some DOS games like Prince of Persia and Lunar Lander. I learned a bunch of CLI commands just to play my favorite games.
The passion for playing and making games followed me as a hobby. I have a pygame series of posts on this blog, where I go through basic concepts of game development trying to explain them to someone who is starting to learn about it.
I’m starting this series of posts to give you tips on libraries that can be handy on your day to day as a Developer and also to present libraries I think you should keep on eye on.
One of the perks of a good Developer is having a proper tool-set available on your belt, and nothing more appropriate to start this series than a library that installs other libraries!
How many times did you install some Python CLI tool inside of a Python virtualenv? Have you ever updated some tool and broke another library because it relied on a common dependency?
Raise your hand if you never versioned the Django’s SECRET_KEY at the beginning of a project and needed to generate a new one before going to production.
This TLDR is a quick reminder of how to generate a secret key locally, without going to some website on the internet to generate it for you.
Django generates a secret key every time that you create a new project, so this function already exists at its code, and you can access it in this way:
Recently, I had the opportunity to face a frontend challenge at Configr. It consists of improving the tracking rate of the new users who come to the system (a.k.a. leads). More specifically, the tracking rate from the UTM parameters of the marketing campaigns.
UTM
The acronym UTM came from Urchin which was an analytics software made to measure how effective a marketing campaign was, by using the parameters of the Urchin Traffic Module to accomplish that. Later, Google started to support these parameters, and right after Facebook, and eventually, these parameters became famous as a standard tool to measure the effectiveness of marketing campaigns across the internet.
Chatting with a friend, Mário Sérgio, about problems that happen when you migrate your codebase from Python versions, I came out with the idea of writing this TLDR.
I hope it can help someone that is trying to work with texts that contain Unicode characters that don’t fall back into the ASCII table like other than the roman alphabet and emoji.
On Python 2 there’s no distinction between byte and string. It leads us to eventually not correctly encode/decode the data when we deal with input and output. That kind of mistake can cause runtime errors like that:
Someday, during the Python Tuesdays event at Calango Hacker Club, one of the participants came with a question on how to automate its email reading process at Gmail categorizing their messages into something that could be important and something that is not. That question motivated me looking after how to that, and then into this post that maybe can help someone that is trying to do something similar with Python.
Some libraries aren’t 100% packaged Python code, some of them are bindings to external libraries. They offer a Python interface so you can call them inside your code. On these cases, we need to install them previously at the system so the python package can work.
When that happens, we get this kind of error:
ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
To solve errors like that, you need to install the external library, and the system configures everything to you. However, if you work with multiple Python versions managed by pyenv, you have to rebuild all python versions every time that you remember to install a new dependency.
This post it the result of a bug that haunted me for three months until I finally could isolate the error properly, and get to the root of the issue.
One of the core parameters of a Django Model field is the default. It sets the value of the Field when you don’t pass a value to it at the Model instance creation. The default parameter can receive a value or a callable, and callable are functions or any object that implements the __call__ method.