I’ve been programming. Sometimes.

Been a while since I posted here. To be honest, life has been simultaneously slow and fast. A lot has happened, but also nothing has happened. Time has flown, mental health is up and down, and a consistent lack of motivation has prevailed so far this year. But lately I’ve picked up a couple projects here and there and I figure I may as well share some of my progress.

Global Game Jam 2021

So I ended up participating in GGJ21 as I’d intended, but I never got a team. I ran it solo and gave it the best I could muster. Problem was, it went over a weekend in summer, i.e. I was playing cricket on the Saturday. This made it particularly challenging, and I had to try and work around and through that to make the game.

With the theme of ‘Lost & Found’, the game I had in mind was a narrative-focused 2D dungeon-crawler, where the protagonist had their heart stolen by their partner and they had to work through waves of enemies to reclaim their heart, and the love of their life. Unfortunately my plan wasn’t super fleshed out, and the time struggles made it difficult to get the game to fruition.

I spent a while on the art, drawing mostly on my Surface fairly simple pixel art. I don’t claim to be an artist, and never will, so that was tough and I couldn’t really get it working. It might have worked better if I had more appropriate tools than just Gimp, but for an amateur like me it sufficed.

I guess the art had its own little quirkiness to it.

I didn’t have a good implementation of my idea, the mechanics were shoddy at best, the art was meh, and my perfectionism meant I spent longer than I needed to on some things. The one thing I kinda got right was the text, and maybe it would’ve been a promising jam game if I had a more solid foundation for the game and its mechanics.

If you do feel like checking it out though, it’s on my itch page.

Breakout Urban Android port

Earlier in the year, I picked this up because I really wanted to get back into game dev and finish this project once and for all. I was finding myself with time and opportunities to work on something and inspiration for this game hit me.

I set up an Asana kanban board to track my ideas and tasks, and organised private playtesting through the Google Play Store, so my friends and I could download and get updates easily. The Asana board filled up with plenty of ideas and bugs, and I made steady progress for a while.

The main goal was to make everything run more efficiently and streamline the UX and game experience, since it didn’t have a lot of good interactions. Using the Play Store, I was able to test fairly easily on a few of my devices and I found that it struggled a little on my old Samsung S4, so I figured I should work on optimisations too. I want the game to run smoothly on as many Android devices as possible.

Unfortunately, I’ve fallen off that track and haven’t worked on the game in a few months. However, with the task tracking I won’t have to worry about remembering what I want to do the next time I pick it up. I intend to finish this one day, even if it ultimately doesn’t achieve much.

Mini weather station

I was scrolling through Reddit and I came across a link to an article with things you can do with a Raspberry Pi. With a spare Pi Zero and a 16×2 dot matrix screen lying around, I decided I wanted to do something with that. In the end I decided to make a little weather station. Just something that gave basic details of the current weather plus forecast details (don’t tell past me that I can only barely fit just temps in).

How cool does this look though?
(source, retrieved 27/9/2021)

The weather station they showed off was a full graphical one on a 320×280 screen, so the library was useless to me. So I went researching for weather APIs that I could hijack and get the data from, as well as a library to work with my LCD. Fortunately both were fairly easy, although the first weather API I found was actually just a server hosting data accrued from other people’s weather stations…. That hasn’t been updated in 3 years.

I soldered up the screen directly to the Pi, taking a lot longer than I’d like to admit. I made plenty of adjustments to the wiring afterwards too, including shortening some lengths, as well as later powering the LCD backlight off a dedicated GPIO pin so I could turn it on and off.

Power wiring for dot matrix screen.
After the power wires were soldered.

The API I chose was OpenWeatherMap and would provide me with the most relevant weather data according to my GPS coordinates in JSON form. I used Google Maps to determine them, and then I added in other parameters including the API key, units, and the actual URL to retrieve the data from. After a quick search on parsing JSON data in Python, I set up a simple while 1 loop and set it to retrieve the data, get the current temp and forecast min/max temps, and update the screen every 5 minutes.

