Pages

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:

Friday, May 20, 2016

We have music! (Sort of.)

That's right, I decided that a game is not really a game until it has music in it.

Desiring to keep in spirit with the game, continue on with other development, and pursue a neat idea I've always had, I decided to create a music generator using DirectSound and raw mathematical music synthesis. This is only the first step (it plays 3 simple power chords using mere sine waves, as can be heard in the video), but the rest is relatively easy (especially given my background in music theory and composition and electronic music production).

One of the advantages this will bring in the near future is the concept of infinite auto-generated music. For the time being, I will probably settle with generating basic ambient music, lest the game devolve into irritability, but I already have the concepts of notes, half steps, and ADSHR (attack, decay, sustain, hold, and release) envelopes programmed in.

This should not take much development time away from the game at all, and I will ensure that it is a contributive, pleasant, and disable-capable feature. Thirty ninth step complete:

Tuesday, May 17, 2016

Vastly Improved Networking Code!

Another set of long hours dedicated to Fragile and now all of its networking code for both the client and server are vastly improved! Now it's much stabler and I will be able to develop the multiplayer gameplay and other chat features a lot more quickly.

I also officially added multiplayer block creation by mouse (not by chat command). Unfortunately, however, there's nothing new and appealing to show here, as the visuals look exactly the same, especially since my server testing is done on the same computer and there's virtually no delay. :P

Looking forward to some real, raw gameplay progress shortly though! This is where development gets exciting. Thirty eighth step complete:

Monday, May 16, 2016

Block Building and Selection!

Due to numerous hours of mathing and coding and fiddling, Fragile now has block-building and block selection capabilities! This was definitely one of the more difficult aspects of the game, but it is a significant milestone in adding core gameplay functionality.

(Fun fact: I also added a "cursor dot" in the center of the screen by drawing a reeaally small cube right in front of the player! :)

Thirty seventh step complete:

Friday, May 13, 2016

Adding Multiplayer Blocks by Command!

Once again, months have gone by, but today after several hours of work I have fixed all of the remaining registration and login bugs (that I'm aware of).

Even more significantly, now, at the current state of the Durable server, I am able to add new blocks at specific positions in the game that I command from inside of Fragile, and they will also be added in all of the other clients' games as well! This is the first major step in constructing and maintaining game worlds for players to play in! I am very happy with the results.

(I thought this should go without saying, but for clarification purposes, no, these blocks are not actually being added by the chat commands themselves, only dictated to the server that way for the time being.)

Thirty sixth step complete:

Next, I will probably develop the multiplayer gameplay itself.