{"size": 917, "ext": "js", "max_stars_repo_path": "src/js/core/Snake.js", "max_stars_repo_name": "mariuszklinger/snake3D", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/js/core/Snake.js", "max_issues_repo_name": "mariuszklinger/snake3D", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/js/core/Snake.js", "max_forks_repo_name": "mariuszklinger/snake3D", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.3777777778, "max_line_length": 68, "alphanum_fraction": 0.4231188659}
'use strict';

define(['underscore', 'core/SETTINGS'], function(_, SETTINGS){

    function Snake(scene){

        this.ID = 1;
        
        this.color = Math.random() * 0xFFFFFF;
        
        this.last_direction = false;
        this.engine = undefined;

        this.body = [
            {v: [0, 0, 1]},
            {v: [0, 0, 2]},
            {v: [0, 0, 3]},
            {v: [0, 0, 4]},
            {v: [0, 0, 5]},
            {v: [0, 0, 6]},
        ];
    };

    Snake.prototype.OPPOSITES_MOVES = {
        'A': 'D',
        'D': 'A',
        'S': 'W',
        'W': 'S',
        'Q': 'E',
        'E': 'Q',
        false: '',
    }

    Snake.prototype.move = function(direction){

        if(this.last_direction === this.OPPOSITES_MOVES[direction]){
            return;
        }

        this.last_direction = direction;
        return this.engine.move(this.ID, direction);
    }

    return Snake;
})