Unnamed Fossil Project

Check-in [183e7b325c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:moved the call to load until after the creation of the mazecanvas.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:183e7b325cf5eaf2ab3f4c13741365510b6f101a
User & Date: Derek 2013-02-24 15:57:52
Context
2013-02-24
21:55
variables for zoom in and out buttons. check-in: 29ee9c1008 user: Derek tags: trunk
15:57
moved the call to load until after the creation of the mazecanvas. check-in: 183e7b325c user: Derek tags: trunk
2013-02-22
19:12
automatically adjust pixel size to maze resolution. check-in: be90bb36df user: Derek tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to maze.html.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147

148
149
150
151
152
153
154
/*.menubutton:hover{border-style:outset;}*/
.menubutton:hover{border-color:#fff;}
.menubutton:active{border-style:solid;background-color:#888;border-color:#000}
</style><script>//<!--

//globals
var canvas,ctx,mazecanvas,menudiv,
arr=[],width=30,height=30,pxsize=2,
x,y,goalx,goaly,startx,starty,
dx=0,dy=0,
screenblocks=33,
dt=30,speed=12,turbofactor=1.75,pcolor="#2b2",
keys=[],mousedown=null,mouseloc=null,mousejoystickradius=80;edit=false,testonly=false,brush=1,victory=false,
savetime=10000,
helpmsg="Help Message goes here.";
................................................................................
{x:x,y:y,w:width,h:height,startx:startx,starty:starty,goalx:goalx,goaly:goaly,arr:arr});
localStorage.saved=true;}

function load(){
if(!localStorage.saved){return 0;}
var o=JSON.parse(localStorage.mazestate);
x=o.x;y=o.y;width=o.w;height=o.h;arr=o.arr;startx=o.startx;starty=o.starty;goalx=o.goalx;goaly=o.goaly;dx=0;dy=0;
pxsize=Math.max(Math.floor(1000/(width+height)),1);
return 1;}

function reset(w,h){
if(w&&h)width=w,height=h;
w=width,h=height;
pxsize=Math.max(Math.floor(1000/(w+h)),1);
goalx=w-1,goaly=h-1,startx=0,starty=0,
arr=new Array(w*h);
for(var i=0;i<w*h;++i)arr[i]=0;
x=0.5,y=0.5,dx=0,dy=0;
drawmaze();}

function drawmaze(){//mazecanvas
................................................................................
zi=_("+",0,function(){screenblocks*=0.8;});
zo=_("-",0,function(){screenblocks/=0.8;});
zi.className+=" bigtxt";zo.className+=" bigtxt";
}

// onload
window.onload=function(){
if(!load())reset(50,50);
canvas=crElem("canvas",document.body);
mazecanvas=crElem("canvas");
function resize(){canvas.width=window.innerWidth-2;canvas.height=window.innerHeight-2;}
window.onresize=resize;
resize();
ctx=canvas.getContext("2d");

drawmaze();

function changespeed(){
dx=0,dy=0;
var r=mousejoystickradius,tf=turbofactor;
if(!edit&&mousedown&&mouseloc||edit&&brush==4){// mouse joystick
dx+=tf*speed*Math.min(Math.max((mouseloc[0]-mousedown[0])/r, -1),1);







|







 







|





|







 







<






>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
134
135
136
137
138
139
140

141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*.menubutton:hover{border-style:outset;}*/
.menubutton:hover{border-color:#fff;}
.menubutton:active{border-style:solid;background-color:#888;border-color:#000}
</style><script>//<!--

//globals
var canvas,ctx,mazecanvas,menudiv,
arr=[],width=30,height=30,pxsize=2,maxpxdimsum=800,
x,y,goalx,goaly,startx,starty,
dx=0,dy=0,
screenblocks=33,
dt=30,speed=12,turbofactor=1.75,pcolor="#2b2",
keys=[],mousedown=null,mouseloc=null,mousejoystickradius=80;edit=false,testonly=false,brush=1,victory=false,
savetime=10000,
helpmsg="Help Message goes here.";
................................................................................
{x:x,y:y,w:width,h:height,startx:startx,starty:starty,goalx:goalx,goaly:goaly,arr:arr});
localStorage.saved=true;}

function load(){
if(!localStorage.saved){return 0;}
var o=JSON.parse(localStorage.mazestate);
x=o.x;y=o.y;width=o.w;height=o.h;arr=o.arr;startx=o.startx;starty=o.starty;goalx=o.goalx;goaly=o.goaly;dx=0;dy=0;
pxsize=Math.max(Math.floor(maxpxdimsum/(width+height)),1);
return 1;}

function reset(w,h){
if(w&&h)width=w,height=h;
w=width,h=height;
pxsize=Math.max(Math.floor(maxpxdimsum/(w+h)),1);
goalx=w-1,goaly=h-1,startx=0,starty=0,
arr=new Array(w*h);
for(var i=0;i<w*h;++i)arr[i]=0;
x=0.5,y=0.5,dx=0,dy=0;
drawmaze();}

function drawmaze(){//mazecanvas
................................................................................
zi=_("+",0,function(){screenblocks*=0.8;});
zo=_("-",0,function(){screenblocks/=0.8;});
zi.className+=" bigtxt";zo.className+=" bigtxt";
}

// onload
window.onload=function(){

canvas=crElem("canvas",document.body);
mazecanvas=crElem("canvas");
function resize(){canvas.width=window.innerWidth-2;canvas.height=window.innerHeight-2;}
window.onresize=resize;
resize();
ctx=canvas.getContext("2d");
if(!load())reset(50,50);
drawmaze();

function changespeed(){
dx=0,dy=0;
var r=mousejoystickradius,tf=turbofactor;
if(!edit&&mousedown&&mouseloc||edit&&brush==4){// mouse joystick
dx+=tf*speed*Math.min(Math.max((mouseloc[0]-mousedown[0])/r, -1),1);