<commit_before>this.initialize = function()
{
    print("Player.Initialize");
    this.Component.backgroundDivisor = this.Component.backgroundDivisor || 50;
    this.Component.speed = this.Component.speed || 20;
    
    MessageHandler.subscribe("fireBullet", this.fireBullet, this);
}

this.start = function()
{
    print("Player.Start");
    this.AnimatedSprite = this.GameObject.AnimatedSpriteRendererComponent;
    this.Background = this.GameObject.parentGameObject().Background.SpriteRendererComponent.material;
    this.bullet = this.Scene.sceneContents().Bullet;
    this.crosshair = this.Scene.sceneContents().Camera.Crosshair;
    
    this.scaleX = this.Background.textureParameters.z();
    this.scaleY = this.Background.textureParameters.w();
    this.moveX = 0.0;
    this.moveY = 0.0;
}

this.update = function(time)
{   
    var dt = time / 1000;
    
    var translateX = 0;
    var translateY = 0;
    
    if(this.GameObject.Key_Left.isActionHeld())
        translateX = -this.Component.speed * dt;
    
    if(this.GameObject.Key_Right.isActionHeld())
        translateX = this.Component.speed * dt;
    
    if(this.GameObject.Key_Up.isActionHeld())
        translateY = this.Component.speed * dt;
    
    if(this.GameObject.Key_Down.isActionHeld())
        translateY = -this.Component.speed * dt;
    
    //this.GameObject.debug(translateX);
    //this.GameObject.debug(translateY);
    
    this.moveX += translateX / this.Component.backgroundDivisor;
    this.moveY += translateY / this.Component.backgroundDivisor;
    this.Background.textureParameters = new QVector4D(this.moveX, this.moveY, this.scaleX, this.scaleY);
   
    this.GameObject.parentGameObject().translate(translateX / this.scaleX, translateY / this.scaleY, 0);
    
    if(translateX == -this.Component.speed && translateY == this.Component.speed)
        this.AnimatedSprite.direction = 0;
    
    if(translateX == -this.Component.speed && translateY == 0)
        this.AnimatedSprite.direction = 1;
    
    if(translateX == -this.Component.speed && translateY == -this.Component.speed)
        this.AnimatedSprite.direction = 2;
    
    if(translateX == 0 && translateY == -this.Component.speed)
        this.AnimatedSprite.direction = 3;
    
    if(translateX == this.Component.speed && translateY == -this.Component.speed)
        this.AnimatedSprite.direction = 4;
    
    if(translateX == this.Component.speed && translateY == 0)
        this.AnimatedSprite.direction = 5;
    
    if(translateX == this.Component.speed && translateY == this.Component.speed)
        this.AnimatedSprite.direction = 6;
    
    if(translateX == 0 && translateY == this.Component.speed)
        this.AnimatedSprite.direction = 7;
    
    if(translateX == 0 && translateY == 0)
    {
	if(this.AnimatedSprite.animation != 0)
	    this.AnimatedSprite.animation = 0;
    }
    else
    {
        if(this.AnimatedSprite.animation != 1)
            this.AnimatedSprite.animation = 1;
    }
}

this.draw = function(timeLapse)
{
}

this.stop = function()
{
}

this.cleanup = function()
{
}

this.fireBullet = function() 
{
    var newBullet = Game.clone(this.bullet);
    newBullet.enabled = true;

    var newPosition = this.GameObject.worldPosition();
    newPosition.setZ(this.bullet.position.z());
    newBullet.setPosition(newPosition);

    var dir = new QVector3D();
    dir.setX(this.crosshair.worldPosition().x() - newPosition.x());
    dir.setY(this.crosshair.worldPosition().y() - newPosition.y());
    dir.normalize();
    newBullet.ScriptingComponent.direction = dir;
}
<commit_msg>--debug for the apocalypse player script<commit_after>this.initialize = function()
{
    this.Component.backgroundDivisor = this.Component.backgroundDivisor || 50;
    this.Component.speed = this.Component.speed || 20;
    
    MessageHandler.subscribe("fireBullet", this.fireBullet, this);
}

