src/Neuron/GameServer/Map/Movement.php
private function calculateSpeed ()
	{
		$startSpeed;
		$endSpeed;
		$acceleration = 0;

		// Accelerated speed
		if (abs ($this->acceleration) > 0)
		{
			$startSpeed = $this->startSpeed;
			$acceleration = $this->acceleration;
			$endSpeed = $this->startSpeed + ($acceleration * $this->getDuration ());
		}

		// Constant velocity
		else
		{
			$startSpeed = $this->getDistance () / $this->getDuration ();
			$endSpeed = $startSpeed;
		}

		return array 
		(
			'start' => $startSpeed,
			'end' => $endSpeed,
			'acceleration' => $acceleration
		);
	}
private function calculateSpeed ()
	{
		$startSpeed;
		$endSpeed;
		$acceleration = 0;

		// Accelerated speed
		if (abs ($this->acceleration) > 0)
		{
			$startSpeed = $this->startSpeed;
			$acceleration = $this->acceleration;
			$endSpeed = $this->startSpeed + ($acceleration * $this->getDuration ());
		}

		// Constant velocity
		else
		{
			$startSpeed = $this->getDistance () / $this->getDuration ();
			$endSpeed = $startSpeed;
		}

		return array 
		(
			'start' => $startSpeed,
			'end' => $endSpeed,
			'acceleration' => $acceleration
		);
	}
private function calculateSpeed ( ) { $ startSpeed ; $ endSpeed ; $ acceleration = 0 ; // Accelerated speed if ( abs ( $ this -> acceleration ) > 0 ) { $ startSpeed = $ this -> startSpeed ; $ acceleration = $ this -> acceleration ; $ endSpeed = $ this -> startSpeed + ( $ acceleration * $ this -> getDuration ( ) ) ; } // Constant velocity else { $ startSpeed = $ this -> getDistance ( ) / $ this -> getDuration ( ) ; $ endSpeed = $ startSpeed ; } return array ( 'start' => $ startSpeed , 'end' => $ endSpeed , 'acceleration' => $ acceleration ) ; }
Return an array of speed & acceleration
Speed is defined in pixels / second
Return an array of speed & acceleration Speed is defined in pixels / second