Thursday, November 30, 2017

Final Feature, Revamping Old Ones

Hey all,

This week on Particularly Wavy I have been working on the final feature I intend to add to the game, in addition to revisiting some previously implemented ones and giving them a bit more depth and UI dazzle, if such a word can be used.

The final feature I'd like to add is the emission of light from heated objects. I have a script and shader that are working to update the appearance of an object which is hit by an intensified beam of light, and the next step is simply to add the actual emission of light from that object. This is more or less the easier part, since it follows almost the same rules as the lasers and objects which emit light due to collisions.

The features I'm revisiting are chargeable objects and movable objects. Chargeable objects originally were implemented to connect to other objects using a line renderer to display an arc between the two objects, but I never got this working to my satisfaction, so I've gone back and changed it to a particle system which travels between the two. I've also been adding more functionality to the objects connected to the chargeable objects. They can be of different types, like doors that swing open, lasers that get activated, etc. For movable objects, I'm trying to add tracks to show where and how they can move.

Saturday, November 25, 2017

Fog of War

hey all,

So I have been working on adding a fog of war effect to my game. Fog of War normally means an effect in strategy games where parts of the map without any player units are unlit and in order to reveal that area, the player will have to send a unit there. Doing so will light up that area of the map and reveal any enemy units that were hiding out there.

I wanted a similar effect, but instead of units, I wanted my beams of light to reveal parts of the level. It turns out that this was very wrong of me, as it took over two weeks and more than 63 hours of coding, banging my head against the monitor, research, more coding, more head-smashing, more research, etc.

At first, I thought I would just implement a simple fog of war effect using shaders and quads. This worked fine for single objects that did not extend to far in any one direction, but just didn't look very nice for light beams.

Then, I thought just using Unity's built in lights would be the next obvious step, but they did not produce the results I wanted, and had awful side effects like washing out the little color that I have in the game and making some elements look even more unattractive than before.

My penultimate step was to look at particle systems. This actually seemed like it might work, but I ran into bug after bug after bug, even after literally copying and pasting code from Unity's own website. So I gave up on that.

I was about to just quit and when I remembered a subject that I had researched in some detail months ago for my Digestion Game: metaballs! Now, before you get sick images of balls made of other balls, metaballs are simple a way to take overlapping sprites and combining their properties in various ways. They have been used for water rendering, influence mapping, and for lots of other stuff. I quickly found a few shaders that looked promising, tweaked their code, and set up some prefabs in Unity. The actual setup to produce the effect took less than an hour, but I spent a good 4 hours working out the best (to my mind and to my current abilities) solution for handling them together with my lights. It is still not fool proof, but I think I have got a pretty nice solution.




Wednesday, November 8, 2017

All Work and No Play...

hey all,

Yes, I'm still hard at work on Particularly Wavy. In the last week I have designed six new puzzles, many of which utilize the mechanics I've been describing in the last several blog posts. I hope to publish the game very soon, but I will continue to work on adding more puzzles over the next few weeks.

In addition to adding more content to the game, I've now implemented rudimentary scoring mechanics and, yes, have found and fixed even more bugs with my refraction calculations. Above a particular angle between the surface normal and the light vector (if you understand that phrase, then you already know what is coming next), the light will be reflected inside the prism instead of exiting it. This requires a different kind of calculation, and basically just re-complicated my refraction code that I had spent so many days simplifying. In any case, it seems to be working nicely, and without hogging too many system resources.

But don't get the idea that I am chained in front of my computer all day every day, slaving away at this game. I'm still enjoying playing video games that others have slaved over, such Total War: Warhammer, The Banner Saga, and Duskers. I'm pulling up to the 200 hour mark for Total War: Warhammer, and there are still two factions (Beastmen and Brettonia, plus another DLC I don't have yet for Norsca) that I haven't played, as well as two special campaign maps that I haven't done yet. And then there are still several games that I purchased months or years ago that I haven't gotten around to playing, like SpellForce 2, King of Dragon Pass, Democracy, and Crusader Kings II. And my wife and I are still planning trips to take in the near future, so we will be getting out and about and exploring this planet of ours.

Cheers,

Sunday, October 29, 2017

Ground-Up Rewrite

hey all,

