Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yutio888
Tales of MajEyal
Commits
27168ee3
Commit
27168ee3
authored
5 years ago
by
DarkGod
Browse files
Options
Downloads
Patches
Plain Diff
plop
parent
1ecb855d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/tilemaps/Maze.lua
+5
-5
5 additions, 5 deletions
game/engines/default/engine/tilemaps/Maze.lua
game/engines/default/engine/tilemaps/Tilemap.lua
+13
-4
13 additions, 4 deletions
game/engines/default/engine/tilemaps/Tilemap.lua
with
18 additions
and
9 deletions
game/engines/default/engine/tilemaps/Maze.lua
+
5
−
5
View file @
27168ee3
...
...
@@ -29,7 +29,7 @@ function _M:init()
Tilemap
.
init
(
self
)
end
function
_M
:
makeSimple
(
w
,
h
,
floors
,
walls
,
enclosed
)
function
_M
:
makeSimple
(
w
,
h
,
floors
,
walls
,
enclosed
,
allow_position
)
if
type
(
floors
)
==
"string"
then
floors
=
{
floors
}
end
if
type
(
walls
)
==
"string"
then
walls
=
{
walls
}
end
...
...
@@ -68,16 +68,16 @@ function _M:makeSimple(w, h, floors, walls, enclosed)
xpos
=
pick
[
1
]
ypos
=
pick
[
2
]
local
dir
=
{}
if
xpos
+
2
>
mw
and
xpos
+
2
<
Mw
and
mazemap
[
ypos
][
xpos
+
2
]
then
if
xpos
+
2
>
mw
and
xpos
+
2
<
Mw
and
mazemap
[
ypos
][
xpos
+
2
]
and
(
not
allow_position
or
allow_position
(
self
:
point
(
xpos
+
2
,
ypos
)))
then
dir
[
#
dir
+
1
]
=
6
end
if
xpos
-
2
>
mw
and
xpos
-
2
<
Mw
and
mazemap
[
ypos
][
xpos
-
2
]
then
if
xpos
-
2
>
mw
and
xpos
-
2
<
Mw
and
mazemap
[
ypos
][
xpos
-
2
]
and
(
not
allow_position
or
allow_position
(
self
:
point
(
xpos
-
2
,
ypos
)))
then
dir
[
#
dir
+
1
]
=
4
end
if
ypos
-
2
>
mh
and
ypos
-
2
<
Mh
and
mazemap
[
ypos
-
2
][
xpos
]
then
if
ypos
-
2
>
mh
and
ypos
-
2
<
Mh
and
mazemap
[
ypos
-
2
][
xpos
]
and
(
not
allow_position
or
allow_position
(
self
:
point
(
xpos
,
ypos
-
2
)))
then
dir
[
#
dir
+
1
]
=
8
end
if
ypos
+
2
>
mh
and
ypos
+
2
<
Mh
and
mazemap
[
ypos
+
2
][
xpos
]
then
if
ypos
+
2
>
mh
and
ypos
+
2
<
Mh
and
mazemap
[
ypos
+
2
][
xpos
]
and
(
not
allow_position
or
allow_position
(
self
:
point
(
xpos
,
ypos
+
2
)))
then
dir
[
#
dir
+
1
]
=
2
end
...
...
This diff is collapsed.
Click to expand it.
game/engines/default/engine/tilemaps/Tilemap.lua
+
13
−
4
View file @
27168ee3
...
...
@@ -120,6 +120,10 @@ point_meta = {
distance
=
function
(
p
,
p2
)
return
core
.
fov
.
distance
(
p
.
x
,
p
.
y
,
p2
.
x
,
p2
.
y
)
end
,
addDir
=
function
(
p
,
dir
)
local
dx
,
dy
=
util
.
dirToCoord
(
dir
)
return
_M
:
point
(
p
.
x
+
dx
,
p
.
y
+
dy
)
end
,
clone
=
function
(
p
)
return
_M
:
point
(
p
)
end
,
...
...
@@ -414,7 +418,7 @@ function _M:hasResult()
end
--- Locate a specific tile
function
_M
:
locateTile
(
char
,
erase
,
min_x
,
min_y
,
max_x
,
max_y
)
function
_M
:
locateTile
(
char
,
erase
,
min_x
,
min_y
,
max_x
,
max_y
,
allow_position
)
local
res
=
{}
min_x
=
min_x
or
1
min_y
=
min_y
or
1
...
...
@@ -422,7 +426,7 @@ function _M:locateTile(char, erase, min_x, min_y, max_x, max_y)
max_y
=
max_y
or
self
.
data_h
for
i
=
min_x
,
max_x
do
for
j
=
min_y
,
max_y
do
if
self
.
data
[
j
][
i
]
==
char
then
if
self
.
data
[
j
][
i
]
==
char
and
(
not
allow_position
or
allow_position
(
self
:
point
(
i
,
j
)))
then
res
[
#
res
+
1
]
=
self
:
point
(
i
,
j
)
if
erase
then
self
.
data
[
j
][
i
]
=
erase
end
end
...
...
@@ -524,6 +528,10 @@ group_meta = {
return
(
"Group[%s](%d points)"
):
format
(
tostring
(
g
.
list
),
#
g
.
list
)
end
,
__index
=
{
print
=
function
(
g
)
print
(
g
)
for
i
,
p
in
ipairs
(
g
.
list
)
do
print
(
" - "
..
p
.
x
..
" x "
..
p
.
y
)
end
end
,
updateReverse
=
function
(
g
)
g
.
reverse
=
{}
for
j
=
1
,
#
g
.
list
do
...
...
@@ -800,7 +808,7 @@ function _M:eliminateByFloodfill(walls)
if
g
and
#
g
.
list
>
0
then
print
(
"[Tilemap] Ok floodfill with main group size"
,
#
g
.
list
)
self
:
eliminateGroups
(
walls
[
1
],
groups
)
return
#
g
.
list
return
#
g
.
list
,
g
else
print
(
"[Tilemap] Floodfill left nothing"
)
return
0
...
...
@@ -948,9 +956,10 @@ function _M:groupOuterRectangle(group)
end
--- Carve out a simple linear path from coords until a tile is reached
function
_M
:
carveLinearPath
(
char
,
from
,
dir
,
stop_at
,
dig_only_into
)
function
_M
:
carveLinearPath
(
char
,
from
,
dir
,
stop_at
,
dig_only_into
,
ignore_first
)
local
x
,
y
=
math.floor
(
from
.
x
),
math.floor
(
from
.
y
)
local
dx
,
dy
=
util
.
dirToCoord
(
dir
)
if
ignore_first
then
x
,
y
=
x
+
dx
,
y
+
dy
end
if
type
(
dig_only_into
)
==
"table"
then
dig_only_into
=
table
.
reverse
(
dig_only_into
)
end
while
x
>=
1
and
x
<=
self
.
data_w
and
y
>=
1
and
y
<=
self
.
data_h
and
self
.
data
[
y
][
x
]
~=
stop_at
do
if
not
dig_only_into
or
(
type
(
dig_only_into
)
==
"table"
and
dig_only_into
[
self
.
data
[
y
][
x
]])
or
(
type
(
dig_only_into
)
==
"function"
and
dig_only_into
(
x
,
y
,
self
.
data
[
y
][
x
]))
then
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment