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!!!
Saturday, May 28, 2016
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:
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:
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:
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:
(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.
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.
Subscribe to:
Posts (Atom)