Friday, July 31, 2020

RPG: Hover Info Over Objects

Not too much to show on this RPG update. I am now adding mouse hover labels / hit point bars (when appropriate) to objects on the map.

Mouse over an item tells you what it is...

Mouse over the bed to tell you what happens when you interact with it (including health bar on the off chance you want to break your bed)...

If you mouse over a NPC, it tells you what happens when you interact with it...

If you mouse over an enemy, then you see its health (and nothing happens if you try to interact with it)...

I'm still not entirely sure how I want to handle labels and if they should include what happens when you click to interact, but the options are there now to tweak it.

Other than some minor code cleanup, that's the whole update this month!

Saturday, June 27, 2020

RPG: Multiplayer Items & Effects

Items and effects are now communicating over the network!


The server or the client can pickup or drop an item and that change is reflected across the network. Anything on the ground is managed by the server. Anything held by a player is managed by that game's client.

Next I command the lower right game client to pick up the sword and the upper left game server to pickup the healing potion.

Changes reflect on both games! Lots of cleanup to do in the code, but it's working great.


Effects are not purely visual (drawing of flames on the ground), they also include abilities such as healing or damaging.

Screenshot of the client putting down a flame wall...

I let my server player get injured...

Then my client player heals him...

A visual effect is drawn on the player receiving the heal on both games and the target player's health increases.

Sunday, May 31, 2020

RPG: Multiplayer Characters

Player and non-player characters are now communicating over the network!

As you can see in the screenshot, items are not being shared between game instances yet.

The type, position, speed, heading, armament, animation, and killed state of characters are sent between games. The position of network characters are dead-reckoned based off the speed and heading of their last update packet to keep the movement smooth and limit packets on the network.

I'm actually quite happy with how smooth the motion is over the network. It's on par with similar network games. Up next will be to send effects and items over the network.

Wednesday, April 29, 2020

RPG: Multiplayer Connect & Chat

Multiplayer work has begun in the RPG!

After selecting your character, you pick if you're single player or networked.

My goal is that you will be able to seamlessly go between a single player experience and playing with your friends.

- If "Single Player", then it starts as normal.
- If "Private Server", then it starts the game as a TCP server and will accept client connections.
- If "Private Client", then it will connect to a TCP server.
- If "Public Client", then it will connect to an Internet accessible server. I don't know how feasible this mode will be. For now I'm intending the game to be primarily LAN (Local Area Network) play like Diablo 1. Even if the Internet play shows promise, I want to keep the LAN play fully functional.

I started 2 instances of the game. One as a "Private Server" with a player called "Host". The second instance is with the player called "Player" connecting as a "Private Client" to the server.

And when I click "Start", it attempts to connect to the server. If successful, it starts the game for the client!

On the Server (left window), it announces "Player" has arrived.

You can see sharing character positions is not yet working, but I do have chat messages between the servers and clients functioning. Press enter to bring up the chat box, type in your message, press enter, and it gets sent.

There is no set limit to the number of players that may connect. It'll be interesting to see how well it scales as the numbers of players grow.

Tuesday, March 31, 2020

RPG: Hit Indication, Debug Mode, Dropping Coins

Hit Indication

When you got hit in the game, the only way you knew was from the health bar going down. But that health bar is in the corner of the screen and easy to miss. I'll eventually have sounds for getting hit, but there are plenty of situations when someone won't be able to hear the game. So I wanted something more apparent to the user that they were taking damage.

Solution I came up with turned out very nice. When you get hit, the border of the map pulses red. The harder the hit, the worse the red pulse. Multiple small hits in a short period of time will also cause the red pulse to grow larger.

I also have some lingering red shading if you're injured to give a reminder that you're not at full health.

Debug Mode

As the game get more feature rich, I've been needing to change more and more variables at runtime. The solution was a debug mode. Pressing F10 brings up a little input symbol in the corner.

I can now type commands such as "framerate" or "coins=30".

And adding more commands is very very quick. To support this, I had to add support for text boxes in my SFML windowing system. Which means I could also add the ability to drop coins on the ground!

Dropping Coins

If you click on the player's purse icon, a dialog box now appears asking how much to drop.

Type the new value and push enter and it appears as a purse bag on the ground...

Several other little improvements here and there to the game as well... slow but steady progress.

Friday, February 28, 2020

Rocket Stand

A couple years ago I built a rocket launcher (turn key, push button, liftoff!), but just sticking a metal rod into the ground wasn't exactly an ideal way to keep them vertical. A local Makerspace opened up and started offering welding classes. I always wanted to learn how to weld, so took the short class and then had an hour one-on-one session to work on whatever project I wanted. Remembering that need for a rocket stand, that was the project I went with.

