Hallo,
Ik probeer een heightmap om te zetten naar een veld (een kamer).
Ik heb momenteel een probleem met de coördinaten.
Ik wil dat elke div ze eigen coördinaten heeft: Y,X.
Hij moet dus optellen tot de $this->widht/height gehaald is.
En dan weer op 0 zetten en door gaan
Height staat voor hoeveel rijden hoog is die, en widht voor hoelang die is. Is de max widht gehaal moet die dus een nieuwe rij beginnen (via CSS maar dit komt later).
Ik wil hem dus automatisch alles laten vullen maar hij moet het per div doen hoe moet ik dit doen?
PHP Class
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class roomcreate {
private $height;
private $widht;
private $roomdata;
public function __construct($widht, $height, $roomdata){
$this->widht = $widht;
$this->height = $height;
$this->roomdata = $roomdata;
}
public function create(){
$roomData = $this->roomdata;
for ($i=0; $i<=strlen($this->roomdata); $i++) {
$roomData = str_replace(1, , $roomData);
$roomData = str_replace(0, , $roomData);
}
for ($i=0; $i<=$this->height; $i++) {
$roomData = str_replace(yco, $i, $roomData);
}
for ($i=0; $i<=$this->widht; $i++) {
$roomData = str_replace(xco, $i, $roomData);
}
echo $roomData;
}
}
?>
HTML
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
CSS:
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.room {
position: relative;
margin-top: 10px;
}
.room div {
width: 64px;
height: 40px;
position: absolute;
background-image: url("img/1.png");
}
.room div.none {
background: #000;
}
Result
Quote:
Ik probeer een heightmap om te zetten naar een veld (een kamer).
Ik heb momenteel een probleem met de coördinaten.
Ik wil dat elke div ze eigen coördinaten heeft: Y,X.
Hij moet dus optellen tot de $this->widht/height gehaald is.
En dan weer op 0 zetten en door gaan
Height staat voor hoeveel rijden hoog is die, en widht voor hoelang die is. Is de max widht gehaal moet die dus een nieuwe rij beginnen (via CSS maar dit komt later).
Ik wil hem dus automatisch alles laten vullen maar hij moet het per div doen hoe moet ik dit doen?
PHP Class
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class roomcreate {
private $height;
private $widht;
private $roomdata;
public function __construct($widht, $height, $roomdata){
$this->widht = $widht;
$this->height = $height;
$this->roomdata = $roomdata;
}
public function create(){
$roomData = $this->roomdata;
for ($i=0; $i<=strlen($this->roomdata); $i++) {
$roomData = str_replace(1, , $roomData);
$roomData = str_replace(0, , $roomData);
}
for ($i=0; $i<=$this->height; $i++) {
$roomData = str_replace(yco, $i, $roomData);
}
for ($i=0; $i<=$this->widht; $i++) {
$roomData = str_replace(xco, $i, $roomData);
}
echo $roomData;
}
}
?>
HTML
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
CSS:
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.room {
position: relative;
margin-top: 10px;
}
.room div {
width: 64px;
height: 40px;
position: absolute;
background-image: url("img/1.png");
}
.room div.none {
background: #000;
}
Result
Quote: