Pages

Friday, July 3, 2020

Workruft

Fragile has been superseded by Workruft

Saturday, July 30, 2016

Absolutely Beautiful Multiplayer Building and Deletion!

This particular update on Fragile is very exciting. There are several key updates:
  • I discovered a way to determine a pixel's game world position in the pixel shader, as well as a way to produce pseudo-random values and therefore random noise in the shader code as well!

    What does that lead to? First and foremost, a way to construct very, very beautiful looking buildings, each with a unique look to them as well! Secondly, it dissolves me of the need to utilize any textures or texture coding, for the time being. Lastly, it opens the door to more easily creating all sorts of neat effects in the future, such as blurring, fire, water, lightning, shining, etc.! (I will also be able to animate these effects if desired.)

    I also discovered a really cool website while looking for shader code to help me calculate pseudo-random numbers, which is basically a sort of open-source GPU-shader-code testing, development, and sharing website: https://www.shadertoy.com
  • I added memory structures to efficiently detect collisions and use the spiral that I recently created to move the builder unit when it builds on top of itself. This is important because it will allow for efficient calculations for other things like path finding, auto-attacking, area of effect (AoE) actions, etc. in the near future.
  • I finished adding building capabilities for players and building deletion (left double-click for now).
  • I fixed several glitches with drawing, alpha, etc. and improved unit movement and targeting.

Lastly, before we get to the demo, please note that Fragile is still in desperate need of path finding. You'll notice that when even the slightest bit of a corner is in the way of the unit, it will immediately stop moving. This demonstrates both my excellent collision detection code and the frailty of the game's playability until path finding is added in soon.

Here is the beautiful demo, followed by several pictures. Forty fourth step complete:


Next up: path finding, building animation, attacking, health, etc.!

Friday, July 15, 2016

Generated a gridded spiral for repositioning!

When a player builds on top of itself, it needs automatically jump (teleport) to the nearest adjacent spot in the game. There are various solutions to this problem, but I chose to create a gridded spiral to solve it, which is kind of a unique solution but should be more time-efficient.

What happens is, I create and store something like a gridded Archimedean spiral with unique points when the game starts. Then, when a player builds on top of itself, the game runs through this spiral (in an outward fashion) and checks each space until it finds an empty one.

Forty third step complete (orange lines drawn in Paint for illustration):
 Here is what the spiral algorithm would generate if I spaced it out 3 times (not using this one):

I'm in the middle of adding more features in regards to building and moving, so more progress updates on that coming soon!

Thursday, June 23, 2016

Multiplayer Unit Movement! And More...

I haven't posted for a few weeks, but I have been busy working on Fragile and Durable. Besides multiplayer unit movement (we'll get to that), I worked on the following, each of which were not worthy of their own post:
  • Text fading over time
  • Improved Durable server logging and Fragile error handling
  • Very basic profanity filter (it replaces all cusswords with "drumpf", Donald Trump's ancestral surname) and other chat message filtration
  • Preparations for actual release of game client executable
  • Fixed numerous 3D block object scaling and positioning issues
  • Managed blocks better and added the concept of units and buildings
  • Added forward and backward camera strafing (as opposed to in and out)
On top of all of that, I added multiplayer unit movement!

Currently, each player is only "lerped" (linearly interpolated, aka. "moved gradually in a line") towards their destination, and they go right through each other and other buildings. This should be a very simple fix in the future though, to add at least a small-scale path-finding algorithm for the time being. Collision detection will also be extremely easy to implement. It's all just in the logistics.

Other than a bunch of bugs that I had to fix once I added this feature, several of the challenges I faced were:
  • Introducing a lot of different concepts to the game at once, such as: different types of units, different types of unit actions (i.e. move, move to build, attack, etc.), different types of buildings, different player colors, etc. (and all of this multiplayer!).
  • When a player logs on (which, for the time being, is the equivalent of joining in on the actual gameplay), if any other players, units, and buildings are already in the game, they all need to be sent to the joined player immediately, to sort of "catch him up". This is a very nice feature to have though, that you don't find in a lot of other RTS-ish games: mid-game joining. I demonstrate this working in the second video.
  • When a player logs off, all of his units and buildings need to be erased, both on the server-side (and thus for all of the other clients as well (depending on the mini-game)) and on the client-side.
But alas, it's all working (though there may be a small bug or two left...)! Forty second step complete:

Saturday, May 28, 2016

Drawing a Sphere... Ready for gameplay!

Due to the nature of cubes not being a very good representation of a rotatable unit, I decided to add a sphere to Fragile's collection of drawable "blocks", and OH MY GOSH I ran into all sorts of difficulties... You wouldn't believe how many hours I spent trying to add a simple sphere to the game. Here's the story.

First, I had to generate a sphere. I tried replicating a UV sphere formula, and it kind of worked, but it was heavily distorted. I figured okay, maybe the formula wasn't designed for Direct3D or something, so after some tinkering I decided to move on to a different algorithm.

Next, I wrote some code to generate it from an icosahedron, which is a 20-faced sphere-like shape that you start with because each face is a triangle - real interesting, actually. You then divide each (equilateral) triangle into 4 equilateral subtriangles (broken at the midpoints of each edge of the bigger triangle), and you can keep repeating this process until your sphere-like shape has enough vertices (points) to satisfy you. You also re-adjust each point along the way to ensure that it has a distance of 1 away from the origin, and then it becomes an isosphere! :)

Well yeah, that was heavily distorted too. So I rechecked the algorithm and each line of code at least a dozen times, and I figured, maybe the vertices can't be duplicates, so I revised the algorithm to get rid of duplicates. I also tried starting from an octahedron (to make an octasphere?). Nope, still heavily distorted.

Then I did some searching around and discovered that maybe the winding order had something to do with it, so I revised the algorithm to take care of that. Nope, still heavily distorted.

This process went on and on and on and on for hours and hours; I did all sorts of problem-solving with all diligence, determined to fix this stupid sphere. I plotted the points in gnuplot (looked like a sphere!), I manually checked and revised a bunch of vertices and indices, I turned features and indices on and off, I talked to my programming friends about the issue, I researched, I debugged the graphics pipeline, I changed memory structures, I tried a few other fixes, and I gave up a few times. Still a distorted sphere:

But, determined not to give up, totally baffled by this weird spear-like point that kept distorting my sphere - yet with perfect vertices and a rather simple algorithm - I finally figured out the problem: there was a byte-alignment property that was improperly set when I duplicated the cube-drawing code... Great.

The bad news is, I lost several days and many hours of development fixing this dumb sphere. The good news is, now it's finally drawing, and I understand the process extremely well and refreshed my memory on how the entire graphics pipeline and all of Fragile's drawing code works! So I'm sure that will have its benefits. Forty first step complete:

Fun fact: this beautiful sphere is made out of 4 levels of the recursive algorithm, and it consists of 1,026 vertices and 454 indices.

Next up: units, blocks, and gameplay!!!

Tuesday, May 24, 2016

Perfected Server Multithreading!

Ugh. I found an issue with the Durable server's multithreading code (aka. the "handle multiple clients at the same time capability"). Once I fixed it, several issues popped up.

At first, I thought I would have had to rewrite a large portion of the server code in order to fix these issues, and I even began to do so until I realized the full extent of how difficult that would have been (hard to explain). Then I rediscovered that I had already accounted for these issues while I was creating the foundation of the server way back (phew!), and so after that it only took me a couple of hours to fix.

The good news is, I thoroughly tested everything again and it all works wonderfully without errors. The bad news is, I lost a few days of development doing so. Such are the ways of software development.

This time, there are lots of pictures to demonstrate the multithreading working. Fortieth step complete:
Notice how both clients are logging in at the same time (both clients connect and version match before being logged in).

Both clients registering and logging in at the same time:

Both clients building and selecting each others' blocks and chatting to each other at the same time: