Golf - The Sketch
Over this weekend (night of April 8th to the night of April 9th), I decided to make my first sketch project for this website. Mostly to have the first inaugural sketch for this website, but also because I wanted a change of pace.
To explain to what a sketch for this site is supposed to be- typically, when I work on a project I greatly underestimate the complexity. This usually means that I don't get much of anything near a state that I'd be happy to show people. However, this means that my project output has stagnated, even if I still work on projects that are private. To solve this, I decided on the idea of sketches. These are intended to be tiny projects, made in an afternoon, evening, or weekend that test out some idea I had in my head. Basically an MVP of a project that I can put out to show people.
Initially for this site's launch, I was going to upload an old fireworks demo that I was pretty proud of as the first sketch. Unfortunately, it turns out that project was somehow deleted from my hard drive and not checked into git (rookie mistake 😔). Upon learning of the disappearance of that project, I sat at my computer trying to brainstorm something to work on to replace it. I knew I wanted:
- A game
- Something that is simple to pick up
- Something that I don't have to author a bunch of content for
One of the first usable ideas I came up with was just a simple mini golf game with randomly generated courses. I've always enjoyed games like Golf It! or Golf with Your Friends, but I've never tried to make a game in that style before. From there it was settled, I'd make a quick 2D golfing prototype as the first project!
I still think I underestimated the scope of this a little bit, especially considering I was aiming to be done with this on day one 😆. However, it was still a fun experiment to see how complete I could get the game to feel over the weekend.
I'd definitely consider the code for this project "game jam quality." There are many optimizations I could have done, especially in the level generation and collision areas. Level generation works by traversing sectors in random directions until we reach the sector that the hole is in. However, this also means that you could potentially iterate through all sectors, or iterate over duplicate sectors just to find the hole and create a course. As the map is relatively small, the game runs quickly on my PC. This, of course, would not be very scalable.
Collision is a whole other beast where I iterate through all entities as we move to see if the ball intersects their bounding box. I added the sector concept for level generation right at the end of the project, but with hindsight that's probably what I should have done for collision as well. Break the level into sectors, when we need to check collisions, find what sectors the ball is currently in, and check entities in those sectors for collisions.
Try it out if you want and play a few levels! I had a lot of fun working on this and I feel like this project has sparked some motivation for me to keep making more of these little sketches, especially in between larger projects that I am working on.