<commit_before>package cc.clv.BlueRobe.input;

import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.math.Vector2;

import cc.clv.BlueRobe.BlueRobe;
import rx.Observable;
import rx.subjects.PublishSubject;

/**
 * Created by slightair on 15/02/21.
 */
public class GameSceneInput extends InputMultiplexer {

    private class GestureListener implements GestureDetector.GestureListener {

        private static final float flingThreshold = 200.0f;

        @Override
        public boolean touchDown(float x, float y, int pointer, int button) {
            subject.onNext(BlueRobe.Action.CHARACTER_PREPARE_JUMP);
            return false;
        }

        @Override
        public boolean tap(float x, float y, int count, int button) {
            subject.onNext(BlueRobe.Action.CHARACTER_JUMP);
            return false;
        }

        @Override
        public boolean longPress(float x, float y) {
            return false;
        }

        @Override
        public boolean fling(float velocityX, float velocityY, int button) {
            if (velocityX > flingThreshold) {
                subject.onNext(BlueRobe.Action.CHARACTER_MOVE_RIGHT);
            } else if (velocityX < -flingThreshold) {
                subject.onNext(BlueRobe.Action.CHARACTER_MOVE_LEFT);
            }

            return false;
        }

        @Override
        public boolean pan(float x, float y, float deltaX, float deltaY) {
            return false;
        }

        @Override
        public boolean panStop(float x, float y, int pointer, int button) {
            subject.onNext(BlueRobe.Action.CHARACTER_CANCEL_JUMP);
            return false;
        }

        @Override
        public boolean zoom(float initialDistance, float distance) {
            return false;
        }

        @Override
        public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1,
                Vector2 pointer2) {
            return false;
        }
    }

    private class KeyboardInputProcessor implements InputProcessor {

        @Override
        public boolean keyDown(int keycode) {
            return false;
        }

        @Override
        public boolean keyUp(int keycode) {
            switch (keycode) {
                case Input.Keys.A:
                case Input.Keys.LEFT:
                    subject.onNext(BlueRobe.Action.CHARACTER_MOVE_LEFT);
                    break;
                case Input.Keys.D:
                case Input.Keys.RIGHT:
                    subject.onNext(BlueRobe.Action.CHARACTER_MOVE_RIGHT);
                    break;
            }
            return false;
        }

        @Override
        public boolean keyTyped(char character) {
            return false;
        }

        @Override
        public boolean touchDown(int screenX, int screenY, int pointer, int button) {
            return false;
        }

        @Override
        public boolean touchUp(int screenX, int screenY, int pointer, int button) {
            return false;
        }<commit_msg>Add jump action by Space key<commit_after>package cc.clv.BlueRobe.input;

import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.math.Vector2;

import cc.clv.BlueRobe.BlueRobe;
import rx.Observable;
import rx.subjects.PublishSubject;

/**
 * Created by slightair on 15/02/21.
 */
public class GameSceneInput extends InputMultiplexer {

    private class GestureListener implements GestureDetector.GestureListener {

        private static final float flingThreshold = 200.0f;

        @Override
        public boolean touchDown(float x, float y, int pointer, int button) {
            subject.onNext(BlueRobe.Action.CHARACTER_PREPARE_JUMP);
            return false;
        }

        @Override
        public boolean tap(float x, float y, int count, int button) {
            subject.onNext(BlueRobe.Action.CHARACTER_JUMP);
            return false;
        }

        @Override
        public boolean longPress(float x, float y) {
            return false;
        }

        @Override
        public boolean fling(float velocityX, float velocityY, int button) {
            if (velocityX > flingThreshold) {
                subject.onNext(BlueRobe.Action.CHARACTER_MOVE_RIGHT);
            } else if (velocityX < -flingThreshold) {
                subject.onNext(BlueRobe.Action.CHARACTER_MOVE_LEFT);
            }

            return false;
        }

        @Override
        public boolean pan(float x, float y, float deltaX, float deltaY) {
            return false;
        }

        @Override
        public boolean panStop(float x, float y, int pointer, int button) {
            subject.onNext(BlueRobe.Action.CHARACTER_CANCEL_JUMP);
            return false;
        }

        @Override
        public boolean zoom(float initialDistance, float distance) {
            return false;
        }

        @Override
        public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1,
                Vector2 pointer2) {
            return false;
        }
    }

    private class KeyboardInputProcessor implements InputProcessor {

        @Override
        public boolean keyDown(int keycode) {
            switch (keycode) {
                case Input.Keys.SPACE:
                    subject.onNext(BlueRobe.Action.CHARACTER_PREPARE_JUMP);
                    break;
            }
            return false;
        }

        @Override
        public boolean keyUp(int keycode) {
            switch (keycode) {
                case Input.Keys.A:
                case Input.Keys.LEFT:
                    subject.onNext(BlueRobe.Action.CHARACTER_MOVE_LEFT);
                    break;
                case Input.Keys.D:
                case Input.Keys.RIGHT:
                    subject.onNext(BlueRobe.Action.CHARACTER_MOVE_RIGHT);
                    break;
                case Input.Keys.SPACE:
                    subject.onNext(BlueRobe.Action.CHARACTER_JUMP);
                    break;
            }
            return false;
        }

        @Override
        public boolean keyTyped(char character) {
            return false;
        }

        @Override
        public boolean touchDown(int screenX, int screenY, int pointer, int button) {
            return false;
        }

        @Override
        public boolean touchUp(int screenX, int screenY, int pointer, int button) {
            return false;
        }
{'fraction_non_alphanumeric': 0.07235064545181627, 'fraction_numerical': 0.005703992794956469, 'mean_word_length': 1.7878661087866108, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '929088', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1765, 'n_words': 437}