Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Vexal

Member Since 28 Sep 2007
Offline Last Active Jul 02 2014 04:16 PM

Topics I've Started

Confusion programming a server accepting websockets

27 June 2014 - 02:33 PM

I have written a basic HTTP server in C++ that supports regular websites, but am now trying to extend it to support websockets.  All of the networking and parsing is done by my own code, so no libraries -- except I copied and pasted some code for computing SHA1 and converting to base64.

 

I am reading several guides that describe how to handshake an incoming websocket connection, such as this: http://www.altdev.co/2012/01/23/writing-your-own-websocket-server/ and http://enterprisewebbook.com/ch8_websockets.html

 

I am stuck on the part where the server needs to take the key from the client's header and append the magic string onto it, then hash it with SHA1, encode it in base64, and send the result back as part of the accept header.

 

The specific part giving me trouble is the '==' in the key, and the '=' in the resulting string sent back by the server.  I can't find any information stating what to do with these -- do I drop the == from the key before appending the magic string to it, or do I keep them on?  Also, I can't figure out where the '=' at the end of the final server answer comes from -- and why the server's answer only has a single '=' and the client's key has two '='

 

Lastly, I am confused about why the magic string the server uses is in base16, but the key sent by the client's browser is already base64 -- do I need to convert the server string to base 64 before appending it, or does it not matter?

 

And when I convert to base 64, am I converting it as if each ascii symbol is the digit (so 'A' in the string would be 10), or am I converting the binary representation of the entire string to a string representing the original binary but with digits of base64?

 

 


I made a web app version of the internet.

23 June 2014 - 01:07 PM

I know everyone loves the convenience of Web Apps, but for some reason, we use a native client to browse the web.  I created a solution to this: a web app version of Chrome that runs right inside your web browser.  Now the only things you need to conveniently browse the internet is an internet connection and a web browser.

 

Here is a demonstration:

 


Stumped on collision detection for animated voxels.

30 May 2014 - 12:40 AM

I recently started a rogue-like platformer game, where all characters are voxel-based and the player has an inventory of additional blocks that the user can add to their character (added blocks must be adjacent to existing blocks).  All properties of the character (guns, ammo, etc) are based on the block configuration, and if a block is hit, it's destroyed.  The player gets more blocks in their inventory when they kill stuff.

 

Video of some prototype gameplay.  This video shows some combat, and as well as the system for adding blocks to your character. -- for reference, if the blue heart block on a character is destroyed, the whole character dies;  if a block is left dangling with no path to the blue heart block, that block falls off.

 

The problem I have run into is with animating the player's character -- animation is used meaning moving a voxel aligned with the grid to an adjacent grid square, no rotation or scaling.  Originally I was going to have no animations, but I feel animations are necessary to add character to the game.  However, since the player can add arbitrary blocks to their character, animation is difficult.  I have built a simple prototype for animating the position of individual voxels on a character, and this works well for now.  I've also drafted up a simple UI where the player can specify the position of blocks on their model at a given frame.

HdS0LjO.png

 

The user adds blocks by clicking on their actual model.  But animating blocks is done through the image of the block in the UI.  I know it looks bad right now, but it's just for testing, and making this UI from scratch look good is a pain.  The user will be able to select blocks by clicking on them (the white block in the picture is the block currently selected), and then scroll the frame count to a desired frame, then click on an adjacent empty block (block animations must be adjacent, and the block must still have at least one block touching it after moving).  This will cause the selected block to translate to that block at that frame.  Scrolling the frame counter updates the image to reflect the current state of the model at that frame, combining all animations.

 

The issue comes from the implications of the animations on platforming.  Collision detection is handled directly with the character model, so when a particular voxel animates, it changes how the character collides with the environment.  A video showing how the platforming works:

 

 

When walking on uneven areas, if the block touching the uneven area is calculated to be a "foot" block (has no blocks on the character under it), and the block on the terrain has no blocks above it, the game will boost the character up the terrain.

 

I am stumped on coming up with a design solution on how to handle animations without making collision with the environment unintuitive.  Imagine if your foot animates, and whether or not you land on a ledge depends on the current frame of animation.  Also, if a character is standing directly against a wall, and an animated voxel on the character is moved into the wall, what should I do?  Will players be just okay with this, and try to build their models in a way that doesn't make platforming difficult, or do I need to completely rethink or remove the animation system?


I wrote an article on transitioning between biomes in procedurally generated terrain

28 May 2014 - 11:52 AM

Video of result:

 

 

