Tags

, ,

I got an email today, asking if I could provide the source for VDE. I did have that stored on DropBox, but I removed it recently. So, I’ve added it back to Dropbox, after going through my code and adding some extra comments. You can find it here.

It’s under the Creative Commons Attribution 4.0 licence, so if anyone does use this, please attribute this to me and include a link to the source in the credits. If you have any questions, don’t hesitate to drop me an email asking about it.

Update 13th of June:
I’ve been told that there might be a problem with the code I included, most likely on line 127 of LevelManager.cs:

newPiece = possiblePieces[Random.Range(0, possiblePieces.Count)];

I suspect that this is caused by the syntax I’ve used for Random.Range there. The indices of a List or array in C# run from 0 to 1 below the number of elements in the array – i.e. in the array [a, b, c, d], there are four elements and the indices run from 0 to 3. However, if Random.Range takes a pair of integers, it will return anything between the first and a value that is one lower than the second, e.g Random.Range(0, 2) will return either 0 or 1 if 0 and 2 are passed as integers. If they’re passed in as floats, it will return any float ranging from 0 to 2 – including 2.

The quickest solution, if this does happen, is to replace Random.Range(0, possiblePieces.Count) with Random.Range(0, possiblePieces.Count -1). If this does fix the problem, I’ll update the source code to match.

Advertisements