Version 0.3

Move over to new physics engine. Level coloured grey to see it better.
Extremely glitchy, not working very well at all.
This commit is contained in:
Markus Scully 2013-07-05 21:35:40 +01:00
parent 8f3bd8c150
commit b063eecfff
3 changed files with 208 additions and 113 deletions

48
oldCollision.js Normal file
View file

@ -0,0 +1,48 @@
this.xCheck = function(){
this.left = this.right = false;
for(j in actors){
if(actors[j].image != this.image){
if(actors[j].x + 16 > this.x && this.x > actors[j].x && this.sameY(actors[j])){
this.left = true;
this.x = actors[j].x + 16;
this.xvel = (this.xvel < 0 ? 0 : this.xvel);
}
if(this.x + 16 > actors[j].x && this.x < actors[j].x && this.sameY(actors[j])){
this.right = true;
this.x = actors[j].x - 16;
this.xvel = (this.xvel > 0 ? 0 : this.xvel);
}
}
}
}
this.yCheck = function(){
this.up = this.down = false;
if(this.y >= 216){
this.down = true;
this.y = 216;
}
for(j in actors){
if(actors[j].image != this.image){
if(this.y + 16 > actors[j].y && this.y < actors[j].y + 16 && this.sameX(actors[j])){
if(this.y < actors[j].y){
this.down = true;
this.y = actors[j].y - 16;
}else{
this.up = true;
this.y = actors[j].y + 16;
}
}
}
}
}
this.sameY = function(obj){
return (this.y < obj.y + 15 && this.y + 16 > obj.y);
}
this.sameX = function(obj){
return (this.x + 15 > obj.x && this.x < obj.x + 15);
}