From 5c9cc8d82bac547f222281d405c5478212b6c161 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Thu, 8 Sep 2016 13:49:23 +1000 Subject: [PATCH] test code to check for font load --- cat.html | 19 ++++++++++++++++++- todo | 5 ----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cat.html b/cat.html index a2533da..78a60e9 100644 --- a/cat.html +++ b/cat.html @@ -1259,6 +1259,19 @@ var game = { return this.rng.rndrange(min, max); }, + isfontloaded : function() { + var tempctx = this.stargoalbanner.getContext("2d"); + var size; + tempctx.font = "50 pt " + FONT; + size = tempctx.measureText("wwwww").width; + console.log(size); + + if (size >= 36) { + return true; + } + return false; + }, + addfireworks : function() { var delay = 0; for (i = 0; i < FIREWORKCOUNT; i++) { @@ -1343,6 +1356,7 @@ var game = { //this.canvas = document.createElement("canvas"); this.canvas = document.getElementsByTagName('canvas')[0]; this.stargoalbanner = document.createElement("canvas"); + this.temp = document.createElement("canvas"); this.hratio = SCREENH / SCREENW; this.wratio = SCREENW / SCREENH; @@ -7773,7 +7787,10 @@ function mainloop() { game.drawloader(); if (nimages >= maximages) { - game.setstate("title"); + // has font loaded? + if (game.isfontloaded()) { + game.setstate("title"); + } } } else if (game.state == "help") { game.clear(); diff --git a/todo b/todo index 6a15938..8153058 100644 --- a/todo +++ b/todo @@ -34,17 +34,12 @@ arrow/signpost - cat parades bounce off and take out htings in the path PLAYTEST: - ... adjust point goal calculation code now that we have multiplier. ... adjust # of turns per level - - foot/human/cat toy - adjacent cat pushes it, clear the horiz. line. - - show points for each element along path??