PHP code example of masyasmv / otus_moving_objects

1. Go to this page and download the library: Download masyasmv/otus_moving_objects library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

masyasmv / otus_moving_objects example snippets


use App\Service\Mover;
use App\Service\Rotator;
use App\Contract\Positionable;
use App\Contract\VelocityAware;
use App\Contract\Rotatable;
use App\ValueObject\Vector2D;

// Пример корабля:
class Ship implements Positionable, VelocityAware, Rotatable {
    use App\Trait\HasPosition;
    use App\Trait\HasVelocity;
    use App\Trait\HasAngle;

    public function __construct() {
        $this->setPosition(new Vector2D(0, 0));
        $this->velocity = new Vector2D(1, 0);
    }
}

$ship = new Ship();

$mover = new Mover();
$mover->move($ship);

$rotator = new Rotator();
$rotator->rotate($ship, 45);