Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Normand Erwan
VVVVVV_level_merger
Commits
dc52a18c
Commit
dc52a18c
authored
Jun 01, 2015
by
Orbmancer
Browse files
echo some stuff
parent
64038df1
Changes
2
Hide whitespace changes
Inline
Side-by-side
merge.php
View file @
dc52a18c
...
...
@@ -19,6 +19,7 @@ foreach($levels as $level){
$myContent
=
new
Tabs
();
$myContent
->
importXML
(
$level
[
'data'
]);
$final
->
setTab
(
$myContent
->
getTab
(),
$level
[
'x'
],
$level
[
'y'
]);
unset
(
$myContent
);
}
echo
$final
->
toString
();
model/Tabs.class.php
View file @
dc52a18c
...
...
@@ -3,7 +3,7 @@
class
Tabs
{
private
static
$tabwidth
=
40
;
private
static
$tabheight
=
3
1
;
private
static
$tabheight
=
3
0
;
private
$mapwidth
;
private
$mapheight
;
private
$tabsRaw
;
...
...
@@ -14,11 +14,11 @@ class Tabs
$this
->
mapwidth
=
5
;
$this
->
mapheight
=
5
;
$this
->
content
s
=
array
();
$this
->
tab
s
=
array
();
for
(
$i
=
1
;
$i
<=
5
;
++
$i
)
for
(
$j
=
1
;
$j
<=
5
;
++
$j
)
$this
->
content
s
[
$i
][
$j
]
=
array
();
$this
->
tab
s
[
$i
][
$j
]
=
array
();
}
public
function
importXML
(
$string
)
{
...
...
@@ -31,25 +31,26 @@ class Tabs
$line
=
array
();
$prev_y
=
1
;
for
(
$i
=
0
;
$i
<
count
(
$tabs
);
++
$i
){
for
(
$i
=
0
;
$i
<
count
(
$tabs
)
-
1
;
++
$i
){
$tab_x
=
$this
->
getTabX
(
$i
);
$tab_y
=
$this
->
getTabY
(
$i
);
echo
'TAB INDEX: '
.
$i
.
' : '
.
$tab_x
.
'|'
.
$tab_y
.
'<br/>'
;
$line
[]
=
(
int
)
$tabs
[
$i
];
if
(
$prev_y
!=
$tab_y
){
$this
->
content
s
[
$tab_x
][
$tab_y
][]
=
$line
;
$this
->
tab
s
[
$tab_x
][
$tab_y
][]
=
$line
;
$line
=
array
();
}
}
}
private
function
getTabX
(
$index
){
return
(
int
)
floor
(
$index
/
self
::
$tabwidth
)
%
5
+
1
;
return
1
+
(
int
)
(
floor
(
$index
/
self
::
$tabwidth
)
%
5
)
;
}
private
function
getTabY
(
$index
){
return
(
int
)
floor
(
$index
/
(
self
::
$tabwidth
*
$this
->
mapwidth
*
self
::
$tabheight
))
+
1
;
return
1
+
(
int
)
floor
(
$index
/
(
self
::
$tabwidth
*
$this
->
mapwidth
*
self
::
$tabheight
));
}
public
function
settabs
(
$tabs
)
{
...
...
@@ -67,14 +68,15 @@ class Tabs
for
(
$i
=
1
;
$i
<=
5
;
++
$i
)
{
for
(
$j
=
1
;
$j
<=
5
;
++
$j
)
{
foreach
(
$this
->
content
s
[
$i
][
$j
]
as
$line
)
{
foreach
(
$this
->
tab
s
[
$i
][
$j
]
as
$line
)
{
foreach
(
$line
as
$block
){
if
(
$block
!=
0
){
$x
=
$i
;
$y
=
$j
;
$exit
=
true
;
break
;
}
if
(
$exit
)
break
;
}
if
(
$exit
)
break
;
...
...
@@ -98,7 +100,7 @@ class Tabs
for
(
$i
=
0
;
$i
<
self
::
$tabwidth
;
++
$i
){
$line
[]
=
0
;
}
$this
->
content
s
[
$x
][
$y
][]
=
$line
;
$this
->
tab
s
[
$x
][
$y
][]
=
$line
;
}
}
...
...
@@ -113,7 +115,7 @@ class Tabs
for
(
$i
=
1
;
$i
<=
5
;
++
$i
){
for
(
$j
=
1
;
$j
<=
5
;
++
$j
)
{
foreach
(
$this
->
content
s
[
$i
][
$j
]
as
$l
=>
$line
)
{
foreach
(
$this
->
tab
s
[
$i
][
$j
]
as
$l
=>
$line
)
{
foreach
(
$line
as
$b
=>
$block
){
$txt
.
=
$block
.
','
;
}
...
...
@@ -125,11 +127,12 @@ class Tabs
}
public
function
setTab
(
$tab
,
$x
,
$y
){
$this
->
content
s
[
$x
][
$y
]
=
$tab
;
$this
->
tab
s
[
$x
][
$y
]
=
$tab
;
}
public
function
getTab
(){
$where
=
$this
->
whereIsMyLevelLocated
();
return
$this
->
contents
[
$where
[
'x'
]][
$where
[
'y'
]];
echo
'WHERE:'
.
$where
[
'x'
]
.
'|'
.
$where
[
'y'
]
.
'<br/>'
;
return
$this
->
tabs
[
$where
[
'x'
]][
$where
[
'y'
]];
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment