|
|
@ -57,6 +57,11 @@ function drawBoard(arr){ |
|
|
|
cell.innerHTML = (arr[y][x]); |
|
|
|
} |
|
|
|
} |
|
|
|
// add drawing of snakes and ladders
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//spielbrett objekt Struktur
|
|
|
@ -95,32 +100,42 @@ function generateBoardObjects (leitern, schlangen, objectArray){ |
|
|
|
objectArray.push(schlange); |
|
|
|
} |
|
|
|
} |
|
|
|
//make a canvas the same size as the playbaord
|
|
|
|
function drawCanavas(){ |
|
|
|
var ctx = document.getElementById("canvas"); |
|
|
|
var board = document.getElementById("board"); |
|
|
|
//get the tables measurements
|
|
|
|
tableMes = board.getBoundingClientRect() |
|
|
|
|
|
|
|
tableWidth = tableMes.width; |
|
|
|
tableHight = tableMes.height; |
|
|
|
console.log(tableHight, tableWidth) |
|
|
|
//set canavas to table size
|
|
|
|
ctx.height = tableHight |
|
|
|
ctx.width = tableHight |
|
|
|
//divide canvas x and y by the number of rows // coloums
|
|
|
|
|
|
|
|
//find center of each cell
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//function that draws a line using x,y cooridinates of two points
|
|
|
|
function drawLine(type, count, ax,ay, bx, by){ |
|
|
|
if(ay>by) |
|
|
|
{ |
|
|
|
bx=ax+bx; |
|
|
|
ax=bx-ax; |
|
|
|
bx=bx-ax; |
|
|
|
by=ay+by; |
|
|
|
ay=by-ay; |
|
|
|
by=by-ay; |
|
|
|
} |
|
|
|
var calc=Math.atan((ay-by)/(bx-ax)); |
|
|
|
calc=calc*180/Math.PI; |
|
|
|
var length=Math.sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)); |
|
|
|
console.log(length) |
|
|
|
|
|
|
|
|
|
|
|
let newLine = document.createElement("div") |
|
|
|
newLine.id = type + count; |
|
|
|
|
|
|
|
let style = "height:" + length + "px;width:5px;background-color:black;position:absolute;top:" + (ay) + "px;left:" + (ax) + "px;transform:rotate(" + calc + "deg);-ms-transform:rotate(" + calc + "deg);transform-origin:0% 0%;-moz-transform:rotate(" + calc + "deg);-moz-transform-origin:0% 0%;-webkit-transform:rotate(" + calc + "deg);-webkit-transform-origin:0% 0%;-o-transform:rotate(" + calc + "deg);-o-transform-origin:0% 0%;" |
|
|
|
|
|
|
|
newLine.style.cssText = style; |
|
|
|
document.getElementById("board").appendChild(newLine); |
|
|
|
} |
|
|
|
function drawLine(startPosX, startPosY, endPosX, endPoseY){ |
|
|
|
|
|
|
|
var c = document.getElementById("canvas"); |
|
|
|
var ctx = c.getContext("2d"); |
|
|
|
ctx.beginPath(); |
|
|
|
ctx.moveTo(0, 0); |
|
|
|
ctx.lineTo(537, 537); |
|
|
|
ctx.stroke(); |
|
|
|
ctx.strokeStyle; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function boardObjects(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -128,6 +143,10 @@ function drawLine(type, count, ax,ay, bx, by){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|