<commit_before>$(document).ready(function(){
	$(document).keydown(function(event){
//        console.log(event.which);
        switch(event.which)
        {
            case 119:
                direction = 0; break; //w
            case 97:
                direction = 1; break; //a
            case 115:
                direction = 2; break; //s
            case 100:
                direction = 3; break; //d
                
            case 38:
                direction = 0; break; //up
            case 37:
                direction = 1; break; //left
            case 40:
                direction = 2; break; //down
            case 39:
                direction = 3; break; //right
        }
    });
    
//    setInterval(update, 1000/60); //60fps
    var fps = 10;
    setInterval(update, 1000/fps);
    
    posX = 0;
    posY = 0;
    width = 15;
    height = 15;
    
    direction = 3;
    
    var tmpW = 900;
    var tmpH = 600;
    game = new SnakeGame(tmpW, tmpH);
    pellet = game.createFoodPellet();
    console.log(game);
    
//    var Game = new SnakeGame(tmpW, tmpH);
//    var Game = new SnakeGame(canvas.width, canvas.height);
});

var posX, posY, width, height;
var direction;
    
//var canvas = document.getElementById("canvas");<commit_msg>Prevent changing direction by 180 degrees (unless snake length==1).<commit_after>$(document).ready(function(){
	$(document).keydown(function(event){
//        console.log(event.which);
        switch(event.which)
        {
            case 119:
                direction = 0; break; //w
            case 97:
                direction = 1; break; //a
            case 115:
                direction = 2; break; //s
            case 100:
                direction = 3; break; //d
                
            case 38: //up
                if(game.snakeBody.length == 1 || !down()) direction = 0; break;
            case 37: //left
                if(game.snakeBody.length == 1 || !right()) direction = 1; break;
            case 40: //down
                if(game.snakeBody.length == 1 || !up()) direction = 2; break;
            case 39: //right
                if(game.snakeBody.length == 1 || !left()) direction = 3; break;
        }
    });
    
//    setInterval(update, 1000/60); //60fps
    var fps = 10;
    setInterval(update, 1000/fps);
    
    posX = 0;
    posY = 0;
    width = 15;
    height = 15;
    
    direction = 3;
    
    var tmpW = 900;
    var tmpH = 600;
    game = new SnakeGame(tmpW, tmpH);
    pellet = game.createFoodPellet();
    console.log(game);
    
//    var Game = new SnakeGame(tmpW, tmpH);
//    var Game = new SnakeGame(canvas.width, canvas.height);
});

var posX, posY, width, height;
var direction;
    
//var canvas = document.getElementById("canvas");
{'fraction_non_alphanumeric': 0.13263462233465848, 'fraction_numerical': 0.04192265992049151, 'mean_word_length': 1.4936936936936938, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6007972', 'n_tokens_mistral': 954, 'n_tokens_neox': 823, 'n_words': 225}