www.MarkDawson.org

Mark Dawson's place in cyber space

Home Software Fun Family About Contact
Software

I am a software engineer by trade and in my spare time (when I get any) I like to learn new things and program.  The reason I like to program is because I love to problem solve and think in abstractions.  Plus it is very satisfying to build something and see it working.  Ideally I would love to go and do a PhD and program and invent all day, sounds like heaven.  Below is some stuff I have done in my spare time.

 

MD Software License

All of my code is released under the MD software license - this states "You can do anything you want with any of the code, change it, re-use it, do whatever you want with it, just give credit to me whenever you do for the initial work".

 

What's new

Unit testing - an article I wrote about my thoughts on unit testing.  Technologies used are C# and NUnit.

Serialization / Deserialization using the .Net framework.

.NET C#

I love C#, it is an awesome language to program with, check out some C# related items.  The try/catch/finally quiz is pretty fun for you hardened coders out there.

Linux

Linux is an Open Source operating system, one of a number of alternatives to Microsoft Windows.  I have a section of my website dedicate to Linux based projects, please follow this link to see more.

Book List

I like to read technical books to learn new technologies,  I started writing some basic comments down about the books I read, maybe you might find them useful.  Click here to read the list.

SVG - Scalable Vector Graphics

SVG is a standard for drawing Vector graphics, primarily on the web.  SVG is not just used for displaying graphics, it also allows for user interactions and animation.  This is done similarly to DHTML using JavaScript to manipulate the SVG DOM.  At work I helped to create an editing tool using SVG.  The tool basically takes input from lighting control hardware and updates an image to allow a user to get real-time feedback from their building lighting system. 

I think that SVG is a really cool technology,  it is an open specification, found here.  The main player is Adobe with their SVG viewer which is really the defacto standard in viewers, although Mozilla is also capable of rendering SVG natively.  Although I really like this technology I do not think it is really ready for the mainstream, the reason I say this is because it does not have any widgets, like scrollbars, drop downs, checkboxes etc.  So building a user interface is tedious, when you compare this to things such as Flash, Flex and the awesome upcoming XAML from Microsoft it has a long way to catch up.

If you are interested in learning more, here are some useful links:

Adobe SVG Zone - this will get you started and you can download their SVG viewer

KevLinDev - excellent place for beginners tutorials

Yahoo SVG Group - plenty of SVG people here to answer any questions you have.

Good SVG Book - explains all you need to know.  I have a copy myself and have found it very useful.

SVG Whiteboard
SVG whiteboard is a little app I created to let people draw to each other using SVG over the internet.  It is pretty simple to do using SVG and a few lines of ASP.Net to act as a server.  The basic premise is that every time a user draws on one board, the SVG posts the newly drawn data to the server which stores it in a buffer.  Each board continually polls the server to see if there is any new data to retrieve, if there is then it is collected and appended into the SVG DOM.  The networking inside the SVG uses the postURL method to send data to the server and getURL to retrieve the data.  Once the data is received it is turned into an XML Document Fragment using the parseXML method so that it can be appended inside the SVG DOM.

It is just a demo application, so only two people can use it at any time (the JavaScript code is written to accommodate unlimited users, but this webpage has hard coded user ids).  To run, one person clicks on the Whiteboard1 link below, the other on the Whiteboard2 link.  Then drawing on either board will be shown on the other users board.  Feel free to look at the code, but if you use it or modify it, please give credit to me.

Whiteboard1

Whiteboard2

 

THE CODE - (you will probably have to right click and download the files, in order to be able to view them, depending on your browser settings):

clsWhiteBoard.js -> contains functionality for handling user input.

clsDataSyncroniser.js -> handles sending and receiving data from the SVG to the server.

clsEnumNamespaces.js -> stores all of the different namespaces used in the applications.

WhiteBoard.svg -> creates the SVG whiteboard area, and loads the JavaScript files specified above.

newdrawing.aspx, newdrawing.aspx.cs, newdrawing.aspx.resx -> very simple data store to facilitate data transfer between different whiteboard instances (you obviously will need IIS capable or running ASP.Net to run these files, plus remove the .download postfix to the end of the file name, I added this so that the files could be downloaded)

 

SVG Gaming Framework
I got a little bit bored one night and decided that I would try to make a game using SVG.  After I started thinking about this I decided that it would be friendlier to make a framework for gaming in SVG that other people could use and build on to make their own games.  So the following code has some simple constructs, sprites, collision detection, animation and user input handling,  all of the basic requirements for a game.  Using the code you can quickly and easily make new games, so please go ahead and try to make your own games using this framework.  

There is an example game below called "Catch the Astronaut", which was build using this framework,  I was able to code it extremely quickly, thanks to all of the main framework in the files below: 

 

clsAnimationEngine.js  -> handles animating all of the sprites around the canvas.  It is possible to modify the frame rate of the animation to suit your needs.

clsBoundingBox.js -> the bounding region around a sprite.

clsCanvas.js -> handles all of the user input events, plus has reference to all of the other major items such as the animation engine etc.  You just need to inherit from this file when you create your own game.

clsLayer.js -> represents a layer to which sprites can be added or removed.  This allows sprites to be placed infront or behind each other, plus it also allows you to hide groups of sprites with a single command.

clsNamespaces.js -> class that holds all of the namespaces used in the framework.  You can add your own namespaces to this file.

clsSprite.js -> The sprite class contains methods for displaying images and shapes, as well as applying transformations.

clsSpriteCollection.js -> a collection used to hold multiple sprites

clsStatusBar.js -> a bar that normally appears at the top of the gaming area.  This allows you to put things like current score and number of remaining lives etc for users to see.

clsVertex2D.js -> A vector class used to help with collision detection.

SVGGamingEngine.zip - contains all of the files above in one zip file for easy download.

 

Again feel free to use any of this code in your own apps, but don't forget to give credit to me.

Catch The Astronaut
Catch The Astronaut - this is a game I created using the SVG game framework from above. It probably took me 2 or 3 hours to make using the framework above.  The aim of the game is to dodge the shooting stars whilst trying to save as many astronauts as you can.  You get more points the faster you go and the more astronauts you pick up.

Controls

Up Arrow - move forward, the more you hold this down the faster you will go.

Down Arrow - slow down, the more you hold it down, the more you slow down.

Left, Right Arrow - turn left and right

It is important that you click on the game area with the mouse and leave the mouse inside the game area, otherwise the controls will not work because the SVG viewer will not receive any keyboard events.

Click here to play, make sure you have read the above paragraph.  This game runs very smoothly on my computer (2.53Ghz Pentium 4), if it is slow and jerky, you can change the frame rate, by changing the value of the this.m_intFrameRate variable in the clsAstronautCanvas.js file.

Here are the files which are built on top of the Game Framework:

clsAsteroidSprite.js -> inherits from clsSprite.  The is the asteroid you should avoid in the game.

clsAstronautSprite.js -> inherits from clsSprite.  The astronaut that you need to try and catch.

clsSpaceCraftSprite.js -> inherits from clsSprite.  The spacecraft you control in the game.

clsAstronautCanvas.js -> inherits from clsCanvas.  Loads all of the sprites and handles the user input.

Astronaut.zip -> contains all the files required to play the game.

 

C# Chat Client and Server (Instant Messaging)
The following code allows you to create a chat server then have multiple clients connect and talk to each other like Instant Messaging.  The application was written in C# using Remoting, which is a very powerful easy to use way of communicating data across application domains.  The code can be downloaded from below.  The main reason I wrote this was because some of the people I worked with wanted a way to quickly talk to each other at work, but IM is not allowed where I work.  So we decided to create our own simple Instant Messaging framework.

I didn't include much of a GUI with this because my main goal was to create the backend networking part.  Creating a GUI to this framework is simple and easy and you can just plug the backend code right into anything you create.

The files you need are listed below:

RemotingServerClient.zip -> The Client and Server class library.  This library will allow you to connect remotely over the internet (you may have issues with firewalls).

MessagingServer.zip -> A GUI for the server, to allow you to start / stop and choose ports for the server.

MessagingClient.zip -> A very basic client front end - you might want to write your own, this one will not win any prizes, I just created it for testing the backend code.

 

.NET Compact Framework GDI+ Extension
A friend and I had the idea of creating an SVG viewer for the .NET Compact framework.  After initially looking into the framework, it can be seen that it is quite limited when it comes to graphics.  No paths, or transformations i.e. rotation, scaling and translation.  So I set about creating a library for the .NET compact framework that would easily let you do these things.  The code will be posted soon, I just have to tidy up the comments a bit first.