Unnamed Fossil Project

Check-in [65b5d28601]
Login

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

Overview
Comment:colored buttons :) !!!!
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:65b5d2860141a182027faf33a47b58b6d9dc0762
User & Date: Derek 2013-02-22 07:14:36
Context
2013-02-22
07:27
big zoom icons!!! check-in: 3d360b98f1 user: Derek tags: trunk
07:14
colored buttons :) !!!! check-in: 65b5d28601 user: Derek tags: trunk
06:05
redid the draw function and some other stuff. check-in: 19858e93d4 user: Derek tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to maze.html.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
107
108
109
110
111
112
113
114
115
116

117
118
119
120
121

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<html><head>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,maximum-scale=1">
<style>
canvas{margin:0px;}
body{overflow:hidden;margin:0px;}
.menudiv{position:absolute;left:20px;top:0px;height:99%;background-color:#ed9;background-color:rgba(230,220,170,0.60);padding:2px 8px 2px 8px;border-style:solid;border-width:1px;border-color:#000;}
.menubutton{border-style:ridged;border-width:2px;height:10%;border-color:#fa0;background-color:#fd8;
font-weight:bold;width:100%;padding:5px 8px 4px 8px;margin:4px 0px 4px 0px;}
/*.menubutton:hover{border-color:#c80;background-color:#ec7;}*/
/*.menubutton:hover{border-style:outset;}*/
.menubutton:hover{background-color:#feb;}
.menubutton:active{border-style:solid;background-color:#ec7;border-color:#fff}
</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,
................................................................................
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(){
var w=width,h=height,pxs=pxsize,scrx,scry,
cw=canvas.width,ch=canvas.height,/*cs=Math.min(cw,ch),cx=(cw-cs)*0.5,cy=(ch-cs)*0.5,cw2=cw*0.5,ch2=ch*0.5,*/
scrb=screenblocks,bs=Math.min(cw,ch)/scrb,ps=bs*0.9;//protagonist size
//o=convert(cx,cy);
ctx.fillStyle="#000";
ctx.fillRect(0,0,cw,ch);
ctx.drawImage(mazecanvas,0,0,pxs*w,pxs*h,Math.floor(cw/2-x*bs),Math.floor(ch/2-y*bs),w*bs,h*bs);

if(edit){//start,goal
................................................................................

function isblocked(x,y){
var w=width,h=height;
if(x<0||w<=x||y<0||h<=y) return true;
return arr[Math.floor(x)+w*Math.floor(y)];}

function loop(){
var f=dt*0.001,_dx=dx,_dy=dy
v=x+f*_dx,w=y+f*_dy;
if(!(edit&&brush==4)){//ignore walls
if(isblocked(v,y)) _dx=0;
if(isblocked(x,w)) _dy=0;
if(_dx&&_dy&&isblocked(v,w)) _dx=0,_dy=0;} //block diagonal
x+=f*_dx,y+=f*_dy;
if(!edit&&!victory&&Math.floor(x)==goalx&&Math.floor(y)==goaly){victory=true;alert(testonly?"Maze End.":"You Won");keys=[];}
draw();}

function convert(scrx,scry){ //convert screen coordinates
var cw=canvas.width,ch=canvas.height,cs=Math.min(cw,ch),sb=screenblocks,f=sb/cs;
return [x+f*(scrx-cw*0.5),y+f*(scry-ch*0.5)];}
................................................................................

function getElem(id){return document.getElementById(id);}

// make user menus
function makemenu(){
menudiv=crElem("div",document.body,"menudiv");

function addbutton(txt,f,id){
var b=crElem("input",menudiv,"menubutton",id);
b.type="button";b.value=txt;b.onclick=f;

crElem("br",menudiv);return b;}

var editbutton=null;
function playmode(){edit=false,editbutton.value="Edit";pcolor=testonly?"#fe4":"#2b2";}
function editmode(){edit=true,editbutton.value="Test";pcolor="#c32";victory=false;}


var _=addbutton;
_("Start", function(){x=startx+0.5,y=starty+0.5;victory=false;testonly=false;playmode();});
_("File",function(){});
editbutton=_("Edit",function(){edit?playmode():(editmode(),testonly=true);});
_("Reset",function(){reset(180,100);});
_("Help",function(){alert(helpmsg);});
_("+",function(){screenblocks*=0.8;});
_("-",function(){screenblocks/=0.8;});
}

// onload
window.onload=function(){
if(!load())reset(50,50);
canvas=crElem("canvas",document.body);
mazecanvas=crElem("canvas");





|
|
|


|
|







 







|







 







|
|

|
|
|







 







|
|

>


|
<
|
>


|
|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
107
108
109
110
111
112
113
114
115
116
117
118
119
120

121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<html><head>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,maximum-scale=1">
<style>
canvas{margin:0px;}
body{overflow:hidden;margin: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:#aaa;background-color:#eee;
font-weight:bold;width:100%;padding:0px 8px 0px 8px;margin:2.5% 0px 2.5% 0px;}
/*.menubutton:hover{border-color:#c80;background-color:#ec7;}*/
/*.menubutton:hover{border-style:outset;}*/
.menubutton:hover{border-color:#fff;border-style:solid;}
.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,
................................................................................
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(){
var w=width,h=height,pxs=pxsize,scrx,scry,
cw=canvas.width,ch=canvas.height,
scrb=screenblocks,bs=Math.min(cw,ch)/scrb,ps=bs*0.9;//protagonist size
//o=convert(cx,cy);
ctx.fillStyle="#000";
ctx.fillRect(0,0,cw,ch);
ctx.drawImage(mazecanvas,0,0,pxs*w,pxs*h,Math.floor(cw/2-x*bs),Math.floor(ch/2-y*bs),w*bs,h*bs);

if(edit){//start,goal
................................................................................

function isblocked(x,y){
var w=width,h=height;
if(x<0||w<=x||y<0||h<=y) return true;
return arr[Math.floor(x)+w*Math.floor(y)];}

function loop(){
var f=dt*0.001,_dx=dx,_dy=dy,
u=x+f*_dx,v=y+f*_dy;
if(!(edit&&brush==4)){//ignore walls
if(isblocked(u,y)) _dx=0;
if(isblocked(x,v)) _dy=0;
if(_dx&&_dy&&isblocked(u,v)) _dx=0,_dy=0;} //block diagonal
x+=f*_dx,y+=f*_dy;
if(!edit&&!victory&&Math.floor(x)==goalx&&Math.floor(y)==goaly){victory=true;alert(testonly?"Maze End.":"You Won");keys=[];}
draw();}

function convert(scrx,scry){ //convert screen coordinates
var cw=canvas.width,ch=canvas.height,cs=Math.min(cw,ch),sb=screenblocks,f=sb/cs;
return [x+f*(scrx-cw*0.5),y+f*(scry-ch*0.5)];}
................................................................................

function getElem(id){return document.getElementById(id);}

// make user menus
function makemenu(){
menudiv=crElem("div",document.body,"menudiv");

function addbutton(txt,c,f){
var b=crElem("input",menudiv,"menubutton");
b.type="button";b.value=txt;b.onclick=f;
if(c)b.style.backgroundColor=c;
crElem("br",menudiv);return b;}

var eb=null;//editbutton

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);});
_("+",0,function(){screenblocks*=0.8;});
_("-",0,function(){screenblocks/=0.8;});
}

// onload
window.onload=function(){
if(!load())reset(50,50);
canvas=crElem("canvas",document.body);
mazecanvas=crElem("canvas");