added 'paused' indicator...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-04-20 23:46:09 +03:00
parent fea40858c7
commit 8d61d19bde
3 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,5 @@
CACHE MANIFEST
# Timestamp: 20170420232958
# Timestamp: 20170420234350
CACHE:
simplesnake.html

View File

@ -90,6 +90,21 @@ body {
background-color: red;
}
.simplesnake.stopped:before {
content: "Paused...";
position: absolute;
display: block;
width: 100%;
top: 50%;
margin-top: -10vmin;
font-size: 10vmin;
font-weight: bolder;
text-align: center;
color: rgba(0, 0, 0, 0.2);
z-index: 100;
}
/*
.simplesnake .apple {
position: relative;

View File

@ -287,6 +287,7 @@ var Snake = {
.snakeKilled(null)
},
start: function(t){
this._field.classList.remove('paused')
this.__timer = this.__timer
|| setInterval(this._tick.bind(this), t || this.config.interval || 200)
// reset player control actions...
@ -297,6 +298,7 @@ var Snake = {
return this
},
stop: function(){
this._field.classList.add('paused')
clearInterval(this.__timer)
delete this.__timer
delete this.__tick