I wanted to set up the station permanently in my room, so I could always easily get the temps, but the LCD backlight was bright and would’ve kept me up all night. I noticed the initialisation method for the LCD gave a backlight pin as a parameter, but I’d set up my backlight to be powered off the same 5v line as the rest of the screen. So I moved it over to GPIO pin 4, as set in the code, and tested that it did in fact power the backlight. This is where I learnt GPIO pins can be used as a 3.3v output for things. I tested the code to turn the backlight off and it worked wonders.

The next issue I faced was getting a momentary button to work. I looked it up, but I never understood what exactly I needed to do to make it work. Then I changed the pin I was looking on for input, and set it up the most basic way. Just 3.3v connected to one leg, and an output wire connected to a leg on the other side of the button going to GPIO pin 27. I enabled the in-built pull-down resistor on the Pi so it read low while no voltage went through.

Using a push button with Raspberry Pi GPIO | Raspberry Pi HQ
I saw many diagrams like this and genuinely could not wrap my head around it.
Yes, I’m dumb.
(source, retrieved 27/9/2021)

A change to the code was necessary so it could register the button press while it was sleeping between data retrievals. I ended up just implementing basic game engine logic, with a Start method and an Update loop, and then just counting down the time to wait by calculating the delta time from the last loop. I then set up the button to enable the backlight for 10 seconds, before it turns itself off again, enough time to read the screen.

Then came the next challenge. I told my friends about this project and they complained it wasn’t BOM data, to which I responded with, “BOM doesn’t have an API for the public to use”. The actual truth though, I had just never looked. So I investigated, and quite easily found the access to the data. They provided a lot of it in various different formats, but the thing that still irks me: recently observed weather data is available in JSON format through HTTP. Forecast data on the other hand… how about an XML that I have to download through FTP? That’s not really stupidly annoying, noooooo….

Seriously, who thought this was a good idea?
(source, retrieved 27/9/2021)

So back to the googling on how to access FTP, download data from a file to RAM, and then also parse the data that’s presented in XML format. It took me a couple tries, but using some in-built Python libraries and some string trickery I pulled it off. It was a pain in my ass, but I’m glad I did that, because now I get the data from the probably most reliable source in the country.

But I wasn’t done yet. I figured I wanted to see the temp in my room. So I bought a temp sensor module (DS18B20) that was already set up with the pull-up resistor and plugged it in, setting up the Pi’s One Wire functionality on GPIO pin 5 (since the default, 4, is being used for the backlight). Little did I know that the module board swapped the Vdd and data pins, at least until I looked at the data sheet from the website I bought it from. Once I cleared that up though, it worked a treat. It’s scary how much my PC heats my room. 7 degrees outside, 23 inside… Also I can see just how ineffective our central heating is for my room and now I hate it even more.

And finally I finished the project… or did I???

Weather station v2

Soooo… I’m not actually done with the idea of a weather station yet. I’ve got my eyes set on a graphical interface for the weather station, much like the one shown earlier. I’ve already gotten myself a 2.8″ touchscreen that will connect via SPI to a Pi, and I’m currently waiting on a Pi Zero W to arrive so I can get started.

Now, because I want to use the data that I’m already retrieving from the BOM, I’m pretty sure I need to set up the program myself. This will make it a decent challenge, but I’m up for it. Based on my research, I can’t use accelerated graphics, like OpenGL, through SPI. So, the plan is to use Pygame to run the display: since it uses non-accelerated graphics, it should be able to push graphics through SPI.

Ludum Dare 49?

This one, I’m not so sure on. I said at the start of the year I’d do at least 3 game jams, but I’m sitting here having still only done one. I’m honestly thinking I may look at the theme and do something, but not actually submit anything. Take some time to just make a game, and not push myself when I’m clearly not talented enough for things like art and design. Hopefully I’ll be able to partake in a game jam with a team again soon.

That’s it…

That’s all for now, I haven’t done anything else really. Now I’m just doing what I can do while away time until lockdown finally lifts and I can get back to things like bowling and cricket.

Until next time, whenever that is, take care and get vaccinated y’all!