xxxxxxxxxx
var w = 64;
var h = 64;
var counter = 0;
var dx = 0;
var fr = 0;
var topAlien = [];
function preload(){
aliens = loadImage("Spaceinvaders1.png");
}
function setup() {
createCanvas(windowWidth, windowHeight);
for (var i = 0; i< 1; i++) {
topAlien.push(new Alien(i*80+dx));
frameRate(2);
}
}
function draw() {
background(120);
for (var i=0; i<topAlien.length; i++) {
topAlien[i].display();
//alien();
print(fr);
}
}
function Alien(x){
this.dx = x;
this.display = function(){
if (fr == 0){
//scale(.8);
copy(aliens, 338, 104, 65, h, dx, 100, w, h); //i*80+dx, 100, w, h);
}else if (fr == 1){
//scale(.8);
copy(aliens, 242, 104, 65, h, dx, 100, w, h);
}
fr = fr + 1;
if (fr >= 2){
fr = 0;
}
dx = dx + 35;
}
}