Copied and pasted from my website (it can't handle much traffic): http://vexal.us/Projects/TerrainGeneration/TerrainGeneration.html

Terrain2Low.jpg

 

Simplex Noise Terrain - July 2013 worldgenfile2.png

The generation function now uses Simplex Noise instead of Perlin Noise.

Shown in the picture to the left is an example world definition file used to create the parameters for the Simplex Noise, and the parameters used for the first video above. Inside each { } is the definition for a single simplex noise function. The function runs for each x,z input coordinate, and outputs a 'y' height value. Functions nested inside functions imply that whether the nested function is applied at a particular coordinate is dependent on the output of the parent function at that coordinate. This nesting is how biomes are created. For more information on how dependencies and biome nesting works, see the next section of this page, Selective Application of Noise Function Application.

Functions inside [ ] are function systems. They signify that multiple simplex noise functions are applied at each input coordinate, with the output value being all functions combined. The amplitude and frequency of these function systems are multiplied or divided for each successive octave.

The parameter names mean:

  • Frequency: The frequency of the simplex noise function. Higher values produce bumpier terrain. The input coordinates are multiplied by the frequency before computing the function output.
  • Ampltitude: The peak value of the simplex noise output. The output height of the simplex noise function is multiplied by the amplitude.
  • Contribute Value: Whether this function contributes to the output height value of the system -- non-contributing functions are used for dependencies.
  • Octave Count: For function systems, the octave count is the number of successive simplex noise functions applied on top of each other at a particular input coordinate.
  • Octave Start: The offset for the octave count.
  • Persistence: In a function system, for each octave, the frequency of the function increases by a power of two, whereas the amplitude of the function is equal to pow(persistence, octaveIndex)
  • Frequency Multiplier: Multiplied to the frequency of each function in a function system.
  • Scale: The amplitude of a function system for each function is multiplied by the scale, and the frequency is divided by it.
  • Falloff Power: The output of the simplex noise at a particular coordinate is divided by some scalar to this power.
  • Dependency Type: For nested functions, dependency type determines how the child function is compared to the output of the parent function.
  • Dependency Fail Action: For nested functions, dependency fail action determines how to compute values in the failure range of the parent function.
  • Dependency Value: Dependency value 1 is the cutoff failure output for the child function to fail against the parent function's output. For interpolated functions, dependency value 2 is the interval outside the passing comparison of the parent function output for which the output of the child function goes to zero.

 

Selective Noise Function Application (biomes; varying landscapes) - June 2013

The screen shots of my terrain generation previously all demonstrated mountainous landscapes. If the goal is a huge mountain range, then this is perfect. However, if the goal is to make a useful game world, then having only mountain ranges can be problematic.

The first intuitive solution to this issue which comes to mind is to make the frequency of the mountains lower, so that the high mountain peaks are more spread out. This solves the issue of there being no flat land, but it leaves another problem: In order for the mountains to look good, additional high frequency, low amplitude height functions must be added on top of the low frequency, high amplitude mountain functions (to give the mountain a craggy, bumpy look, as opposed to a rolling, smooth look). This is fine for the mountains, but since the noise functions are applied uniformly across the entire map, then all the areas in between the mountain peaks will also become needlessly bumpy. It is not enough to simply lower the frequency of the tall mountain peaks.

The next solution is to selectively apply the high frequency height functions. One could check the height value generated by the low frequency height function at a particular coordinate, and only if the height value is above a certain threshold, then the height value from the high frequency function will be applied. This allows the areas in between mountain peaks to remain flat, and the high mountain peaks to remain craggy.

Other conditions can descriminate which functions to apply in which areas. For example, one could have a very low frequency height function which only returns 1, 2, or 3 at any coordinate. Coordinates where the function returns 1 could on top apply a set of noise functions producing a low frequency rolling hill; coordinates returning 2 could apply noise functions producing flat plains, etc.

Unfortunately, selective application of noise functions is not as straightforward as one wishes it be. As demonstrated by the following images:

NoiseFunctionNI_low.jpg NoiseFunctionNI2_low.jpg

The above images show that if a noise function is only applied to a specific area, there is a discontinuity at the coordinates at the edge of where the noise function is applied.

The solution to this issue is to interpolate the resulting height of the function at the coordinates where it is no longer applied so that the output of the function smoothly goes to zero.

NoiseFunctionInterpolation3_low.jpg NoiseFunctionInterpolation6_low.jpg

Terrain with selectively applied noise functions interpolated at edges.

In the image on the left, the terrain is flat except for two areas where several noise functions are applied to create the appearance of a crater or rock formation. The noise functions are set to apply at coordinates whose value of a separate random function is past a threshold. The amplitudes of the noise functions are interpolated towards zero at a specified rate for coordinates not meeting the criteria for applying the functions.

The image on the right shows bumpy noise functions that are only applied to areas where the height of the mountain noise function exceeds a specified threshold. The threshold for application is near the top of the peak, and the bumpiness of the mountains gradually decreases towards the bottom.

Other Details

The system I have set up is intended to be as generalized as possible. A function can be set to be dependent on the value of any number of other functions at that coordinate. The dependency conditions can be set as well as the dependency fail actions.

An example of using this system could be to have a low frequency function intended to determine what land type is at a coordinate (snow, plains, mountains, grassland, etc). A set of functions can be created intended to only be used for specific land types.

 


Your first game / programming project?

27 May 2014 - 10:17 PM

What was your first project?

 

Mine was this Tetris game I made in the Warcraft 3 level editor in 2003 when I was 14.  It wasn't the first map I made in Warcraft, but it was my first time using the scripting language (JASS) instead of the GUI.  Level editing in WC3 was what initially taught me about things like variables and loops, before I ever got to a real language like Java.

 


PARTNERS