Answer the question
In order to leave comments, you need to log in
How to output some info to the canvas every time the function is executed?
The point is this. I am writing a game. I'm making a timer. And I need a tag that will display time in the canvas. Here is the script:
var gameField = document.getElementById("gameField");
var graphics = gameField.getContext("2d");
var m = 1;
var s = 31;
var a = 1;
var b = 31;
function timer() {
if ((s > 0) && (m >= 0)) {
s = b - 1;
b = s;
document.write(a + ':' + b);
}
if ((s = 0) && (m > 0)) {
s = 59;
m = a - 1;
a = m;
document.write(a + ':' + b);
}
if ((s = 0) && (m = 0)) {
alert ('Время закончилось');
}
}
setInterval(timer, 1000);
Answer the question
In order to leave comments, you need to log in
It's strange how you make a game if you can't even display the text. Can it be like this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question