xxxxxxxxxx
var SmallEnemy = [];
var Intelli = [];
var bullets = [];
function preload() {
player = loadImage('player.png');
enemy = loadImage('enemy.png');
// bull=loadImage('bull.png');
}
function setup() {
createCanvas(375, 375);
SmallEnemy.push(new smallEnemy());
Intelli.push(new Intelligent());
bullets.push(new bullet());
}
function draw() {
background(0);
var px = mouseX;
var py = mouseY;
image(player, px, py, 40, 40);
// rect(mouseX, mouseY, 20, 20);
print("draw");
var y1 = 0;
var x1 = 0;
var y2 = 0;
var x2 = 0;
var ds;
var di;
//for smaller enemies
//'''''''''''''''''''
for (var i = 0; i < SmallEnemy.length; i++) {
SmallEnemy[i].show();
SmallEnemy[i].update();
ds = dist(mouseX, mouseY, SmallEnemy[i].x, SmallEnemy[i].y);
print(ds);
if (ds < 42) {
print("chlo re");
SmallEnemy.splice(i, 1);
} else {
print("waaps");
}
}
//for the intelligent enemies
for (var a = 0; a < Intelli.length; a++) {
Intelli[a].show()
Intelli[a].update();
di = dist(mouseX, mouseY, Intelli[a].x, Intelli[a].y);
if (di < 45 + 0) {
noLoop();
}
let dix = Intelli[a].x;
let diy = Intelli[a].y;
if (di <= 200 && di > 49) {
for (var j = 0; j < bullets.length; j++) {
bullets[j].show();
bullets[j].update();
bullets.push(new bullet());
}
// ellipse (dix,diy,010,10);
// print("before"+diy);
// dix-=px;
// diy -=py;
//print ("gdhsjsbbsbsbsbsh"+diy);
}
}
//pushing of the smaller enemies
if (frameCount % 0100 == 0) {
SmallEnemy.push(new smallEnemy());
}
//pushing for Intelligent enemies
if (frameCount % 60 == 0) {
Intelli.push(new Intelligent());
}
}