snake.js 653 B

123456789101112131415161718192021222324252627282930
  1. var Snake = function(){
  2. this.physicists = [];
  3. for (var i = 0; i < n_physicsists; i++){
  4. this.physicists.push_back(new Physicist(this, position));
  5. }
  6. this.new_physicists = [];
  7. this.bonuses = [];
  8. this.speed = 1;
  9. }
  10. Snake.prototype.add_physicist = function(physicist){
  11. }
  12. Snake.prototype.add_bonus = function(bonus){
  13. }
  14. Snake.prototype.remove_physicist = function(index){
  15. }
  16. Snake.prototype.move = function(next_cell){
  17. this.physicist[0].position = next_cell;
  18. for(var i = 1; i < this.physicist.length; i++){
  19. this.physicists[i].position = this.physicists[i-1].position;
  20. this.physicists[i].direction = this.physicists[i-1].direction;
  21. }
  22. }