playerScore and aiScore are variables which are incremented in case of goal(i made some kind of football game).In console everything seems fine I can see incremented values of my variables but I can't see them on HTML page.
HTML :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pong</title>
<style>
body{
margin:0;
padding:0;
display:flex;
align-items:center;
justify-content:center;
height:100vh;
background-color:darkgray;
}
canvas{
border: 3px solid #fff;
}
</style>
</head>
<body>
<canvas id="cnv"></canvas>
<script src="pong.js"></script>
</body>
</html>
Needed JS:
function score(){
var text = document.getElementById("cnv").innerHTML = playerScore + ":" + aiScore;
ctx.font = '30px Arial';
ctx.fillStyle = 'red';
ctx.textAlign = 'center';
ctx.fillText(text,cw/2,ch/2);
}
Aucun commentaire:
Enregistrer un commentaire