<commit_before>//
// Created by dar on 11/28/15.
//

#include "EntityPlayer.h"
#include "core/map/Map.h"
#include <core/map/chunk/block/SimpleBlock.h>
#include "EntityToy.h"

EntityPlayer::EntityPlayer(LevelContext &levelContext) : EntityMoving(levelContext, 0.55, 0.55) {
    b2CircleShape shape;
    shape.m_p.Set(0, 0);
    shape.m_radius = 1.5; // A bit more than our size because it is only a sensor
    b2FixtureDef fixDef;
    fixDef.shape = &shape;
    fixDef.isSensor = true;
    fixDef.density = 2.0f;
    fixDef.friction = 0.1f;
    this->body->CreateFixture(&fixDef);
}

void EntityPlayer::update(double deltaTime) {
    EntityMoving::update(deltaTime);

    this->ejectTimer *= pow(0.75, deltaTime);
    if (std::abs(this->ejectTimer) < 0.05) {
        if (this->ejectTimer < 0.0) {
            this->setToy(true);
        }
        this->ejectTimer = 0.0;
    } else {
        if (this->ejectTimer > 0) {
            this->applyForce(3 * this->ejectTimer, 3 * this->ejectTimer);
        } else if (this->getToyToMerge() != nullptr) {
            this->applyForce((this->getToyToMerge()->getX() - this->getX()) * 2.0, (this->getToyToMerge()->getY() - this->getY()) * 2.0);
        }
    }

    if (this->getToy() == nullptr) {
        double speed_x = this->getBody()->GetLinearVelocity().x;
        double speed_y = this->getBody()->GetLinearVelocity().y;
        double speed = speed_x * speed_x + speed_y * speed_y;
        this->increaseTailAnimation((0.5 + speed * 0.9) * 0.3 * deltaTime);
    }

    if (this->getToy() != nullptr) {
        this->setX(this->getToy()->getX());
        this->setY(this->getToy()->getY());
    }

    if (this->getToy() != nullptr) {
        this->colorfulness += 0.04 * deltaTime;
        if (this->colorfulness > 2.0) this->colorfulness = 2.0;
    } else {
        this->colorfulness -= 0.025 * deltaTime;
        if (this->colorfulness < 0.0) this->colorfulness = 0.0;<commit_msg>Increased tail animation speed during movement<commit_after>//
// Created by dar on 11/28/15.
//

#include "EntityPlayer.h"
#include "core/map/Map.h"
#include <core/map/chunk/block/SimpleBlock.h>
#include "EntityToy.h"

EntityPlayer::EntityPlayer(LevelContext &levelContext) : EntityMoving(levelContext, 0.55, 0.55) {
    b2CircleShape shape;
    shape.m_p.Set(0, 0);
    shape.m_radius = 1.5; // A bit more than our size because it is only a sensor
    b2FixtureDef fixDef;
    fixDef.shape = &shape;
    fixDef.isSensor = true;
    fixDef.density = 2.0f;
    fixDef.friction = 0.1f;
    this->body->CreateFixture(&fixDef);
}

void EntityPlayer::update(double deltaTime) {
    EntityMoving::update(deltaTime);

    this->ejectTimer *= pow(0.75, deltaTime);
    if (std::abs(this->ejectTimer) < 0.05) {
        if (this->ejectTimer < 0.0) {
            this->setToy(true);
        }
        this->ejectTimer = 0.0;
    } else {
        if (this->ejectTimer > 0) {
            this->applyForce(3 * this->ejectTimer, 3 * this->ejectTimer);
        } else if (this->getToyToMerge() != nullptr) {
            this->applyForce((this->getToyToMerge()->getX() - this->getX()) * 2.0, (this->getToyToMerge()->getY() - this->getY()) * 2.0);
        }
    }

    if (this->getToy() == nullptr) {
        double speed = velX * velX + velY * velY;
        this->increaseTailAnimation((0.35 + speed * 0.6) * 0.3 * deltaTime);
    }

    if (this->getToy() != nullptr) {
        this->setX(this->getToy()->getX());
        this->setY(this->getToy()->getY());
    }

    if (this->getToy() != nullptr) {
        this->colorfulness += 0.04 * deltaTime;
        if (this->colorfulness > 2.0) this->colorfulness = 2.0;
    } else {
        this->colorfulness -= 0.025 * deltaTime;
        if (this->colorfulness < 0.0) this->colorfulness = 0.0;
{'fraction_non_alphanumeric': 0.17456093666844066, 'fraction_numerical': 0.032197977647684936, 'mean_word_length': 2.621387283236994, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 83, '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': '4211815', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1327, 'n_words': 252}