This weeks lesson in software

YonnisYonnis
3 min read

I’ve decided to write a small weekly piece about the things i learnt this week in software.

What did i get up to this week?

Well i really wrangled around with odin and raylib this week, while also working on some conveyor belt logic for a pretty rudimentary system.

This system had some good ideas. Namely how pathing would work. This was achieved by when placing a conveyor all the conveyors in the cardinal directions would update to see if they needed to change their target conveyor.

Here you can see that i’m drawing a line from each conveyor, to its logical target conveyor. You’ll also note that conveyor paths are independent. They’re not stored, we can just traverse a conveyor starting anywhere, and follow the target until it’s nil and then terminate.

Individual conveyors with their own paths

Some of you keen eyed readers might notice these co-ordinates seem really stupid (they are). This is my first foray into graphics, game logic programming, traditionally coming from the corporate world and more of an OOP background at my current job. This kind of leads up to the big lesson i learnt this week…

If your foundation sucks, it’s really hard to write good code on top of it.

I learnt this the hard way when i spent more time struggling with my rendering and entity code than i’d like to admit. I kind of jumped the gun, got a bit excited to program some conveyors and didn’t realise how crap it was to always go back and fix things because they weren’t in place properly.

I can say though i learnt some cool ideas about conveyors this week, and game programming in general. I learnt how an atlas works, how textures are loaded and handled in raylib and how awesome it is to program in odin.

What are my key takeaways from this week?

I’m going to strip back this project and tackle one problem at a time. If i want to stop fighting with my renderer, i need to make it more complete. This means dedicated calls like draw_sprite() which can take an entity object of my choosing and render to the positions defined in it’s structure. I also need to have a better understanding of screen space and world space. I’ve started to understand it, but am unsure if when i draw a rectangle using raylib that im drawing to screen or world (I will test this).

If anything i’ve learnt i need a solid foundation before i can get to the fun stuff. Having a robust rendering solution isn’t super glamorous, and it’s keeping me away from the fun programming.

There’s some great cool things i did this week though. I learnt how to check neighboring tiles and update them based on changes to their surroundings. I also learnt a very rudimentary linked list based pathing system. Also picked up odin and raylib for the first time and gave it a solid crack.

Am i super proud of this work? no. Am i happy i did it. yes.

I learnt a lot of valuable lessons in software planning. Sometimes its okay to cowboy it, you’ll get where you need to go. But at the start of the project, is not the place to cowboy it.

Thanks for reading

10
Subscribe to my newsletter

Read articles from Yonnis directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yonnis
Yonnis