Fruit Ninjas! rotate

Make a great game and let's play!

by Kyle Bezio

HTML

<p id="text">Slice the fruits, not the bombs</p>
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;"></canvas>

CSS

#myCanvas {
    cursor:auto;
}

JavaScript

//apple bannana orange cherry watermelon pear kiwi grapes pinapple bomb
//https://www.soundsnap.com/tags/fruit
//https://www.freesound.org/people/qubodup/packs/12143/
/**
Add the fruit in the init() method 
**/
//access the canvas
var canvas = document.getElementById('myCanvas');
//access drawing environment
var context = canvas.getContext("2d");
canvas.width = document.body.clientWidth;
canvas.height = document.body.clientHeight;
var canvasWM = canvas.width / 500; //Canvas width multiplier
var canvasHM = canvas.height / 500; //Canvas height multiplier
//get the mouse coordinates
var mouseX = [];
var mouseY = [];

var firstX;
var firstY;
//set initial gravity
var gravity = 0.4;
//the fruits are stored in an array
var fruits = [];
var maxNumberOfFruits = 6;
var minFruitSize = 100;
var maxFruitSize = 120;
var maxFruitSpeed = 20;
var bombInterval = 10;
//the sword
var sword = new Sword();
//is the sword cutting
var cutting = false;
//game variables
var score = 0;
var tries = 3;
var playing = false;
var count = 0;
var combo = 0;
var combonum = [];
var combocount = 0;
var combocounted = false;
var thread;

function detectmob() { 
 if( navigator.userAgent.match(/Android/i)
 || navigator.userAgent.match(/webOS/i)
 || navigator.userAgent.match(/iPhone/i)
 || navigator.userAgent.match(/iPad/i)
 || navigator.userAgent.match(/iPod/i)
 || navigator.userAgent.match(/BlackBerry/i)
 || navigator.userAgent.match(/Windows Phone/i)
 ){
    return true;
  }
 else {
    return false;
  }
}

var mobile = detectmob();
////////////////////////////
//images for the game
///////////////////////////
//the sword
var sImg = new Image();
sImg.src = "https://s28.postimg.org/jaolso9yl/Sword.png";
//the fruits
var fImg = new Image();
fImg.src = "https://s28.postimg.org/dburbvmnh/Fruit_1.png";
//the background
var bgImg = new Image();
bgImg.src = "http://s29.postimg.org/a0476iz87/image.png";
/******
initialize the awesome
******/
function init() {
    clearInterval(thread);
    fruits = [];
   ...