diff options
author | Mike Buland <Mike.Buland@mjfirm.com> | 2016-10-21 15:44:11 -0600 |
---|---|---|
committer | Mike Buland <Mike.Buland@mjfirm.com> | 2016-10-21 15:44:11 -0600 |
commit | af8190aea9296ae82fbb08ebf01a15ce45faa8d1 (patch) | |
tree | 68e2c27873083fe9b3e1ecfe72c7d8fc842a19d4 | |
parent | 1545f1d23e2dd8956593c6294518c4f3dc5c2028 (diff) | |
download | lost-af8190aea9296ae82fbb08ebf01a15ce45faa8d1.tar.gz lost-af8190aea9296ae82fbb08ebf01a15ce45faa8d1.tar.bz2 lost-af8190aea9296ae82fbb08ebf01a15ce45faa8d1.tar.xz lost-af8190aea9296ae82fbb08ebf01a15ce45faa8d1.zip |
Some cleanup; fixed the player position.
-rw-r--r-- | js/lost.js | 67 |
1 files changed, 14 insertions, 53 deletions
@@ -698,37 +698,21 @@ function RenderCanvas2D( rMap, eParent ) | |||
698 | 698 | ||
699 | this.btnBox.appendChild( cardTbl ); | 699 | this.btnBox.appendChild( cardTbl ); |
700 | 700 | ||
701 | let names = []; | ||
702 | // names[6] = 'In (<)'; | ||
703 | // names[7] = 'Out (>)'; | ||
704 | |||
705 | cardTbl = document.createElement('table'); | 701 | cardTbl = document.createElement('table'); |
706 | for( let j = 3; j < this.rMap.getDims(); j++ ) | 702 | for( let j = 3; j < this.rMap.getDims(); j++ ) |
707 | { | 703 | { |
708 | cardRow = document.createElement('tr'); | 704 | cardRow = document.createElement('tr'); |
709 | cardTbl.appendChild( cardRow ); | 705 | cardTbl.appendChild( cardRow ); |
710 | 706 | ||
711 | let label; | ||
712 | |||
713 | if( typeof names[j*2] === 'undefined' ) | ||
714 | label = (j+1) + '-'; | ||
715 | else | ||
716 | label = names[j*2]; | ||
717 | |||
718 | cardTd = document.createElement('td'); | 707 | cardTd = document.createElement('td'); |
719 | this.aMoveButtons[j*2] = cardTd.appendChild( | 708 | this.aMoveButtons[j*2] = cardTd.appendChild( |
720 | createMoveButton( this.rMap, j, -1, label ) | 709 | createMoveButton( this.rMap, j, -1, (j+1) + '-' ) |
721 | ); | 710 | ); |
722 | cardRow.appendChild( cardTd ); | 711 | cardRow.appendChild( cardTd ); |
723 | 712 | ||
724 | if( typeof names[j*2+1] === 'undefined' ) | ||
725 | label = (j+1) + '+'; | ||
726 | else | ||
727 | label = names[j*2+1]; | ||
728 | |||
729 | cardTd = document.createElement('td'); | 713 | cardTd = document.createElement('td'); |
730 | this.aMoveButtons[j*2+1] = cardTd.appendChild( | 714 | this.aMoveButtons[j*2+1] = cardTd.appendChild( |
731 | createMoveButton( this.rMap, j, 1, label ) | 715 | createMoveButton( this.rMap, j, 1, (j+1) + '+' ) |
732 | ); | 716 | ); |
733 | cardRow.appendChild( cardTd ); | 717 | cardRow.appendChild( cardTd ); |
734 | } | 718 | } |
@@ -752,6 +736,10 @@ RenderCanvas2D.prototype.render = function render() | |||
752 | else | 736 | else |
753 | p = this.rMap.pPlayer.copy(); | 737 | p = this.rMap.pPlayer.copy(); |
754 | 738 | ||
739 | let iPlayerIcon = | ||
740 | Math.floor(this.iIconSquare*0.5) + | ||
741 | Math.floor(this.iIconSquare*0.5) * this.iIconSquare; | ||
742 | |||
755 | for( let x = 0; x < this.rMap.getSize( 0 ); x++ ) | 743 | for( let x = 0; x < this.rMap.getSize( 0 ); x++ ) |
756 | { | 744 | { |
757 | for( let y = 0; y < this.rMap.getSize( 1 ); y++ ) | 745 | for( let y = 0; y < this.rMap.getSize( 1 ); y++ ) |
@@ -793,11 +781,16 @@ RenderCanvas2D.prototype.render = function render() | |||
793 | let iIcon = 0; | 781 | let iIcon = 0; |
794 | for( let ed = 2; ed < this.rMap.getDims(); ed++ ) | 782 | for( let ed = 2; ed < this.rMap.getDims(); ed++ ) |
795 | { | 783 | { |
784 | if( iIcon == iPlayerIcon ) | ||
785 | iIcon++; | ||
796 | if( (c.iWalls&(1<<(ed*2))) !== 0 ) | 786 | if( (c.iWalls&(1<<(ed*2))) !== 0 ) |
797 | { | 787 | { |
798 | this.renderDirIcon( x, y, iIcon, ed*2 ); | 788 | this.renderDirIcon( x, y, iIcon, ed*2 ); |
799 | } | 789 | } |
800 | iIcon++; | 790 | iIcon++; |
791 | |||
792 | if( iIcon == iPlayerIcon ) | ||
793 | iIcon++; | ||
801 | if( (c.iWalls&(1<<(ed*2+1))) !== 0 ) | 794 | if( (c.iWalls&(1<<(ed*2+1))) !== 0 ) |
802 | { | 795 | { |
803 | this.renderDirIcon( x, y, iIcon, ed*2+1 ); | 796 | this.renderDirIcon( x, y, iIcon, ed*2+1 ); |
@@ -812,9 +805,9 @@ RenderCanvas2D.prototype.render = function render() | |||
812 | if( this.rMap.pPlayer !== null ) | 805 | if( this.rMap.pPlayer !== null ) |
813 | { | 806 | { |
814 | let bx = this.rMap.pPlayer.get(0)*iSize + | 807 | let bx = this.rMap.pPlayer.get(0)*iSize + |
815 | this.iBorder + (this.iIconSquare-1)*(this.iBorder+this.iIconSize); | 808 | this.iBorder + Math.floor(iPlayerIcon%this.iIconSquare)*(this.iBorder+this.iIconSize); |
816 | let by = this.rMap.pPlayer.get(1)*iSize + | 809 | let by = this.rMap.pPlayer.get(1)*iSize + |
817 | this.iBorder + (this.iIconSquare-1)*(this.iBorder+this.iIconSize); | 810 | this.iBorder + Math.floor(iPlayerIcon/this.iIconSquare)*(this.iBorder+this.iIconSize); |
818 | this.rMap.pPlayer.equals( p ); | 811 | this.rMap.pPlayer.equals( p ); |
819 | this.ctx.beginPath(); | 812 | this.ctx.beginPath(); |
820 | this.ctx.ellipse( | 813 | this.ctx.ellipse( |
@@ -872,39 +865,7 @@ RenderCanvas2D.prototype.renderDirIcon = function renderDirIcon( | |||
872 | by | 865 | by |
873 | ); | 866 | ); |
874 | break; | 867 | break; |
875 | /* | 868 | |
876 | case 6: | ||
877 | // In | ||
878 | this.ctx.moveTo( | ||
879 | bx+this.iIconSize, | ||
880 | by | ||
881 | ); | ||
882 | this.ctx.lineTo( | ||
883 | bx, | ||
884 | by+this.iIconSize/2 | ||
885 | ); | ||
886 | this.ctx.lineTo( | ||
887 | bx+this.iIconSize, | ||
888 | by+this.iIconSize | ||
889 | ); | ||
890 | break; | ||
891 | |||
892 | case 7: | ||
893 | // Out | ||
894 | this.ctx.moveTo( | ||
895 | bx, | ||
896 | by | ||
897 | ); | ||
898 | this.ctx.lineTo( | ||
899 | bx+this.iIconSize, | ||
900 | by+this.iIconSize/2 | ||
901 | ); | ||
902 | this.ctx.lineTo( | ||
903 | bx, | ||
904 | by+this.iIconSize | ||
905 | ); | ||
906 | break; | ||
907 | */ | ||
908 | default: | 869 | default: |
909 | let label = | 870 | let label = |
910 | Math.floor((iDir/2.0)+1).toString() + | 871 | Math.floor((iDir/2.0)+1).toString() + |