I have been working to integrate lenses and destructible objects into the framework I've already developed, but this weekend I ran into a snag. As I was experimenting with moving and rotating my lens, I realized that the calculation for how light refracts through it was fundamentally flawed. Now matter how I rotated the lens, light was always bent down. The kicker to this was that I had basically copied the code I used for calculating refraction through a prism, which meant that those calculations were fundamentally flawed too. So over the whole weekend I have rewritten the refraction algorithms and calculations, greatly simplifying them and correcting the errors from before. I've also been correcting some small positional errors throughout the whole code base.

With these fixes and changes in place, the next week's work will focus on redesigning the first 18 levels, and on expanding the game with more puzzles to solve.

Cheers,

Sunday, October 22, 2017

Particularly Wavy Black Hole Update

hey all,
I've continued working on the black hole effect, and now, after several weeks of work I have something that I like quite a bit. This effect is, in my opinion, almost ready to be included in the game. The main catch is that right now I am not checking for any collisions within the influence of the black hole itself. There is now really nice way of doing this, but I think I have an idea that might work.



The other update to the game is actually not visible at all, but should greatly increase performance. In previous versions, I would update the light every frame, even if nothing had changed. In the newest version, I have made use of a callback function on every moveable object. When the object is moved or rotated, the function notifies the light emitting object and the light is recalculated from the beginning. If no object gets moved, the light is not updated, which should have a lot of calculations each frame and make the game run much smoother.

There are one or two main updates I would like to make to the game before starting work on designing more levels, but these should be doable within the next two weeks (as the famous construction joke goes).


I'd also like to make the UI compatible with mobile devices, but that is a distant 3rd on my list of things to work on. In any case, here goes to successful game development.

Sunday, October 15, 2017

Particularly Wavy Updates

hey all,

I've spent the last week nailing down a black hole-like effect for Particularly Wavy. It is still extremely rough, and needs a lot of ironing out of details, bugs, and at the moment is probably very expensive in terms of processor use.


Vector3 gravityVec;
  float d;

  Vector3 accel = Vector3.zero;
  Vector3 previous = pos;
  float time = 0.05f;
  float diff = 0.1f;
  for (int i = 0; i < 150; i++)
  {

   gravityVec = center - previous;
   d = Vector3.Distance(center, previous);
   accel.x = blackHoleMass / (d * d * d * d * d);
   accel.y = blackHoleMass / (d * d * d * d * d);
   accel = Vector3.Scale(accel, gravityVec);
   vel += accel * time;
   previous += vel * time;

   if (i % 2 == 0)
   {
    tempList.Add(previous);
   }
   Debug.DrawLine(center, previous, Color.red, 1f);
   if (Vector3.Distance(previous, center) < rad + diff)
   {
    tempList.Add(previous);
    node.hitObject = go;
    hitHole = true;
    break;
   }
   else if (Vector3.Distance(previous, center) > blackHoleDistance + rad)
   {
    tempList.Add(previous);
    break;
   }
  }

I though it might be a bit fun to share some of the code that I've been working on to make this happen. To begin with, the acceleration is set to zero, the velocity is set to a normalized vector indicating the direction of travel multiplied by speed, and a starting position for the light to enter the influence of the black has been found. A time step of 0.05 seconds is used to simulate the physics.

In the loop, the acceleration is the first thing computed. This is found by subtracting the position vectors between the black hole and the light particle, then getting the distance between the previous position and the center of the black hole. Under this model, acceleration is proportional to the mass of the black hole divided by the distance to the 5th power. This acceleration is multiplied by the time step and added to the previous velocity to get the new velocity. Similarly, the new velocity is multiplied by the time step and added to the previous position to yield the new position.

If, while going through the loop, the new position is inside the radius of the black hole or is outside the influence zone of the black hole, we break out. From here, the new positions need to be applied to the line renderer's positions.

This is obviously not exactly how gravity works in the real world. For starters, it is proportional to the masses of the two objects divided by the square of the distance between them, Newton's famous relationship that Robert Hooke accused him of stealing. Of course, light particles have no mass, but their interaction with black holes is caused by the intense gravity actually curving space-time itself.

Sunday, September 24, 2017

Particularly Wavy Update Three

hey all,

Still hard at work on Particularly Wavy. I now have ten puzzles up and running, and have the main mechanics of the game set. I hope to be adding some music from one of my coworkers in the future.