Tuesday, July 23, 2024

Sometimes you do the same thing really well. Twice.

And each time, you do it for the first time.

So, lets start with some back story here. While I was doing all the recent changes to the code in the way that static files are served to the app, I found a few things to be true. Firstly, the data sent was much larger than I thought it was. But that's not the important part, just leads to it. Anyhow, when the app gets new terrain information, it updates the min and max x and y coordinates of what it has, so that it can go and request more when it approaches the end. As I was working on creating the data files to server to the app, I saw the error in that code, and sadly worked out that while it worked in an ideal world, it would be very easy to have a "gap" in the map between the min and max coordinates, but with a blank bit. Sort of like a hole in the centre of a sheet of paper. Then what would happen, it wouldn't request more terrain, but it wouldn't have terrain to display.

So, the solution I came up with was that it would request new terrain each time the party moved a certain number distance in any direction. When it did that, it would take a note that it had asked for that location, and then if it got there again, it knew it had it, so no more requesting it. Great, that's the app covered, but I should put that same functionality into the editor I use to create the game world right? I can get rid of a bunch of other database entries (even longer, unnecessary story there). Getting rid of those entries would make the data chunks sent to the app smaller. Everyone's happy.

So I open up the editor code, start working backwards in the code from a particular action to try to find the point in the code where the trigger lies that causes more map to be loaded. Hey presto. It checks to see if you've moved a certain distance in any direction, and once you get past it, it will fetch more data from the server.

Just like the app does. Now that I updated it.

At least I know that I got to a nice elegant solution twice, apparently each time thinking it was the first time I'd done it.

Monday, July 22, 2024

MOAR MOAR INTERNETS

Ok, it's been many years coming to this milestone, but I finally got the app working on an actual server, over my phone's signal, and it worked. It actually worked.

Got to say that the weekend was basically a marathon coding session, then an environment setup session. And then a lot more coding to accommodate all the actual changes from my local setup (serving static files from buckets and not a local file system) and the crowning gem.... getting a cloud run server to talk to it's cloud sql companion. Ugh. I loathe, and I don't even feel that word is strong enough, environment setup mixed with on-the-fly code changes and tweaks.

Anyhow, the music is thumping in my house currently (the missus is out at choir) and I've got a celebratory vintage here. It's small things, but it's glorious milestones.

Reality check though, the server currently isn't as secure as I'd like it, so tomorrow after work, I'll try to work out how to screw that down a bit more. Then there's a few tweaks I'd like to make, and I might actually start to build out a world ever so slightly, so that when I start to do some alpha testing with a few friends, it'll actually feel more like a game, not a semi-finished broken test-build.

Sunday, July 21, 2024

Something something GCP something

Today, being Sunday, I wasn't working, and today I had the day to code. Looking at where I was up to, I decided to finally crack open the bundle of joy that was going to be setting everything up on a cloud product. I have chosen Google, as I'm at least a little familiar with it.

I say a little, as today was a textbook example of frustration, patience-sapping and generally statements along the lines of "Why? What do you mean? Well, that doesn't make sense!" and a lot of clicking, enabling APIs, more frustration and this sort of general cycle, but with more cuss words and the like.

However.

As I am finishing this up, I managed to load the app up here using a mix of online and local servers, which is a huge step forward. Now that I know that half of it is working and serving data (the static side) I can now look forward to working on the database side on the cloud product in the coming evenings.

Progress. Tiny, painful, frustrating, but delightfully glorious and fabulous progress.

Friday, July 19, 2024

Server Code and Loads of Performance Tweaks

Boy, there's a lot of updates to get through. I had a pretty free evening last night, so continued straight into the server code and got huge chunks of that finished off (and some more this morning) so that's looking really really solid now. I've only got some images now being called from the server for inventory items, which I've somehow missed I think - and aside from that, it's all coming from the internal app asset files, or from the new server code I've been working on - so that's really really sweet.

However, the bigger update is that while I was working on fetching world data from the server (and processing it in the app) I found that the app was getting really buggy, locking up the interface and other things like that which were red-line issues. So, first things first, I managed to do a quick rewrite of the bit of code that handles the main user interface to move the party about in the world. Made it much much simpler than it was (now that I understand a little more Android that seemed much simpler than it did before) which instantly yielded an improvement in terms of what movement felt like. Instantly much smoother and feeling a heck of a lot more responsive. So win there.