They taught MIG welding (and since I'm a beginner), I went with all steel for the material. Home Depot had square bars, sheet metal, and a steel rod relatively cheap and in stock. Around $20 for all the materials.

No progress pics, but the final product...

The rod is way too thin to just weld onto the sheet metal. So I welded a shorter square bar vertically to the sheet metal then the rod onto the bar.


I highly recommend checking out if you have a nearby Makerspace/similar that offers the one day welding classes. Very fun and educational.

Sunday, January 26, 2020

Rain Water Collection

It rains aaaaaa llllloooooottttt in the winter time where I live (Pacific Northwest), but the summers are surprisingly dry. The house is on a well, so when we're out of power we're also out of water. Since I like to flush toilets even when I'm without power and since I keep planting trees down the hill that need water in the summer, it seemed like a good idea to capture some of the vast amounts of water that fall on the roof.

I found plenty of how-to resources online for smaller 50 gallon tanks, and if you're getting large 1,000+ gallon tanks you're probably calling in a professional. But I couldn't find much information / do-it-yourself tips on the medium size tanks. So here's my attempt and what I learned / tried...

As outside rain barrels, the tanks need to be opaque / dark enough such that light can't get in and have algae grow. I went with three dark green Norwesco 305 gallon tanks. These tanks have a good height vs diameter (bigger tanks had substantially larger diameters and would just look comical next to the house).

Tractor Supply has a decent selection of tanks in stock (unfortunately only in black), but they don't have the best prices. I found a supplier online in which three tanks shipped was the same cost as two from Tractor Supply (and dark green was an available color!).

There are some downsides to ordering online though. First, it took several weeks to arrive. And when they showed up...

One of the tanks arrived with what must have been a fork lift gash in the bottom. (Always inspect your tanks before accepting delivery!) As soon as I flipped it over and the delivery guy saw it, there was a four letter word uttered and he got the ramp ready to load it back up. So it was nearly three more weeks before I got the replacement tank in.

To the company's credit, they had zero issue with the refused delivery and immediately worked to send out a replacement tank. I'd say if you're getting one tank, just picking up what's in stock at the local store is worth it. But even with the hassle of delivery it was quite a savings when buying three.

The tanks themselves are fairly light but obviously quite heavy when filled with water, so they need a decent foundation to sit on. (305 gallons x 8.345 pounds = 2,545 pounds + weight of the tank!

Unfortunately I didn't take pictures of these steps, but I excavated just under 8" of ground slightly larger than the tank radius, laid down landscape fabric, then filled my hole with pea gravel. Reading recommendations most places say 4"+ of gravel base. It was easy enough to dig a few more inches so I just went for double. There is a landscape supply company near my house that will dump a half yard (13.5 ft^3) of gravel in the bed of your truck for $16.75. Home Deposit sells 0.5 ft^3 bags of pea gravel for $4.48. Find a landscape supplier for large amounts of dirts, gravel, etc... it's so much cheaper than the big box store.

The landscape fabric is to help contain the pea gravel and minimize weeds from growing out of it. For the foundation ring I picked up 8" flashing from Home Depot and pop riveted it together. It's not the most perfect circle, but the flashing is holding the pea gravel in great. (The rocks you see outside the base in the photo just happened during shoveling.) Long term we'll see how well the flashing holds but so far it has worked great.

And two of the three tanks in place! Each tank is next to a downspout of the house.

To capture the water, I went with: Aqua Barrel Round Downspout Diverter Kit

The reviews cautioned about leaves getting stuck in the downspout over time but otherwise very positive. The parts look great.

They have instructional videos that are quite easy to follow. Drill a hole 3" down from the top of the tank with the supplied medium sized drill bit.

Go level to the downspout pipe.

Then drill the diverter hole with the supplied largest drill bit.

The diverter easily folds up to be pushed into the hole (and expands inside to match the curvature of the pipe). It's held in place by 2 screws.

The kit comes with a spigot (black piece below) and a drill bit for the bottom of the tank, but I really don't want to put any more holes into the tank than absolutely necessary. And there was already a hole at the bottom, so trip to Tractor Supply to get reducer bushings to go from 2" down to 1.25" down to 0.75". Success!

Screwed into place!

Tanks with all the hoses connected!

Here's the diverter hose off during a rain, the diverter works really well! It conforms to the inner lining of the pipe to divert that water into the hose.

Ohhh sweet water!

The middle of the diverter is open to allow excess water through the downspout to drain to the ground. So when the tank is full, the water backs up the diverter hose and then just goes down the downspout.

One of my tanks kept filling up then losing a good amount of its water down to the same level. Turned out there were tiny cracks near the bottom of the tank. At first glance they seemed inconsequential; a few marks. But once the tank filled a couple feet the pressure pushed the water through the cracks. The water level actually stabilized several inches above the crack. I didn't take a before picture, but it almost looks like someone just started to drill a hole then stopped.

No idea how long this will last, but I picked up some Flex Seal from Home Depot and slapped it on. Let's see if "Flex it and forget it" actually works...

If the Flex Seal doesn't last, then I'll do a more proper patch.

** UPDATE ** Flex Seal does not flex it and forget it on these polyethylene tanks.  Another fix will have to be applied. ** UPDATE **

3x 305 gallon tanks: $1075
3x 1/2 yard loads of Pea Gravel: $55
3x Diverter Kits: $102
Flashing: $26
Reducer Bushings: $24
Landscape Fabric: Maybe $10 worth
Total: $1292

Final notes / things to watch:
- This is not potable (drinkable) water. I don't even have a "first flush" device on it (which I may add later). We'll see how clean the water stays throughout the year.
- It's recommended to cap rain barrels in the winter so they stay empty to prevent freezing. It gets cold where I'm at but rarely stays below freezing for long. It also takes quite a bit of cold weather to freeze 300 gallons (and those recommendations were for 50 gallon tanks), so I'm hoping my tanks can stay near full in the winter. When it gets cold I'll ensure there is room for expansion in the tank for whatever does freeze, but I'm going to try to not cap them. If a tank does begin to freeze then I'll throw in a trough heater temporarily and/or let it drain.
- Hopefully the flashing lasts and holds in the gravel.
- And of course I'll have to monitor the Flex Seal patch. ** UPDATE ** Flex Seal Failed ** UPDATE **

Overall though it will be very interesting to see how the rain collection works!