1 /** Stuff. */
  2 function block(x, y, hp, drop, imageorheight, width, color){
  3 this.x = x;
  4 this.y = y;
  5 this.hp = hp
  6 this.width;
  7 this.height
  8 this.image;
  9 this.drop;
 10 this.hasdrop;
 11 if(!drop){
 12 this.hasdrop = false
 13 }
 14 else{
 15 this.drop = drop;
 16 this.hasdrop = true
 17 }
 18 this.score = 100+(this.hp*50)+(this.hasdrop?100:0)
 19 if(typeof imageorheight ==='string'){
 20 	this.image = LoadSurface(imageorheight);
 21 	this.width 	= this.image.width;
 22 	this.height = this.image.height;
 23 	}
 24 	else{
 25 	this.image = CreateSurface(width, imageorheight, CreateColor(0,0,0,0));
 26 	this.image.rectangle(0,0,width, imageorheight, color, false);
 27 	this.width	= width;
 28 	this.height = imageorheight;
 29 	}
 30 
 31 this.blit = function(){this.image.blit(this.x,this.y)}
 32 this.hit 	= function(atk){this.hp-=atk}
 33 }
 34 
 35 
 36 function processBlocks(){
 37 var i = 0;
 38 	while(i<blocks.length){
 39 	blocks[i].blit();
 40 	for(var e = 0; e<balls.length; e++){
 41 		var col = checkForCollision(balls[e], blocks[i])
 42 		if(col[0]) {
 43 		blocks[i].hp-=balls[e].atk;
 44 		if(blocks[i].hp>0) {S_bounce.play();}
 45 		if((col[1]=="left")||(col[1]=="right")){
 46 		if(!balls[e].unstoppable) {balls[e].traj=-(balls[e].traj-Math.PI)}}
 47 		else if((col[1]=="up")||(col[1]=="down")){
 48 		if(!balls[e].unstoppable) {balls[e].traj=-(balls[e].traj)}}
 49 		break}
 50 		}
 51 	if(blocks[i].hp<=0){
 52 		if(blocks[i].hasdrop){
 53 		drops.push(blocks[i].drop);
 54 		}
 55 		S_break.play();
 56 		score+=blocks[i].score;
 57 		blocks.splice(i, 1)
 58 	}
 59 	else i++
 60 	}
 61 }
 62 
 63 function checkForCollision(object, obstr){
 64 var i = 0;
 65 var fdist = accDist(new theorypoint(obstr.x+(obstr.width/2), obstr.y+(obstr.height/2)), object)
 66 //font.drawText(200,0,fdist);
 67 if(fdist>(Math.max(obstr.height, obstr.width)/2)+object.size){return [false]}
 68 
 69 
 70 		for(var e = 0; e<obstr.width; e++){
 71 		if(accDist(object, new theorypoint(obstr.x+e, obstr.y+obstr.height))<object.size/2) {return [true, "down"]}
 72 		}
 73 		for(var e = 0; e<obstr.width; e++){
 74 		
 75 		if(accDist(object, new theorypoint(obstr.x+e, obstr.y))<object.size/2) {return [true, "up"]}
 76 		}
 77 		for(var e = 0; e<obstr.height; e++){
 78 		if(accDist(object, new theorypoint(obstr.x, obstr.y+e))<object.size/2) {return [true, "left"]}
 79 		}
 80 		for(var e = 0; e<obstr.height; e++){
 81 		if(accDist(object, new theorypoint(obstr.x+obstr.width, obstr.y+e))<object.size/2) {return [true, "right"]}
 82 		}
 83 
 84 
 85 return [false]
 86 }
 87 
 88 
 89 var screenL = new block(-64, 0, 10000000, false, GetScreenHeight(), 64, CreateColor(0,0,0,0))
 90 var screenR = new block(GetScreenWidth(), 0, 10000000, false, GetScreenHeight(), 64, CreateColor(0,0,0,0))
 91 var screenU = new block(0, -64, 10000000, false, 64, GetScreenWidth(), CreateColor(0,0,0,0))
 92 var screenD = new block(0, GetScreenHeight(), 10000000, false, 64, GetScreenWidth(), CreateColor(0,0,0,0))