this.start = function()
{
    this.AnimatedSprite = this.GameObject.AnimatedSpriteRendererComponent;
    this.Background = this.GameObject.parentGameObject().Background.SpriteRendererComponent.material;
    this.bullet = this.Scene.sceneContents().Bullet;
    this.crosshair = this.Scene.sceneContents().Camera.Crosshair;
    
    this.scaleX = this.Background.textureParameters.z();
    this.scaleY = this.Background.textureParameters.w();
    this.moveX = 0.0;
    this.moveY = 0.0;
}

this.update = function(time)
{   
    var dt = time / 1000;
    
    var translateX = 0;
    var translateY = 0;
    
    if(this.GameObject.Key_Left.isActionHeld())
        translateX = -this.Component.speed * dt;
    
    if(this.GameObject.Key_Right.isActionHeld())
        translateX = this.Component.speed * dt;
    
    if(this.GameObject.Key_Up.isActionHeld())
        translateY = this.Component.speed * dt;
    
    if(this.GameObject.Key_Down.isActionHeld())
        translateY = -this.Component.speed * dt;
    
    //this.GameObject.debug(translateX);
    //this.GameObject.debug(translateY);
    
    this.moveX += translateX / this.Component.backgroundDivisor;
    this.moveY += translateY / this.Component.backgroundDivisor;
    this.Background.textureParameters = new QVector4D(this.moveX, this.moveY, this.scaleX, this.scaleY);
   
    this.GameObject.parentGameObject().translate(translateX / this.scaleX, translateY / this.scaleY, 0);
    
    if(translateX == -this.Component.speed && translateY == this.Component.speed)
        this.AnimatedSprite.direction = 0;
    
    if(translateX == -this.Component.speed && translateY == 0)
        this.AnimatedSprite.direction = 1;
    
    if(translateX == -this.Component.speed && translateY == -this.Component.speed)
        this.AnimatedSprite.direction = 2;
    
    if(translateX == 0 && translateY == -this.Component.speed)
        this.AnimatedSprite.direction = 3;
    
    if(translateX == this.Component.speed && translateY == -this.Component.speed)
        this.AnimatedSprite.direction = 4;
    
    if(translateX == this.Component.speed && translateY == 0)
        this.AnimatedSprite.direction = 5;
    
    if(translateX == this.Component.speed && translateY == this.Component.speed)
        this.AnimatedSprite.direction = 6;
    
    if(translateX == 0 && translateY == this.Component.speed)
        this.AnimatedSprite.direction = 7;
    
    if(translateX == 0 && translateY == 0)
    {
	if(this.AnimatedSprite.animation != 0)
	    this.AnimatedSprite.animation = 0;
    }
    else
    {
        if(this.AnimatedSprite.animation != 1)
            this.AnimatedSprite.animation = 1;
    }
}

this.draw = function(timeLapse)
{
}

this.stop = function()
{
}

this.cleanup = function()
{
}

this.fireBullet = function() 
{
    var newBullet = Game.clone(this.bullet);
    newBullet.enabled = true;

    var newPosition = this.GameObject.worldPosition();
    newPosition.setZ(this.bullet.position.z());
    newBullet.setPosition(newPosition);

    var dir = new QVector3D();
    dir.setX(this.crosshair.worldPosition().x() - newPosition.x());
    dir.setY(this.crosshair.worldPosition().y() - newPosition.y());
    dir.normalize();
    newBullet.ScriptingComponent.direction = dir;
}

{'fraction_non_alphanumeric': 0.13286516853932584, 'fraction_numerical': 0.009831460674157303, 'mean_word_length': 3.064497716894977, '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': '4040928', 'n_tokens_mistral': 2302, 'n_tokens_neox': 2238, 'n_words': 339}