Monday, 11 March 2013

CSS : Create horizontally / vertically aligned elements without a table

A label is actually a -by default- inline HTML element, therefore no standardized width can be applied​ to it. Eventually this means that developers end up with elements that basically look vertically unaligned.

The solution is to add the following CSS rule on your stylesheet:

    vertical-align: central;
    display: inline-block;
    width: auto;
    text-align: left;

thus, a static width can be defined and the vertical alignment can finally be fixed. I hope this helps someone.

Friday, 8 March 2013

A simple Snake Game Tutorial in C# and WPF


My effort is to try and explain some basic concepts of programming based on really simple words and examples. This article has been posted also on codeproject


The main idea behind a snake game (as in most such games)  is to "fool" the user into thinking that a series of frames is in reality a moving object. Such a concept is fabricated in my implementation. The "motion" effect is based on a series of  Timer events, each of which is "ticking" among specific intervals. The head of the snake is being drawn on a new position slightly misplaced to the direction of motion. The end of its tail is erased from our canvas, thus creating an illusion of motion.