Browse Source

fixed missing files

Bernardo Martins 5 years ago
parent
commit
b0084e6658
7 changed files with 138 additions and 26 deletions
  1. 0 0
      css/iHanoiStyle.css
  2. 104 0
      iHanoi.html
  3. BIN
      imgs/wood1.jpeg
  4. 11 25
      js/iHanoiFunctions.js
  5. 1 1
      js/integration-functions.js
  6. 0 0
      js/jquery-3.3.1.min.js
  7. 22 0
      js/start.js

+ 0 - 0
css/iHanoiStyle.css


+ 104 - 0
iHanoi.html

@@ -0,0 +1,104 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<html>
+	<head>
+		<title> Torre de Hanoi </title>
+		<Style>
+			#planoDeFundo {
+				background :transparent;
+				width: 90%; 
+				height: 75%;
+				position: absolute;
+			}
+			#restart_button{
+				position:absolute;
+				border:1px solid gray;
+				border-radius: 7%;
+				font-size: 0.875;
+				word-wrap: break-word;
+				max-width: 7%;
+				left: 21%;
+				top: 5%;
+			}
+			#A_button{
+				position:absolute;
+				border:1px solid gray;
+				border-radius: 7%;
+				font-size: 1;
+				height: 4.5%;
+				width: 20%;
+				left: 5.4%;
+				top: 77%;
+			}
+			#B_button{
+				position:absolute;
+				border:1px solid gray;
+				border-radius: 7%;
+				font-size: 1;
+				height: 5%;
+				word-wrap: break-word;
+				width: 20%;
+				left: 35.5%;
+				top: 77%;
+			}
+			#C_button{
+				position:absolute;
+				border:1px solid gray;
+				border-radius: 7%;
+				font-size: 1;
+				height: 5%;
+				width: 20%;
+				left: 66%;
+				top: 77%;
+			}
+
+			#Undo_button{
+				position:absolute;
+				border:1px solid gray;
+				border-radius: 7%;
+				font-size: 1;
+				height:5%;
+				width: 20%;
+				left: 20%;
+				top: 83%;
+			}
+			#Redo_button{
+				position:absolute;
+				border:1px solid gray;
+				border-radius: 7%;
+				font-size: 1;
+				height: 5%;
+				word-wrap: break-word;
+				width: 20%;
+				left: 51%;
+				top: 83%;
+			}
+		</Style>
+		<script src="js/jquery-3.3.1.min.js"></script>
+		<script src="js/integration-functions.js"></script>
+	</head>
+	<body>
+	<div class="task"  style="display:none">
+		<button id="A_button" onclick="buttonClick(0)">A</button>
+		<button id="B_button" onclick="buttonClick(1)">B</button>
+		<button id="C_button" onclick="buttonClick(2)">C</button>
+		<button id="Undo_button" onclick="undo()">Undo</button>
+		<button id="Redo_button" onclick="redo()">Redo</button>
+		<canvas id="planoDeFundo"  width="1024" height="615">
+		Seu navegador não suporta o recurso Canvas. Atualize-o para utilizar esse recurso
+		</canvas>
+		<script src= "js/start.js"></script>
+		<script src="js/iHanoiFunctions.js"></script>
+	</div>
+	<div class="creation" style="display:none">
+		Quantidade de discos no desafio: 
+		<select name="Discos" class="cDiscos">
+			<option>2</option>
+			<option>3</option>
+			<option>4</option>
+			<option>5</option>
+			<option>6</option>
+		</select>
+	</div>
+  </body>
+</html>

BIN
imgs/wood1.jpeg


+ 11 - 25
js/iHanoiFunctions.js

@@ -1,28 +1,15 @@
-var canvas = document.getElementById('planoDeFundo');
-var context = canvas.getContext('2d');
-var towerA = [], towerB = [], towerC = [];
-var toMove = null;
-var idF=" ", idT= " ";
-var nMovements = 0, nTotalMovements = 0, nWrongMoves = 0, nDisks;
-var moves = [], totalMoves = []; //vector to save movements
-var acertou=0;
-var optimalSolution;
-		 	//NavyBlue  Lime     Fuchsia   yellow   Orange   LightSteelBlue  red
-var colors = ["#000080","#00FF00", "#FF00FF", "yellow", "#FFA500", "#B0C4DE","red"];
-var start = Date.now(), startOfMove, totalTime, moveTime; //timing vars
-
 function inicio (QntityDisks){
 	nDisks=QntityDisks;
 	optimalSolution= Math.pow(2,QntityDisks)-1;
 	var x = 0;
-	var y = 558;
+	var y = 549.5;
 	var w = 330;
 	startOfMove=Date.now();
 	for (var i = 0; i < QntityDisks; i++) {
 		var disk = new Disk(x,y,w,40,colors[i]);
 		towerA.push(disk);
 		x+=20;  //moves to the right
-		y-=42; //moves up, +1 to separate disks
+		y-=41; //moves up, +1 to separate disks
 		w-=40; //reduces disk width
 	}
 	drawScene();
@@ -59,24 +46,24 @@ function reinicio (){
 }
 function drawTowers (){
 	context.beginPath();
+	context.fillStyle = pat;
 	<!-- torre 1 -->
-	context.fillStyle = 'black';
-	context.fillRect(160, 260, 10, 340);//x, y, largura, altura
-    
+    roundRect(context, 160, 260, 20, 340, 5, pat, false);//ctx, x, y, largura, altura, radius, fill, stroke(T/F)
+
     <!--Base t1-->
-	context.fillRect(0, 600, 330, 15);
+	roundRect(context, 0, 590, 330, 20, 5, pat, false);
 
 	<!-- torre 2 -->
-	context.fillRect(505, 260 ,10, 340);
+	roundRect(context, 505, 260, 20, 340, 5, pat, false);
 
     <!--Base t2-->
-	context.fillRect(345, 600, 330, 15);
+	roundRect(context, 345, 590, 330, 20, 5, pat, false);
 
 	<!-- torre 3 -->
-	context.fillRect(850, 260, 10, 340);
+	roundRect(context, 850, 260, 20, 340, 5, pat, false);
 
     <!--Base t3-->
-	context.fillRect(690, 600, 330, 15);
+	roundRect(context, 690, 590, 330, 20, 5, pat, false);
 }
 
 function drawDisks (){
@@ -140,7 +127,7 @@ function moveDisk (origin, destiny){
 	}
 	moves.push(origin+"  "+destiny);
 	
-	console.log(moves);
+	//console.log(moves);
 	nMovements++;
 	finishMove(origin, destiny);
 	if(towerC.length == nDisks && nDisks!=0){
@@ -200,7 +187,6 @@ function redo(){
 	if (nMovements < moves.length){
 		var res = moves[nMovements].split("  ");
 		nMovements++;
-		console.log(res[0]+ res[1]);
 		finishMove(parseInt(res[0]), parseInt(res[1]));
 	}
 }

+ 1 - 1
js/integration-functions.js

@@ -66,7 +66,7 @@ function getiLMContent() {
         // Observe que esse método faz parte do arquivo js/iarithmetic-functions.js
         console.log(d);
         res = d.split(" ");
-        inicio(parseInt(res[3]));
+        loadIMGS(parseInt(res[3]));
         if (res.indexOf("Quantidade")!=-1){
             document.getElementById("A_button").disabled = true;
             document.getElementById("B_button").disabled = true;

+ 0 - 0
js/jquery-3.3.1.min.js


+ 22 - 0
js/start.js

@@ -0,0 +1,22 @@
+var canvas = document.getElementById('planoDeFundo');
+var context = canvas.getContext('2d');
+var towerA = [], towerB = [], towerC = [];
+var toMove = null;
+var idF=" ", idT= " ";
+var nMovements = 0, nTotalMovements = 0, nWrongMoves = 0, nDisks;
+var moves = [], totalMoves = []; //vector to save movements
+var acertou=0;
+var optimalSolution;
+		 	//NavyBlue  Lime     Fuchsia   yellow   Orange   LightSteelBlue  red
+var colors = ["#000080","#00FF00", "#FF00FF", "yellow", "#FFA500", "#B0C4DE","red"];
+var start = Date.now(), startOfMove, totalTime, moveTime; //timing vars
+var pat;
+
+function loadIMGS(n){
+	var img = new Image();
+	img.onload = function(){
+		pat = context.createPattern(img, "repeat");
+		inicio(n);
+	};
+	img.src = 'imgs/wood1.jpeg';
+}