HTML and CSS Reference
In-Depth Information
Code
Explanation
}
Close clause
curwall = new
Wall(mx,my,mx+1,my+1,wallwidth,wallstyle);
Create new wall. It is small at this point.
inmotion = true;
Set inmotion to true
everything.push(curwall);
Add curwall to everything
drawall();
Draw everything
}
Close function
function stretchwall(ev) {
Function header stretchwall to that
uses the dragging of the mouse to
stretch out a wall while the mouse is
dragged.
Check if inmotion
if (inmotion) {
var mx;
Hold mouse x
var my;
Hold mouse y
if ( ev.layerX || ev.layerX == 0) {
Can we use layerX ?
mx= ev.layerX;
Set mx
my = ev.layerY;
Set my
} else if (ev.offsetX
|| ev.offsetX == 0) {
Else can we use offsetX ? This is
necessary for different browsers.
mx = ev.offsetX;
Set mx
my = ev.offsetY;
Set my
}
Close clause
Change curwall.fx to mx
curwall.fx = mx;
curwall.fy = my;
Change curwall.fy to my
Search WWH ::




Custom Search