Skip to content

Commit

Permalink
fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
increpare committed May 12, 2015
1 parent c1e1783 commit d3279ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions pinball.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,12 @@ function prevent(e) {
}


function setLevel(newCanvasIndex) {
function setLevel(newCanvasIndex,force) {
if ((newCanvasIndex-1)===canvasIndex){
if (!(force===true)){
return;
}
}

canvasIndex=newCanvasIndex-1;
masterCanvas=levelCanvasses[canvasIndex];
Expand Down Expand Up @@ -799,9 +804,12 @@ function press(evt){
} else if (evt.keyCode===90){//z
if (undoList.length>0){
var dat = undoList.pop();
masterCanvas=dat.canvasDat;
setLevel(dat.canvasIndex+1);
for(var i = 0; i < dat.canvasDat.length; i++){
masterCanvas[i] = dat.canvasDat[i];
}
compile();
setVisuals(true);
setVisuals(true,true);
if (shareLinkInner!=null){
shareLinkInner.style.color="gray";
}
Expand Down Expand Up @@ -1322,7 +1330,7 @@ function ballCollides(){
visibleContext.imageSmoothingEnabled= false;
id = visibleContext.createImageData(1,1); // only do this once per page
id_d=id.data;
setLevel(1);
setLevel(1,true);
setVisuals(true);

getData();
Expand Down Expand Up @@ -1581,6 +1589,8 @@ function ballCollides(){
console.log("preserving undo state");
var undoItem = new Object();
undoItem.canvasDat=uint8ar_copy(masterCanvas);
undoItem.canvasIndex=canvasIndex;

undoList.push(undoItem);
if (undoList.length>30){
undoList.shift();
Expand Down
Loading

0 comments on commit d3279ca

Please sign in to comment.