function cChar()
{
	this.x;
	this.y;
	this.dir;
	this.speed;
	this.state;
	this.stateFrame;
	this.stateLength;
	this.lastState;
			
	this.width;
	this.height;
	this.centre_width;
	this.centre_height;
	
	this.xTile;
	this.yTile;
	
	this.downY;
	this.upY;
	this.leftX;
	this.rightX;
	this.upLeft;
	this.downLeft;
	this.upRight;
	this.downRight;
	
	this.jumping;
	this.falling;
	
	this.landed; //event handler for landed
	this.fallStarted; //handler for falling
	
	
	this.animFrame;
	this.animFrameLength;
		
	this.domRef;
	
	/* Class Methods */
	this.constructor = function(){}
	this.draw = function( domParent ){/*Overridable*/}
	
	this.setState = function( p_state )
	{
		this.lastState = this.state;
		this.stateFrame = 0;
		this.state = p_state;
	}	
	
	this.getMyCorners = function( x, y )
	{
		// Get the map tile each corner would be in...
		this.downY = Math.floor( ( y + ( this.centre_height - 1 ) ) / g_tileH );
		this.upY = Math.floor( ( y - ( this.centre_height - 1 ) ) / g_tileH );
  		this.leftX = Math.floor( ( x - ( this.centre_width - 1 ) ) / g_tileW );
  		this.rightX = Math.floor( ( x + ( this.centre_width - 1 ) ) / g_tileW );

		//window.status = this.downY + ":" + this.upY + "(" + y + " ):" + this.leftX + ":" + this.rightX + "::::";			

  		// check what tile they are up against
  		this.upleft = game.tiles.tiles[ g_maps[ game.currentMap ][ this.upY ][ this.leftX ] ].walkable;
  		this.downleft = game.tiles.tiles[ g_maps[ game.currentMap ][ this.downY ][ this.leftX ] ].walkable;
  		this.upright = game.tiles.tiles[ g_maps[ game.currentMap ][ this.upY ][ this.rightX ] ].walkable;
  		this.downright = game.tiles.tiles[ g_maps[ game.currentMap ][ this.downY ][ this.rightX ] ].walkable;

		//window.status += this.upleft + ":" + this.downleft + ":" + this.upright + ":" + this.downright;
	}		
	
	this.moveChar = function( dirx, diry, jump )
	{
		var speed;
		if ( Math.abs( jump ) == 1 )
		{
			speed = this.jumpspeed * jump;
		}
		else
		{
			speed = this.speed;
		}
		//window.status = speed + ":" + jump + ":" + this.jumpspeed + ";;;;";
		
		// Check moving up and down capabilities
		this.getMyCorners( this.x, this.y + speed * diry );
		
		if ( diry == -1 )
		{
			if ( this.upleft && this.upright )
			{
				this.y += diry * speed;
			}
			else
			{
				this.y = this.yTile * g_tileH + this.centre_height;
				this.jumpspeed = 0;
			}
		}
		if ( diry == 1 ) 
		{
    		if ( this.downleft && this.downright && ! this.checkIfOnCloud() )
			{
      			this.y += speed * diry;
			} 
			else 
			{
      			this.y = ( this.yTile + 1 ) * g_tileH - this.centre_height;
				this.jumping = false;
				if( !this.falling )
				{
					if(this.landed)
						this.landed();
				}
    		}
  		}
		
		// Check moving left and right capabilities
		this.getMyCorners ( this.x + speed * dirx, this.y );
  		if (dirx == -1) {
    		if (this.downleft && this.upleft)
			{
      			this.x += speed * dirx;
				this.fall();
    		} 
			else 
			{
      			this.x = this.xTile * g_tileW + this.centre_width;
			}
  		}
  		if (dirx == 1) 
		{
    		if ( this.upright && this.downright) 
			{
      			this.x += speed*dirx;
				this.fall();
			} 
			else 
			{
       			this.x = ( this.xTile + 1 ) * g_tileW - this.centre_width
			}
		}

		// Set the new x and y tiles the character is in.
		this.xTile = Math.floor( this.x / g_tileW );
		this.yTile = Math.floor( this.y / g_tileH );
		
		// update the player div
		this.domRef.style.left = this.x - this.centre_width + "px";
		this.domRef.style.top = this.y - this.centre_height + "px";
		
		//window.status +=  " $ " + game.tiles.tiles[ maps[ game.currentMap ][ this.yTile ][ this.xTile ] ].door;
	}
	
	this.fall = function()
	{
		if ( ! this.jumping )
		{
			this.getMyCorners( this.x, this.y );
			if ( this.downleft && this.downright && ! this.checkIfOnCloud() )
			{
				this.jumpspeed = 0;
				this.jumping = true;
				this.falling = true;
			}
		}
	}
	
	this.checkIfOnCloud = function()
	{
		var leftcloud = game.tiles.tiles[ g_maps[game.currentMap][ this.downY ][ this.leftX ] ].cloud;
		var rightcloud = game.tiles.tiles[ g_maps[game.currentMap][ this.downY ][ this.rightX ] ].cloud;
		if ( ( leftcloud || rightcloud ) && this.yTile != this.downY )
		{
			return true;
		} 
		else 
		{
			return false;
		}
	}
			
	this.update = function (){}
	this.constructor(); // Call class constructor
}
