made turn right button avaible
This commit is contained in:
parent
ae847a5b37
commit
db44f47368
@ -16,5 +16,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button onclick="turn_left()">Turn Left</button>
|
<button onclick="turn_left()">Turn Left</button>
|
||||||
|
<button onclick="turn_right()">Turn Right</button>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -37,7 +37,7 @@ function turn_left()
|
|||||||
x1 -= WIDTH * MOVE_PIECES;
|
x1 -= WIDTH * MOVE_PIECES;
|
||||||
x2 -= WIDTH * MOVE_PIECES;
|
x2 -= WIDTH * MOVE_PIECES;
|
||||||
|
|
||||||
if ((Math.abs(turn) - (1/MOVE_PIECES / 2)) >= 0)
|
if (turn < 0 && (Math.abs(turn) - (1/MOVE_PIECES / 2)) >= 0)
|
||||||
{
|
{
|
||||||
//ctx.drawImage(img, img.width - WIDTH * MOVE_PIECES * (Math.abs(turn) - (1/MOVE_PIECES / 2)), 0, img.width, img.height, 0, 0, WIDTH * MOVE_PIECES * (Math.abs(turn) - (1/MOVE_PIECES / 2)), WIDTH * ASPECT_RATIO); //DRAW RIGHT PART ON THE LEFT SIDE //TODO
|
//ctx.drawImage(img, img.width - WIDTH * MOVE_PIECES * (Math.abs(turn) - (1/MOVE_PIECES / 2)), 0, img.width, img.height, 0, 0, WIDTH * MOVE_PIECES * (Math.abs(turn) - (1/MOVE_PIECES / 2)), WIDTH * ASPECT_RATIO); //DRAW RIGHT PART ON THE LEFT SIDE //TODO
|
||||||
|
|
||||||
@ -48,3 +48,21 @@ function turn_left()
|
|||||||
|
|
||||||
turn--;
|
turn--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function turn_right()
|
||||||
|
{
|
||||||
|
//MOVE AN 8th TO LEFT
|
||||||
|
x1 += WIDTH * MOVE_PIECES;
|
||||||
|
x2 += WIDTH * MOVE_PIECES;
|
||||||
|
|
||||||
|
if (turn > 0 && (Math.abs(turn) - (1/MOVE_PIECES / 2)) >= 0)
|
||||||
|
{
|
||||||
|
//ctx.drawImage(img, img.width - WIDTH * MOVE_PIECES * (Math.abs(turn) - (1/MOVE_PIECES / 2)), 0, img.width, img.height, 0, 0, WIDTH * MOVE_PIECES * (Math.abs(turn) - (1/MOVE_PIECES / 2)), WIDTH * ASPECT_RATIO); //DRAW RIGHT PART ON THE LEFT SIDE //TODO
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.drawImage(img, x1, 0, img.width + WIDTH * MOVE_PIECES, img.height, 0, 0, WIDTH, WIDTH * ASPECT_RATIO); //DRAW
|
||||||
|
|
||||||
|
turn++;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user