I also then looked at how things were being handled when data was being fetched from the server, and managed to update the code so that it spawns a whole bunch more threads when it needs to, so that once again, the app feels an awful lot more responsive and doesn't lag up when request are being processed. I'm still going to see what I can do to get further efficiencies, but last night was a super productive effort which is making me feel great.

I think I'm finally getting close to testing this out on an actual online platform to see where all the gaps potentially are when the network is laggy and finding what breaks.

Wednesday, July 17, 2024

It's all about the Server Code

I took a day off yesterday to get some finances sorted out for another year, and had a good bit of time in the afternoon to roll my sleeves up and write some code. It's finally been time to focus on what a server codebase might look like, splitting the sections that must be database driven, and what I can do without making all those expensive calls.

The big upside is that I've been running my app on a makeshift placeholder codebase, using a lot of code common, or similar to what my editor uses. So I had a good foundation already for the information needed by the app and how it was being consumed. Using that base, I created some clean server code to use static pre-made files to serve where possible to the app. That also meant that some of my app code had to change ever so slightly, but nothing too much there - primary change was a tweak into how/when the game requests more terrain from the server.

This evening, I'm hoping to get a good bunch more of the server side coded up and replace the current database calls still being made for those particular requests.

So, I started this project to write a game engine from the ground up in 2020, and for a long, long time, it's felt like I'm barely scratching at all the work that needs to be done, but I have to proudly say, of late, I'm really feeling not like I'm looking down a long tunnel to see a pin-prick of light, but that I'm almost at the sunny entrance itself.

Monday, July 15, 2024

New Player Setup Tweaks

I've been focused on getting the menu set up properly for new players, so there's been a lot of tweaking and finesse'ing of how the app handles a new account. I'm hoping that I've done enough basic testing, but it seems to now make you create six characters before it will let you launch - and you can do stuff like reset the app etc between characters and it picks up in the right place. I mean, sure the first time someone else does it, it'll break, but jokes aside, it's feeling a bit more resilient and set up for a new player nicely now.

So... server code it is!

Oh, and while I was looking at this code update for new players, I did find a few places that I'll need to tidy up in a similar fashion, but that shouldn't be too difficult - just bullet-proofing code and also circling back with a better understanding of android to some of the early screens I'd done which can do with a fix.

Saturday, July 13, 2024

Sounds are ready to Go

I can say that sound now works functionally in all the spots that it's supposed to. You wander about, there's footsteps. Monsters attack? There's sounds. You go into combat mode - all the right sounds are played at the right times. Trading? Sounds. Equipment? All there.

It's a great and productive weekend.

There are some things that I didn't get working, which was rather annoying though. There's some rather fundamental limitations on the SoundPool class in android - and that makes doing some of the things I wanted to get done rather impossible. I wanted ambient sounds that got louder as you got closer to them - so walking up to a fire would mean you hear the crackling and popping of the fire louder, and then softer again as you walk away. Problem though, you can't adjust the volume of a sound that is playing without stopping it and starting again. That means that looped sounds would bork each time the volume was adjusted. There's also no way to see if a sound is currently playing. Again, that makes it very difficult to do looped sounds along the lines of "If this sound isn't playing at the moment, play it please". I might circle back at some point and see what I can do with the other prebuilt sound classes, but I think the only other one that offers what I want is at a lower level again than this, which means having to handle a lot more fundamental code to get the outcome I want.

In the meantime, this really is quite good enough for now. I'll eventually circle back once I have done more of the game to pick up things that I find along the way, and tweak them, but for now, it's good enough.

I think I'll try to tweak the landing page for new accounts so that it's an easier process to follow to set up a party and the like. That should hopefully be pretty quick and easy, then I think it will be time for getting server code ready in preparation for some alpha testing.

Sometimes you do the same thing really well. Twice.

And each time, you do it for the first time. So, lets start with some back story here. While I was doing all the recent changes to the code ...