Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game2048
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王剑峰
game2048
Commits
b171662d
Commit
b171662d
authored
Apr 24, 2020
by
huangwenjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
bdd543d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
PlayScene.ts
src/scenes/playScene/PlayScene.ts
+6
-6
No files found.
src/scenes/playScene/PlayScene.ts
View file @
b171662d
...
...
@@ -919,7 +919,7 @@ export class PlayScene extends Scene {
// 随机生成基础元素
generateOneElement
()
{
// 随机生成一个数字 2or4
let
randNumber
=
Math
.
random
()
<
0.9
?
2
:
4
let
randNumber
=
Math
.
random
()
<
0.9
?
2
:
2048
// 随机生成位置
let
randNumberX
=
Math
.
floor
(
Math
.
random
()
*
4
)
let
randNumberY
=
Math
.
floor
(
Math
.
random
()
*
4
)
...
...
@@ -1270,7 +1270,7 @@ export class PlayScene extends Scene {
beforeArr
[
x
][
y
]
=
beforeArr
[
xb
][
y
]
beforeArr
[
xb
][
y
]
=
0
}
else
if
(
beforeArr
[
xb
][
y
]
===
beforeArr
[
x
][
y
]
&&
noBlockBottom
(
x
,
xb
,
y
,
beforeArr
))
{
}
else
if
(
beforeArr
[
xb
][
y
]
===
beforeArr
[
x
][
y
]
&&
noBlockBottom
(
x
,
xb
,
y
,
beforeArr
)
&&
beforeArr
[
x
][
y
]
<
2048
)
{
this
.
containerPool
[
xb
][
y
].
children
[
0
].
visible
=
false
let
origin
=
new
GameEle
(
beforeArr
[
xb
][
y
])
this
.
addChild
(
origin
)
...
...
@@ -1317,7 +1317,7 @@ export class PlayScene extends Scene {
beforeArr
[
x
][
y
]
=
beforeArr
[
x
][
yr
]
beforeArr
[
x
][
yr
]
=
0
}
else
if
(
beforeArr
[
x
][
yr
]
===
beforeArr
[
x
][
y
]
&&
noBlockRight
(
x
,
y
,
yr
,
beforeArr
))
{
}
else
if
(
beforeArr
[
x
][
yr
]
===
beforeArr
[
x
][
y
]
&&
noBlockRight
(
x
,
y
,
yr
,
beforeArr
)
&&
beforeArr
[
x
][
y
]
<
2048
)
{
this
.
containerPool
[
x
][
yr
].
children
[
0
].
visible
=
false
let
origin
=
new
GameEle
(
beforeArr
[
x
][
yr
])
this
.
addChild
(
origin
)
...
...
@@ -1364,7 +1364,7 @@ export class PlayScene extends Scene {
beforeArr
[
x
][
y
]
=
beforeArr
[
xt
][
y
]
beforeArr
[
xt
][
y
]
=
0
}
else
if
(
beforeArr
[
xt
][
y
]
===
beforeArr
[
x
][
y
]
&&
noBlockTop
(
x
,
xt
,
y
,
beforeArr
))
{
}
else
if
(
beforeArr
[
xt
][
y
]
===
beforeArr
[
x
][
y
]
&&
noBlockTop
(
x
,
xt
,
y
,
beforeArr
)
&&
beforeArr
[
x
][
y
]
<
2048
)
{
this
.
containerPool
[
xt
][
y
].
children
[
0
].
visible
=
false
let
origin
=
new
GameEle
(
beforeArr
[
xt
][
y
])
this
.
addChild
(
origin
)
...
...
@@ -1411,7 +1411,7 @@ export class PlayScene extends Scene {
beforeArr
[
x
][
y
]
=
beforeArr
[
x
][
yl
]
beforeArr
[
x
][
yl
]
=
0
}
else
if
(
beforeArr
[
x
][
yl
]
===
beforeArr
[
x
][
y
]
&&
noBlockLeft
(
x
,
y
,
yl
,
beforeArr
))
{
}
else
if
(
beforeArr
[
x
][
yl
]
===
beforeArr
[
x
][
y
]
&&
noBlockLeft
(
x
,
y
,
yl
,
beforeArr
)
&&
beforeArr
[
x
][
y
]
<
2048
)
{
this
.
containerPool
[
x
][
yl
].
children
[
0
].
visible
=
false
let
origin
=
new
GameEle
(
beforeArr
[
x
][
yl
])
this
.
addChild
(
origin
)
...
...
@@ -1449,7 +1449,7 @@ export class PlayScene extends Scene {
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
===
0
)
{
hasZero
=
true
}
else
if
(
arr
[
i
]
!==
0
&&
hasZero
||
arr
[
i
]
===
arr
[
i
+
1
]
)
{
}
else
if
(
arr
[
i
]
!==
0
&&
hasZero
||
(
arr
[
i
]
===
arr
[
i
+
1
]
&&
arr
[
i
]
<
2048
)
)
{
return
true
}
else
{
continue
...
...
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