This is a fun little goofy project that's inspired by the fact that the call of gaming is powerful, but I also want to be in remotely decent shape. Combine the gaming and exercise goals, with a little sprinkling of meme energy, and all the sudden we have a pretty legit workout app!
The game lends itself well to it in general. Beyond pushups, seeing 20 minutes remaining on an egg timer was enough of a motivator to get me off my chair to go for a run! Anyway, let's get into what it is and what it does.
Code StuffThis works by using Tesseract in python. It looks at the health bar on the screen and processes the health it sees. It seems to have some issues depending on the background, so it now runs through extra image processing to make it a little more reliable. Beyond that, it seemed to work pretty well overall but sometimes still gets characters it shouldn't so it goes through a bit of a character correction process. If it sees a B, it should be an 8. If it sees an S, it should be a 5... So on and so forth.
We keep track of current health, previous health, and max health. If you take damage, you owe a pushup. The code keeps tally of the number of pushups owed and reads it out every time you owe another. To reset, it looks for the key binding ctrl-r. You just push that after you've paid your debts and done your pushups. To hear how many you owe without being hit again, you just press ctrl-p. Just hold it down a moment, as the code does sleep briefly between checks.
We keep track of max health to help avoid incorrect/egregious values. Still, every now and then we get an incorrect value and it adds a pushup. Still, for the most part, if you get an incorrect value for current health you will incorrectly owe a pushup. One obvious option is to check the subsequent value and compare it to the one previous to the value in question, but then there's more of a delay in the time until pushup feedback and if you're taking actual damage and then healing back to full (I assume that's in the game somewhere) before it registers then you get to just avoid pushups. Either way, this is for fun code not production code, and if the goal is to end up doing pushups anyway, this falls within "it's a feature not a bug" territory.
ConclusionThere you go! If you jump in and make improvements, I'd love to see what you do (and probably use it myself!). Anyway, it's a for fun program so hopefully you have fun with it. Have a good one.
Comments