xxxxxxxxxx
48
let player;
let player2;
function setup() {
createCanvas(600, 600);
player = new Player(300, 300, 250, 170);
player2 =new Player(50, 50, 100, 100);
}
class Player{
constructor(x,y,w,h){
this.x = x ;
this.y = y ;
this.w = w ;
this.h = h ;
this.nwfull = 100;
this.nøfull = 100;
this.swfull = 100;
this.søfull = 100;
this.nwoff = 0;
this.nøoff = 0;
this.swoff = 0;
this.søoff = 0;
}
display(){
rect(this.x,this.y,this.w,this.h,this.søoff,this.nøoff,this.søoff,this.swoff);
if (this.y>200){this.søoff=this.søoff*1.2+1
}else{this.søoff=0}}
move(){
if (keyIsDown(68)) {this.x = this.x+ 4}
if (keyIsDown(65)) {this.x = this.x -4}
if (keyIsDown(87)) {this.y = this.y - 10}
if (keyIsDown(83)) {this.y = this.y + 10}
}
}
function draw() {
background(220);
player.display();
player.move();
player2.display();
}