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.


Underside...


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 **

Cost:
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!

Sunday, December 29, 2019

RPG: Intro and Externalized Items

I'm going to have several quests on my starting island, but I noticed in the play tests that I didn't adequately lead players to the next task. Players should be able to go anywhere, but there should always be a hint of where to go next.

I've now rearranged the island such that after leaving your house, you can immediately see a fellow farmer and the slimes invading his crops. Also, the road leads past the farm for further encouragement to go in that direction and talk to him.


The other thing I wanted to do is demonstrate the "whole world" aspect of the game as soon as possible to the player. So now when you create a new game it starts at the whole world and does the smooth zoom in to the player's home and to the player himself. (Exact zoom rates will be adjusted later, but I like this intro to the game.)


Player movement / map manipulation is disabled until the intro zoom to the player has completed.

I added a couple UI improvements such as holding down the left mouse button to continuously walk (instead of having to click click click). And I no longer allow melee attacking on nothing. I noticed where you could click near (but not on a target), and the player would appear to be attacking it but really be hitting the ground next to it.

Finally the big engine update was externalizing items. I can now add items without changing any code - just create a png image and update a CSV file with the item name and its properties.



Saturday, November 30, 2019

RPG: Smooth Zoom

Quick game update. I had someone play-test the game so I now have a laundry list of feedback to work on. Many suggestions were already on the to-do (the game is still in very early stages), but I received some great usability and "first impressions" suggestions to implement.

Other than some small issues fixed, the biggest update since my last post are:

I finalized on a zoom level / resolution for the tiles (I hope). Going with 150 x 150 pixels for each terrain tile. For the zoom level I think most players will use - that will draw the terrain tiles at their native resolution. You can zoom in and out from that, but then the image may have weird smoothing / anti-aliasing effects and look blurry. By having the tiles at the native resolution players should use, that will ensure the most crisp picture.

But concerning zooming... I've also added a smooth zoom / pan routine when you click the re-center button. Still a little tweaking to do, but it's pretty slick:


Thursday, October 24, 2019

RPG: Shops

Latest update is the ability to buy and sell from shops. I decided to not go with a dedicated buy/sell window similar to Diablo 2 / pretty much any recent RPG. Mine leverages the existing event system that was created for interacting with NPCs.

First off, let's go kill some rats to get their hides. (By the way, these are R.O.U.S.'s, so their hides are pretty big.)


And then visit the tanner! So far this store only offers to buy rat hides and sell rat leather armor. That will be expanded, but this won't be a general store. The tanner will only buy and sell stuff appropriate for that type of shop. I'm also not a fan of huge numbers of items and giant inventories; I don't envision the backpack getting bigger.


Clicking Sell Rat Hide increases your gold and takes the rat hide out of your backpack.


And clicking Buy Rat Leather Armor decreases your gold and drops a piece of armor ready to be picked up.


Small but significant step for the game!