zlodiak,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
var Game = function(parentGameElementTag) {
this.parentGameElementTag = parentGameElementTag;
this.gameElementId = 'game';
this.level = 0;
this.init();
};
Game.prototype.init = function() {
$('<div class="game" id="' + this.gameElementId + '">Game</div>').appendTo(this.parentGameElementTag);
};
Game.prototype.gameOver = function() {
$('<div class="game" >Game over!!!</div>').appendTo(this.parentGameElementTag);
};
var Level = function() {
Game.apply(this, arguments);
this.fieldElementId = 'field';
this.levelScreenDisplay();
};
Level.prototype = Object.create(Game.prototype);
Level.prototype.constructor = Level;
Level.prototype.levelScreenDisplay = function() {
var self = this;
$('<div class="level_begin_label" id="levelBeginLabel">Уровень: ' + this.level + '</div>').appendTo(this.parentGameElementTag);
setTimeout(function() {
$('<div class="any_key_invitation" id="anyKeyInvitation">Нажмите любую клавишу для старта</div>').appendTo('#levelBeginLabel');
$(document).one('keypress', function() {
$('#levelBeginLabel').remove();
self.level++;
if (self.level == 3) self.gameOver();
else self.levelScreenDisplay();
});
}, 1000);
}
Level.prototype.levelScreenDisplay
var app = new Level('body');
</script>
</body>
</html>