xxxxxxxxxx
72
//Creating main variables
var gameover, sword, alien1, alien2, fruit1, fruit2, fruit3, fruit4;
//Creating image variables
var gameoverImage, swordImage, alien1Image, alien2Image, fruit1Image, fruit2Image, fruit3Image, fruit4Image;
//Creating variables for groups
var fruitsGroup, aliensGroup;
//Creating avriables for score
var score = 0;
//Creating variable for gamestates
var gameState = 1;
var PLAY = 1;
var END = 0;
function preload()
{
//Loading images for variables
swordImage = loadImage("sword.png");
gameOverImage = loadImage("gameover.png");
fruit1Image = loadImage("fruit1.png");
fruit2Image = loadImage("fruit2.png");
fruit3Image = loadImage("fruit3.png");
fruit4Image = loadImage("fruit4.png");
alien1Image = loadImage("alien1.png");
alien2Image = loadImage("alien2.png");
}
function setup()
{
createCanvas(580, 520);
background("lightblue")
//Creating sprite for sword
sword = createSprite(40, 200, 20, 20);
sword.addImage(swordImage);
sword.scale = 0.7;
//creating sprite for gameover
gameover = createSprite
//Naming groups
fruit = new Group();
alien = new Group();
}
function Draw()
{
//Adding statements for both gameStates
if(gameState == PLAY)
{
sword.Y = World.mouseY;
sword.X = World.mouseX;
}
else if(gameState == END)
{
}
drawSprites();
}