Ejemplo n.º 1
0
	MapRenderer.onRender = function OnRender( tick, gl )
	{
		var fog   = MapRenderer.fog;
		fog.use   = MapPreferences.fog;
		var light = MapRenderer.light;

		var modelView, projection, normalMat;
		var x, y;

		// Clean mouse position in world
		Mouse.world.x =  -1;
		Mouse.world.y =  -1;
		Mouse.world.z =  -1;

		// Clear screen, update camera
		gl.clear( gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT );
		Camera.update( tick );

		modelView  = Camera.modelView;
		projection = Camera.projection;
		normalMat  = Camera.normalMat;

		Ground.render(gl, modelView, projection, normalMat, fog, light );
		Models.render(gl, modelView, projection, normalMat, fog, light );

		if( Altitude.intersect( modelView, projection, _pos)) {
			x = _pos[0];
			y = _pos[1];

			// Walkable
			if( (Altitude.getCellType( x, y ) & Altitude.TYPE.WALKABLE) ) {
				GridSelector.render( gl, modelView, projection, fog, x, y );
				Mouse.world.x =  x;
				Mouse.world.y =  y;
				Mouse.world.z =  Altitude.getCellHeight( x, y );
			}
		}

		EntityManager.render( gl, modelView, projection, fog );

		Water.render( gl, modelView, projection, fog, light, tick );

		// Display clouds on maps
		Sky.render( gl, modelView, projection, fog, tick );

		// Rendering effects
		Damage.render( gl, modelView, projection, fog, tick );
		//Effects.render( gl, modelView, projection, fog );

		// Play sounds
		Sounds.render( Session.Entity.position, tick );

		// Find entity over the cursor
		var entity = EntityManager.intersect( modelView, projection );
		EntityManager.setOverEntity( entity );

		// Clean up
		MemoryManager.clean(gl, tick);
	};
Ejemplo n.º 2
0
	/**
	 * Does a cell is free (walkable, and no entity on)
	 *
	 * @param {number} x
	 * @param {number} y
	 * @param {returns} is free
	 */
	function isFreeCell(x, y)
	{
		if (!(Altitude.getCellType(x, y) & Altitude.TYPE.WALKABLE)) {
			return false;
		}

		var free = true;

		EntityManager.forEach(function(entity){
			if (Math.round(entity.position[0]) === x &&
			    Math.round(entity.position[1]) === y) {
				free = false;
				return false;
			}

			return true;
		});

		return free;
	}