/** * @return array */ public function getPixels() { $origw = $this->bitmap->getWidth(); $origh = $this->bitmap->getHeight(); $origpixels = $this->bitmap->getPixels(); $pixels = $this->blankPixels; $maxx = min($this->width, $origw - $this->xOffset); $maxy = min($this->height, $origh - $this->yOffset); for ($y = 0; $y < $maxy; ++$y) { $oy = $this->yOffset + $y; if ($oy < 0) { continue; } for ($x = 0; $x < $maxx; ++$x) { $ox = $this->xOffset + $x; if ($ox < 0) { continue; } $pixels[$y * $this->width + $x] = $origpixels[$oy * $origw + $ox]; } } return $pixels; }
/** * 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() { if ($this->background) { $this->frameBuffer->setBackgroundFrame($this->background->getPixels()); } }