Initial loading screen now works. (but is ugly)

This commit is contained in:
Rob Pearce 2016-08-27 12:35:18 +10:00
parent b4e6114875
commit bd6b39a085
2 changed files with 27 additions and 24 deletions

View File

@ -258,8 +258,11 @@ var llamatext = "llama";
var image = new Array(); var image = new Array();
var winimg = null; var winimg = null;
var nfonts = 0;
var nimages = 0; var nimages = 0;
var maximages = 0; var maximages = 0;
var maxfonts = 0;
function loadimage(name, filename) { function loadimage(name, filename) {
image[name] = new Image(); image[name] = new Image();
@ -576,18 +579,6 @@ function getdir(thing1, thing2) {
} }
function startGame() { function startGame() {
var i;
imagenames = ['cat', 'catfull', 'catscared', 'llama', 'cheese', 'title',
'goat','door','sunlight','lock','catwalkl','catwalkr','starfull','starempty' ];
nimages = 0;
maximages = 0;
for (i in imagenames) {
maximages++;
loadimage(imagenames[i], 'images/' + imagenames[i] + '.png');
}
game.init(); game.init();
game.initlevels(); game.initlevels();
@ -987,12 +978,14 @@ var game = {
}, },
incloadprogress : function() { incloadprogress : function() {
setTimeout(function () {
nimages++; nimages++;
console.log(nimages + " / " + maximages + " images loaded."); console.log(nimages + " / " + maximages + " images loaded.");
}, (rnd(3)+1) * 1000);
}, },
drawloader : function() { drawloader : function() {
var bgcol = "#00ccff"; var bgcol = "#008c8c";
var pct = nimages / maximages; var pct = nimages / maximages;
ctx.fillStyle = bgcol; ctx.fillStyle = bgcol;
@ -3381,9 +3374,14 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
}, },
setstate : function(newstate) { setstate : function(newstate) {
console.log("setstate() = " + newstate);
if (newstate != this.state) { if (newstate != this.state) {
this.dirty = true; this.dirty = true;
} }
if (newstate == "help") { if (newstate == "help") {
// decide which word to use // decide which word to use
if (onein(2)) { if (onein(2)) {
@ -3438,11 +3436,21 @@ console.log("lev " + lev + " newwid " + newwid + " ratio " + ratio);
// start fade in // start fade in
wipe.start("", "in", 15); wipe.start("", "in", 15);
} else if (newstate == "loader") { } else if (newstate == "loader") {
// start loading images
var i;
imagenames = ['cat', 'catfull', 'catscared', 'llama', 'cheese', 'title',
'goat','door','sunlight','lock','catwalkl','catwalkr','starfull','starempty' ];
nfonts = 0;
maxfonts = 0;
nimages = 0;
maximages = 0;
for (i in imagenames) {
maximages++;
loadimage(imagenames[i], 'images/' + imagenames[i] + '.png');
}
} }
console.log("setstate() = " + newstate);
this.state = newstate; this.state = newstate;
}, },

7
todo
View File

@ -8,15 +8,10 @@ https://www.smashingmagazine.com/2012/10/design-your-own-mobile-game/
---------- ----------
*game is correct size on phone but HUGE in browsers!
* scale to highest dimension.
loading screen
white outline ? white outline ?
foot - cats push it, clear the horiz. line. foot/human - cats push it, clear the horiz. line.
powerups powerups
get by... doors ? get by... doors ?