Monthly Archives: July 2013

Serializing and Deserializing Objects in JavaScript using JSON

The JavaScript code listed below declares a couple of “classes” (actually, functions) and then instantiates some nested instances of those classes. It then serializes the nested objects to a JSON string, displays that string, and then deserializes that string back … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

A Line-of-Sight Algorithm for a 2D Game

The JavaScript code below implements a (currently naive and inefficient) line-of-sight algorithm for a grid-based 2D game. To see it in action, copy it into an HTML file and open that file in a web browser that runs JavaScript.  Or, … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Converting a File to a Base64 DataURL in JavaScript

The code included below prompts the user to select a file, loads that file, and displays its contents in a text box as a DataURL encoded in Base64 characters.  To see it in action, copy it into an .html file and … Continue reading

Posted in Uncategorized | 14 Comments