rendered paste body<?php
// An example of Object Oriented Programming
// With respect to video games
class Sprite
{
protected $visible;
function __construct($visibility) {
$this->visible = $visibility;
}
function __destruct() {
}
public function SetVisibility($param) {
$this->visible = $param;
}
public function IsVisible() {
return $this->visible;
}
}
class Sprite2D extends Sprite
{
protected $width, $height;
protected $locx, $locy;
function __construct($width, $height, $x, $y, $visible) {
parent::__construct($visible);
$this->width = $width;
$this->height = $height;
$this->locx = $x;
$this->locy = $y;
}
function __destruct() {
}
public function SetWidth($width) {
$this->width = $width;
}
public function GetWidth() {
return $this->width;
}
public function SetHeight($height) {
$this->height = $height;
}
public function GetHeight() {
return $this->height;
}
public function SetXCoord($x) {
$this->locx = $x;
}
public function GetXCoord() {
return $this->locx;
}
public function SetYCoord($y) {
$this->locy = $y;
}
public function GetYCoord() {
return $this->locy;
}
}
class Sprite2DHTML extends Sprite2D
{
protected $htmlid;
function __construct($width, $height, $x, $y, $visible, $htmlid) {
parent::__construct($width, $height, $x, $y, $visible);
$this->htmlid = $htmlid;
}
function __destruct() {
}
public function DrawSprite() {
echo "<div id=\"{$this->htmlid}\" " .
"style=\"position:absolute;width:{$this->width}px;height:{$this->height}px;top:{$this->locx};left:{$this->locy};" .
(($this->IsVisible()) ? "" : "display:none;") .
"\"> </div>";
}
}
class Sprite2DImageHTML extends Sprite2DHTML
{
private $imageurl;
function __construct($width, $height, $x, $y, $visible, $htmlid, $imageurl) {
parent::__construct($width, $height, $x, $y, $visible, $htmlid);
$this->imageurl = $imageurl;
}
function __destruct() {
}
public function DrawSprite() {
echo "<div id=\"{$this->htmlid}\" " .
"style=\"position:absolute;width:{$this->width}px;height:{$this->height}px;top:{$this->locx};left:{$this->locy};background-image:url('{$this->imageurl}');" .
(($this->IsVisible()) ? "" : "display:none;") .
"\"> </div>";
}
}
$test = new Sprite2DImageHTML(100, 100, 100, 100, true, "test", "/images/chocobo_tales.gif");
$test->DrawSprite();
?>