Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <canvas id="gameCanvas" width="1350" height="640"></canvas>
- <script>
- var counter = 0
- function count() {
- console.log(counter);
- counter ++
- }
- window.onload = function() {
- canvas = document.getElementById('gameCanvas');
- canvasContext = canvas.getContext('2d');
- var framesPerSecond = 30 //how many numbers are added per second
- setInterval(function() {
- drawCounter();
- count();
- }, 1000/framesPerSecond);
- }
- function drawCounter() {
- drawRect(0,0, 750,750, 'white');
- canvasContext.font="40px Arial";
- canvasContext.fillStyle = 'blue';
- canvasContext.fillText("Counter :", 50,50);
- canvasContext.fillText(counter, 230,50);
- }
- function drawRect(leftX, topY, width, height, drawColor) {
- canvasContext.fillStyle = drawColor;
- canvasContext.fillRect(leftX, topY, width, height);
- }
- </script>
- <html>
Advertisement
Add Comment
Please, Sign In to add comment