Skip to content

Instantly share code, notes, and snippets.

@klemenzarn
Created March 16, 2014 17:21
Show Gist options
  • Save klemenzarn/9586680 to your computer and use it in GitHub Desktop.
Save klemenzarn/9586680 to your computer and use it in GitHub Desktop.
//razred snake
function Snake(){
this.dolzina = 1;
this.x = 0;
this.y = 0;
this.telo = new Array();
for (var i=0;i<this.dolzina;i++) {
telo.push(new Telo(i,0));
}
}
Item.prototype.getX = function(){
return this.x;
};
Item.prototype.getY = function(){
return this.y;
};
Item.prototype.setX = function(x){
this.x = x;
};
Item.prototype.setY = function(y){
this.y = y;
};
Snake.prototype.checkCollision = function(item){
if(this.x == item.getX() && this.y == item.getY()){
return true;
}
return false;
};
Snake.prototype.addTelo = function(){
telo.push(new Telo(1,1));
};
Snake.prototype.move = function(){
}
//razred telo
function Telo(x,y){
this.x = x;
this.y = y;
}
Telo.prototype.getX = function(){
return this.x;
};
Telo.prototype.getY = function(){
return this.y;
};
Telo.prototype.setX = function(x){
this.x = x;
};
Telo.prototype.setY = function(y){
this.y = y;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment