From af8190aea9296ae82fbb08ebf01a15ce45faa8d1 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 21 Oct 2016 15:44:11 -0600 Subject: Some cleanup; fixed the player position. --- js/lost.js | 67 +++++++++++++------------------------------------------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/js/lost.js b/js/lost.js index 43a0b13..a9d9556 100644 --- a/js/lost.js +++ b/js/lost.js @@ -698,37 +698,21 @@ function RenderCanvas2D( rMap, eParent ) this.btnBox.appendChild( cardTbl ); - let names = []; -// names[6] = 'In (<)'; -// names[7] = 'Out (>)'; - cardTbl = document.createElement('table'); for( let j = 3; j < this.rMap.getDims(); j++ ) { cardRow = document.createElement('tr'); cardTbl.appendChild( cardRow ); - let label; - - if( typeof names[j*2] === 'undefined' ) - label = (j+1) + '-'; - else - label = names[j*2]; - cardTd = document.createElement('td'); this.aMoveButtons[j*2] = cardTd.appendChild( - createMoveButton( this.rMap, j, -1, label ) + createMoveButton( this.rMap, j, -1, (j+1) + '-' ) ); cardRow.appendChild( cardTd ); - if( typeof names[j*2+1] === 'undefined' ) - label = (j+1) + '+'; - else - label = names[j*2+1]; - cardTd = document.createElement('td'); this.aMoveButtons[j*2+1] = cardTd.appendChild( - createMoveButton( this.rMap, j, 1, label ) + createMoveButton( this.rMap, j, 1, (j+1) + '+' ) ); cardRow.appendChild( cardTd ); } @@ -752,6 +736,10 @@ RenderCanvas2D.prototype.render = function render() else p = this.rMap.pPlayer.copy(); + let iPlayerIcon = + Math.floor(this.iIconSquare*0.5) + + Math.floor(this.iIconSquare*0.5) * this.iIconSquare; + for( let x = 0; x < this.rMap.getSize( 0 ); x++ ) { for( let y = 0; y < this.rMap.getSize( 1 ); y++ ) @@ -793,11 +781,16 @@ RenderCanvas2D.prototype.render = function render() let iIcon = 0; for( let ed = 2; ed < this.rMap.getDims(); ed++ ) { + if( iIcon == iPlayerIcon ) + iIcon++; if( (c.iWalls&(1<<(ed*2))) !== 0 ) { this.renderDirIcon( x, y, iIcon, ed*2 ); } iIcon++; + + if( iIcon == iPlayerIcon ) + iIcon++; if( (c.iWalls&(1<<(ed*2+1))) !== 0 ) { this.renderDirIcon( x, y, iIcon, ed*2+1 ); @@ -812,9 +805,9 @@ RenderCanvas2D.prototype.render = function render() if( this.rMap.pPlayer !== null ) { let bx = this.rMap.pPlayer.get(0)*iSize + - this.iBorder + (this.iIconSquare-1)*(this.iBorder+this.iIconSize); + this.iBorder + Math.floor(iPlayerIcon%this.iIconSquare)*(this.iBorder+this.iIconSize); let by = this.rMap.pPlayer.get(1)*iSize + - this.iBorder + (this.iIconSquare-1)*(this.iBorder+this.iIconSize); + this.iBorder + Math.floor(iPlayerIcon/this.iIconSquare)*(this.iBorder+this.iIconSize); this.rMap.pPlayer.equals( p ); this.ctx.beginPath(); this.ctx.ellipse( @@ -872,39 +865,7 @@ RenderCanvas2D.prototype.renderDirIcon = function renderDirIcon( by ); break; -/* - case 6: - // In - this.ctx.moveTo( - bx+this.iIconSize, - by - ); - this.ctx.lineTo( - bx, - by+this.iIconSize/2 - ); - this.ctx.lineTo( - bx+this.iIconSize, - by+this.iIconSize - ); - break; - - case 7: - // Out - this.ctx.moveTo( - bx, - by - ); - this.ctx.lineTo( - bx+this.iIconSize, - by+this.iIconSize/2 - ); - this.ctx.lineTo( - bx, - by+this.iIconSize - ); - break; -*/ + default: let label = Math.floor((iDir/2.0)+1).toString() + -- cgit v1.2.3