Score
This commit is contained in:
commit
8ece1c2775
2 changed files with 9 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
|||
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto">
|
||||
<style>
|
||||
body {
|
||||
color: white;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
@ -13,8 +14,10 @@
|
|||
</head>
|
||||
<body style="background-color:#2c3e50">
|
||||
<center>
|
||||
<div id="score">0</div>
|
||||
<canvas id="canvas" width = '700' height = '700' style='background-color:#2c3e50; margin-top: calc( 50% - 350px ) ; '></canvas>
|
||||
<div style='z-index:2;position:absolute;left:50%;margin-left:-70px;top:0px;'><h1 style='color:#ecf0f1;font-size:50px;'>Hextris</h1></div>
|
||||
<canvas id="canvas" width = '700' height = '700' style='background-color:#2c3e50; position:absolute; margin-top:70px;left:50%;margin-left:-350px;'></canvas>
|
||||
<div style="height:725px; width: 700px;"></div>
|
||||
<div style="z-index:2; position:absolute;" id="score">0 (x1)</div>
|
||||
</center>
|
||||
<script src="math.js"></script>
|
||||
<script src="entities.js"></script>
|
||||
|
|
7
main.js
7
main.js
|
@ -37,11 +37,12 @@ function render() {
|
|||
if(now - lastGen > nextGen) {
|
||||
blocks.push(new Block(randInt(0, 6), colors[randInt(0, colors.length)]));
|
||||
lastGen = Date.now();
|
||||
nextGen = randInt(500, 1500);
|
||||
nextGen = randInt(500/iter, 1500/iter);
|
||||
}
|
||||
if(now - prevScore > 1000) {
|
||||
score += 5 * scoreScalar;
|
||||
prevScore = now;
|
||||
iter += 0.1;
|
||||
}
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
drawPolygon(canvas.width / 2, canvas.height / 2, 6, canvas.width / 2, 30, hexagonBackgroundColor);
|
||||
|
@ -79,7 +80,7 @@ function render() {
|
|||
checkGameOver();
|
||||
}
|
||||
else if (gameState == 2) {
|
||||
showModal('Game Over');
|
||||
showModal('Game Over ' + score + ' pts');
|
||||
}
|
||||
})();
|
||||
|
||||
|
@ -103,7 +104,7 @@ function drawPolygon(x, y, sides, radius, theta, color) { // can make more elega
|
|||
|
||||
function checkGameOver() { // fix font, fix size of hex
|
||||
for(var i=0; i<MainClock.sides;i++) {
|
||||
if(MainClock.blocks[i].length>5)
|
||||
if(MainClock.blocks[i].length>8)
|
||||
{
|
||||
gameState = 2;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue