예제 #1
0
 /**
  * This method is called when the game enters this game loop.
  * This is where you would replace the default frame among other things.
  */
 public function onEnter()
 {
     parent::onEnter();
     $this->p1UpSprite->setVisible(false);
     $this->p1UpSprite->setVisible(false);
     $this->p1UpSprite->setVisible(false);
     $this->p1UpSprite->setVisible(false);
 }
예제 #2
0
 public function onFrameUpdate()
 {
     $this->frameTimestamp = microtime(true);
     switch ($this->gameState) {
         case self::GAMESTATE_INITIALIZING:
             if (empty($this->initializationTimestamp)) {
                 $this->initializationTimestamp = $this->getCurrentMicrotime();
             } else {
                 $this->approxFrameTime = $this->getCurrentMicrotime() - $this->initializationTimestamp;
                 printf("approxFrameTime: %f\n", $this->approxFrameTime);
                 $this->gameState = self::GAMESTATE_WAITING;
             }
             break;
         case self::GAMESTATE_PLAYING:
             // Move sprites before calling parent
             foreach (self::$inputDevices as $device => $paddle) {
                 $this->updatePaddlePositionForDevice($device);
             }
             $this->updatePaddleSpritePositions();
             $this->updateBallPosition();
             break;
         case self::GAMESTATE_WAITING:
         case self::GAMESTATE_GAMEOVER:
         default:
             break;
     }
     parent::onFrameUpdate();
 }
예제 #3
0
 public function __construct(FrameBuffer $frameBuffer, ContainerInterface $container)
 {
     parent::__construct($frameBuffer, $container);
     $this->background = $this->bitmapLoader->loadBitmap('test_image');
 }
 public function __construct(FrameBuffer $frameBuffer, ContainerInterface $container)
 {
     parent::__construct($frameBuffer, $container);
     $this->pressStartFrame = $this->bitmapLoader->loadBitmap('press_start')->getPixels();
     $this->toPlayFrame = $this->bitmapLoader->loadBitmap('to_play')->getPixels();
 }