Unnamed Fossil Project

Check-in [be90bb36df]
Login

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

Overview
Comment:automatically adjust pixel size to maze resolution.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:be90bb36dfb3d148621fbb0bdacb1275cbdffa81
User & Date: Derek 2013-02-22 19:12:39
Context
2013-02-24
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
07:43
more style changes. check-in: b554e251ed user: Derek tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to maze.html.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
30
31
32
33
34
35
36

37
38
39
40


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,maximum-scale=1">
<style>
canvas{margin:0px;padding:0px;}
body{overflow:hidden;margin:0px;padding:0px;}
.menudiv{position:absolute;left:20px;top:0px;height:99%;background-color:#ed9;background-color:rgba(80,80,80,0.75);padding:2px 8px 2px 8px;border-style:solid;border-width:1px;border-color:#000;}
.menubutton{border-style:ridged;border-width:2px;height:12%;max-height:85px;border-color:#444;border-style:solid;background-color:#eee;
font-weight:bold;width:100%;padding:0px 8px 0px 8px;margin:2.5% 0px 2.5% 0px;}
.bigtxt{font-size:180%;}
/*.menubutton:hover{border-color:#c80;background-color:#ec7;}*/
/*.menubutton:hover{border-style:outset;}*/
.menubutton:hover{border-color:#fff;}
.menubutton:active{border-style:solid;background-color:#888;border-color:#000}
</style><script>//<!--

//globals
................................................................................
{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;

return 1;}

function reset(w,h){
if(w&&h)width=w,height=h;


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,y=0,dx=0,dy=0;
drawmaze();}

function drawmaze(){//mazecanvas
var w=width,h=height,l=w*h,pxs=pxsize;
mazecanvas.width=pxs*w*2;mazecanvas.height=pxs*h*2;
var mctx=mazecanvas.getContext("2d");
mctx.fillStyle="#fff";mctx.fillRect(0,0,pxs*w,pxs*h);mctx.fillStyle="#000";
for(var _y=0;_y<h;++_y){for(var _x=0;_x<w;++_x){
var i=_x+_y*w;
if(arr[i])mctx.fillRect(pxs*_x,pxs*_y,pxs,pxs);}}}

function draw(){
................................................................................
function playmode(){edit=false,eb.value="Edit";eb.style.backgroundColor="#fb6";pcolor=testonly?"#fe4":"#2b2";}
function editmode(){edit=true,eb.value="Test";eb.style.backgroundColor="#fea";pcolor="#f82";victory=false;}

var _=addbutton;
_("Start","#cfc",function(){x=startx+0.5,y=starty+0.5;victory=false;testonly=false;playmode();});
_("File","#cbf",function(){});
eb=_("Edit","#fb6",function(){edit?playmode():(editmode(),testonly=true);});
//_("Reset","#faa",function(){reset(180,100);});
_("Help","#acf",function(){alert(helpmsg);});
zi=_("+",0,function(){screenblocks*=0.8;});
zo=_("-",0,function(){screenblocks/=0.8;});
zi.className+=" bigtxt";zo.className+=" bigtxt";
}

// onload







|







 







>




>
>



|




|







 







|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,maximum-scale=1">
<style>
canvas{margin:0px;padding:0px;}
body{overflow:hidden;margin:0px;padding:0px;}
.menudiv{position:absolute;left:20px;top:0px;height:99%;background-color:#ed9;background-color:rgba(80,80,80,0.75);padding:2px 8px 2px 8px;border-style:solid;border-width:1px;border-color:#000;}
.menubutton{border-style:ridged;border-width:2px;height:12%;max-height:85px;border-color:#444;border-style:solid;background-color:#eee;
font-weight:bold;width:100%;padding:0px 8px 0px 8px;margin:2.5% 0px 2.5% 0px;}
.bigtxt{font-size:125%;}
/*.menubutton:hover{border-color:#c80;background-color:#ec7;}*/
/*.menubutton:hover{border-style:outset;}*/
.menubutton:hover{border-color:#fff;}
.menubutton:active{border-style:solid;background-color:#888;border-color:#000}
</style><script>//<!--

//globals
................................................................................
{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
var w=width,h=height,l=w*h,pxs=pxsize;
if(!mazecanvas)return;mazecanvas.width=pxs*w*2;mazecanvas.height=pxs*h*2;
var mctx=mazecanvas.getContext("2d");
mctx.fillStyle="#fff";mctx.fillRect(0,0,pxs*w,pxs*h);mctx.fillStyle="#000";
for(var _y=0;_y<h;++_y){for(var _x=0;_x<w;++_x){
var i=_x+_y*w;
if(arr[i])mctx.fillRect(pxs*_x,pxs*_y,pxs,pxs);}}}

function draw(){
................................................................................
function playmode(){edit=false,eb.value="Edit";eb.style.backgroundColor="#fb6";pcolor=testonly?"#fe4":"#2b2";}
function editmode(){edit=true,eb.value="Test";eb.style.backgroundColor="#fea";pcolor="#f82";victory=false;}

var _=addbutton;
_("Start","#cfc",function(){x=startx+0.5,y=starty+0.5;victory=false;testonly=false;playmode();});
_("File","#cbf",function(){});
eb=_("Edit","#fb6",function(){edit?playmode():(editmode(),testonly=true);});
_("Reset","#faa",function(){reset(200,100);});
_("Help","#acf",function(){alert(helpmsg);});
zi=_("+",0,function(){screenblocks*=0.8;});
zo=_("-",0,function(){screenblocks/=0.8;});
zi.className+=" bigtxt";zo.className+=" bigtxt";
}

// onload