<commit_before>package com.mygdx.mount.game.manager.game.services;

import com.badlogic.gdx.Gdx;
import com.mygdx.mount.game.actors.Hero;
import com.mygdx.mount.game.manager.GameManager;


public class MoveService {
    GameManager manager;
    float delta;
    boolean isAccelerated;

    public MoveService(GameManager manager) {
        this.manager = manager;
    }

    public void act(Hero hero) {
        isAccelerated = true;
        delta = Gdx.graphics.getDeltaTime();
        TouchService.REALM currentTouch = manager.getCurrentTouch();
        System.out.println(currentTouch);
        if (currentTouch != null) {
            if (currentTouch.equals(TouchService.REALM.LEFT)) {
                isAccelerated = false;
                slow(hero, delta);
            } else {
                if (currentTouch.equals(TouchService.REALM.RIGHT_UPPER)) {
                    jump(hero);
                } else {
                    doNothing(hero, delta);
                }
            }
        }
        updateHero(hero, delta);
        moveRight(hero, delta, isAccelerated);

    }

    private static void moveRight(Hero hero, float delta, boolean isAccelerated) {
        if (hero.getX() + hero.getSpeed() * delta > GameManager.SCREEN_WIDTH) {
            hero.setX(0);
        }
        hero.setX(hero.getX() + hero.getSpeed() * delta);


        if (!isAccelerated) {
            return;
        }
        hero.setSpeed(hero.getSpeed() + Hero.MAX_SPEED / (Hero.ACCELERATION_TIME / delta));
        if (hero.getSpeed() > Hero.MAX_SPEED) hero.setSpeed(Hero.MAX_SPEED);

    }

    private static void slow(Hero hero, float delta) {
        if (hero.getSpeed() > 0) {
            System.out.println("speed: " + hero.getSpeed());
            hero.setSpeed(hero.getSpeed() - (Hero.SLOW_CONSTANT * delta));
            System.out.println("speed: " + hero.getSpeed());
        }
        if (hero.getSpeed() < 0) {
            hero.setSpeed(0);
        }

    }

    private static void jump(Hero hero) {
        if (hero.getState().equals(Hero.State.Standing)) {
            hero.setState(Hero.State.Ascending);
        }
    }

    private static void doNothing(Hero hero, float delta) {

    }

    private static void updateHero(Hero hero, float delta) {
        if (hero.getState().equals(Hero.State.Ascending)) {
            float distance = Hero.JUMP_MAX_HEIGHT * delta * 3;
            hero.setY(hero.getY() + distance);
            hero.setHeroJumpHeight(hero.getHeroJumpHeight() + distance);
            if (hero.getHeroJumpHeight() > Hero.JUMP_MAX_HEIGHT) {
                hero.setY(hero.getY() + distance);
                hero.setState(Hero.State.Descending);<commit_msg>change slow speed of hero<commit_after>package com.mygdx.mount.game.manager.game.services;

import com.badlogic.gdx.Gdx;
import com.mygdx.mount.game.actors.Hero;
import com.mygdx.mount.game.manager.GameManager;


public class MoveService {
    GameManager manager;
    float delta;
    boolean isAccelerated;

    public MoveService(GameManager manager) {
        this.manager = manager;
    }

    public void act(Hero hero) {
        isAccelerated = true;
        delta = Gdx.graphics.getDeltaTime();
        TouchService.REALM currentTouch = manager.getCurrentTouch();
        System.out.println(currentTouch);
        if (currentTouch != null) {
            if (currentTouch.equals(TouchService.REALM.LEFT)) {
                isAccelerated = false;
                slow(hero, delta);
            } else {
                if (currentTouch.equals(TouchService.REALM.RIGHT_UPPER)) {
                    jump(hero);
                } else {
                    doNothing(hero, delta);
                }
            }
        }
        updateHero(hero, delta);
        moveRight(hero, delta, isAccelerated);

    }

    private static void moveRight(Hero hero, float delta, boolean isAccelerated) {
        if (hero.getX() + hero.getSpeed() * delta > GameManager.SCREEN_WIDTH) {
            hero.setX(0);
        }
        hero.setX(hero.getX() + hero.getSpeed() * delta);


        if (!isAccelerated) {
            return;
        }
        hero.setSpeed(hero.getSpeed() + Hero.MAX_SPEED / (Hero.ACCELERATION_TIME / delta));
        if (hero.getSpeed() > Hero.MAX_SPEED) hero.setSpeed(Hero.MAX_SPEED);

    }

    private static void slow(Hero hero, float delta) {
        if (hero.getSpeed() > 0) {
            System.out.println("speed: " + hero.getSpeed());
            hero.setSpeed(hero.getSpeed() - (Hero.SLOW_CONSTANT * delta * 3));
            System.out.println("speed: " + hero.getSpeed());
        }
        if (hero.getSpeed() < 0) {
            hero.setSpeed(0);
        }

    }

    private static void jump(Hero hero) {
        if (hero.getState().equals(Hero.State.Standing)) {
            hero.setState(Hero.State.Ascending);
        }
    }

    private static void doNothing(Hero hero, float delta) {

    }

    private static void updateHero(Hero hero, float delta) {
        if (hero.getState().equals(Hero.State.Ascending)) {
            float distance = Hero.JUMP_MAX_HEIGHT * delta * 3;
            hero.setY(hero.getY() + distance);
            hero.setHeroJumpHeight(hero.getHeroJumpHeight() + distance);
            if (hero.getHeroJumpHeight() > Hero.JUMP_MAX_HEIGHT) {
                hero.setY(hero.getY() + distance);
                hero.setState(Hero.State.Descending);
{'fraction_non_alphanumeric': 0.12031887282165368, 'fraction_numerical': 0.002039302929180571, 'mean_word_length': 2.0601247872943844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '3751294', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1640, 'n_words': 292}