Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
黛琳ghz
2048
提交
4b3055fc
2048
项目概览
黛琳ghz
/
2048
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
2048
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4b3055fc
编写于
3月 09, 2014
作者:
G
Gabriele Cirulli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add movement check, score addition
上级
f18f7cee
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
94 addition
and
6 deletion
+94
-6
js/game_manager.js
js/game_manager.js
+9
-1
js/html_actuator.js
js/html_actuator.js
+20
-5
style/main.css
style/main.css
+40
-0
style/main.scss
style/main.scss
+25
-0
未找到文件。
js/game_manager.js
浏览文件 @
4b3055fc
...
...
@@ -103,11 +103,15 @@ GameManager.prototype.move = function (direction) {
// Update the score
self
.
score
+=
merged
.
value
;
// Something's moved for sure
}
else
{
self
.
moveTile
(
tile
,
positions
.
farthest
);
}
moved
=
true
;
if
(
!
self
.
positionsEqual
(
cell
,
tile
))
{
moved
=
true
;
// The tile moved from its original cell!
}
}
});
});
...
...
@@ -201,3 +205,7 @@ GameManager.prototype.tileMatchesAvailable = function () {
return
false
;
};
GameManager
.
prototype
.
positionsEqual
=
function
(
first
,
second
)
{
return
first
.
x
===
second
.
x
&&
first
.
y
===
second
.
y
;
};
js/html_actuator.js
浏览文件 @
4b3055fc
...
...
@@ -2,13 +2,15 @@ function HTMLActuator() {
this
.
tileContainer
=
document
.
getElementsByClassName
(
"
tile-container
"
)[
0
];
this
.
gameContainer
=
document
.
getElementsByClassName
(
"
game-container
"
)[
0
];
this
.
scoreContainer
=
document
.
getElementsByClassName
(
"
score-container
"
)[
0
];
this
.
score
=
0
;
}
HTMLActuator
.
prototype
.
actuate
=
function
(
grid
,
metadata
)
{
var
self
=
this
;
window
.
requestAnimationFrame
(
function
()
{
self
.
clearContainer
();
self
.
clearContainer
(
self
.
tileContainer
);
grid
.
cells
.
forEach
(
function
(
column
)
{
column
.
forEach
(
function
(
cell
)
{
...
...
@@ -26,9 +28,9 @@ HTMLActuator.prototype.actuate = function (grid, metadata) {
});
};
HTMLActuator
.
prototype
.
clearContainer
=
function
()
{
while
(
this
.
tileC
ontainer
.
firstChild
)
{
this
.
tileContainer
.
removeChild
(
this
.
tileC
ontainer
.
firstChild
);
HTMLActuator
.
prototype
.
clearContainer
=
function
(
container
)
{
while
(
c
ontainer
.
firstChild
)
{
container
.
removeChild
(
c
ontainer
.
firstChild
);
}
};
...
...
@@ -69,7 +71,20 @@ HTMLActuator.prototype.positionClass = function (position) {
};
HTMLActuator
.
prototype
.
updateScore
=
function
(
score
)
{
this
.
scoreContainer
.
textContent
=
score
;
this
.
clearContainer
(
this
.
scoreContainer
);
var
difference
=
score
-
this
.
score
;
this
.
score
=
score
;
this
.
scoreContainer
.
textContent
=
this
.
score
;
if
(
difference
)
{
var
addition
=
document
.
createElement
(
"
div
"
);
addition
.
classList
.
add
(
"
score-addition
"
);
addition
.
textContent
=
"
+
"
+
difference
;
this
.
scoreContainer
.
appendChild
(
addition
);
}
};
HTMLActuator
.
prototype
.
gameOver
=
function
()
{
...
...
style/main.css
浏览文件 @
4b3055fc
...
...
@@ -22,6 +22,33 @@ h1.title {
display
:
block
;
float
:
left
;
}
@-webkit-keyframes
move-up
{
0
%
{
top
:
25px
;
opacity
:
1
;
}
100
%
{
top
:
-50px
;
opacity
:
0
;
}
}
@-moz-keyframes
move-up
{
0
%
{
top
:
25px
;
opacity
:
1
;
}
100
%
{
top
:
-50px
;
opacity
:
0
;
}
}
@keyframes
move-up
{
0
%
{
top
:
25px
;
opacity
:
1
;
}
100
%
{
top
:
-50px
;
opacity
:
0
;
}
}
.score-container
{
position
:
relative
;
float
:
right
;
...
...
@@ -45,6 +72,19 @@ h1.title {
line-height
:
13px
;
text-align
:
center
;
color
:
#eee4da
;
}
.score-container
.score-addition
{
position
:
absolute
;
right
:
30px
;
color
:
red
;
font-size
:
25px
;
line-height
:
25px
;
font-weight
:
bold
;
color
:
rgba
(
119
,
110
,
101
,
0.9
);
z-index
:
100
;
-webkit-animation
:
move-up
600ms
ease-in
;
-moz-animation
:
move-up
600ms
ease-in
;
-webkit-animation-fill-mode
:
both
;
-moz-animation-fill-mode
:
both
;
}
p
{
margin-top
:
0
;
...
...
style/main.scss
浏览文件 @
4b3055fc
...
...
@@ -46,6 +46,18 @@ h1.title {
float
:
left
;
}
@include
keyframes
(
move-up
)
{
0
%
{
top
:
25px
;
opacity
:
1
;
}
100
%
{
top
:
-50px
;
opacity
:
0
;
}
}
.score-container
{
$height
:
25px
;
...
...
@@ -73,6 +85,19 @@ h1.title {
text-align
:
center
;
color
:
$tile-color
;
}
.score-addition
{
position
:
absolute
;
right
:
30px
;
color
:
red
;
font-size
:
$height
;
line-height
:
$height
;
font-weight
:
bold
;
color
:
rgba
(
$text-color
,
.9
);
z-index
:
100
;
@include
animation
(
move-up
600ms
ease-in
);
@include
animation-fill-mode
(
both
);
}
}
p
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录