<commit_before>package com.martinimoe.projektkarpador;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.utils.Scaling;

public class ProjektKarpador extends ApplicationAdapter implements ApplicationListener, InputProcessor {
	AtlasRegion grassLeft;
	AtlasRegion grassMiddle;
	AtlasRegion grassRight;
	AtlasRegion playerStanding;
	
	private OrthographicCamera camera;
	private SpriteBatch batch;
	private int imgX = 20;
	private int imgY = 70;
	private boolean imgMove = false;
	private int imgMoveOffsetX = 0;
	private int imgMoveOffsetY = 0;
	
	@Override
	public void create () {
		batch = new SpriteBatch();
		
		TextureAtlas atlas;
		atlas = new TextureAtlas(Gdx.files.internal("KarpadorAtlas.pack"));
		grassLeft = atlas.findRegion("Tiles/grassLeft");
		grassMiddle = atlas.findRegion("Tiles/grassMid");
		grassRight = atlas.findRegion("Tiles/grassRight");
		playerStanding = atlas.findRegion("Player/p1_stand");
		
		float w = Gdx.graphics.getWidth();
		float h = Gdx.graphics.getHeight();
		
		camera = new OrthographicCamera(w, h);
		camera.setToOrtho(false, w * 100, h * 100);
		
		Gdx.input.setInputProcessor(this);
	}

	@Override
	public void render () {
		Gdx.gl.glClearColor(0, 0, 0, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		batch.begin();
		batch.draw(grassLeft, 0, 0);
		batch.draw(grassMiddle, 70, 0);
		batch.draw(grassRight, 140, 0);
		batch.draw(playerStanding, imgX, imgY);
		batch.end();
	}
	
	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
	}
	
	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		int w = Gdx.graphics.getWidth();
		int h = Gdx.graphics.getHeight();
		
		if (screenX >= imgX && screenX < imgX + playerStanding.packedWidth &&
		    (h - screenY) >= imgY && (h - screenY) < imgY + playerStanding.packedHeight)
		{
			imgMove = true;
			
			imgMoveOffsetX = screenX - imgX;
			imgMoveOffsetY = (h - screenY) - imgY;
		}
		
		System.out.println("pos: " + screenX + ", " + screenY);

		return false;
	}

	@Override
	public boolean touchUp(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		imgMove = false;
		
		return false;
	}
	
	@Override
	public boolean touchDragged(int screenX, int screenY, int pointer) {
		// TODO Auto-generated method stub
		if (imgMove)
		{
			int w = Gdx.graphics.getWidth();
			int h = Gdx.graphics.getHeight();
			
			imgX = screenX - imgMoveOffsetX;
			imgY = (h - screenY) - imgMoveOffsetY;
		}
		
		return false;
	}

	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean scrolled(int amount) {
		// TODO Auto-generated method stub
		return false;
	}
	

	@Override
	public boolean keyDown(int keycode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyUp(int keycode) {
		// TODO Auto-generated method stub
		return false;<commit_msg>Player cant move out of window borders<commit_after>package com.martinimoe.projektkarpador;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;

public class ProjektKarpador extends ApplicationAdapter implements ApplicationListener, InputProcessor {
	AtlasRegion grassLeft;
	AtlasRegion grassMiddle;
	AtlasRegion grassRight;
	AtlasRegion playerStanding;
	
	private OrthographicCamera camera;
	private SpriteBatch batch;
	private int imgX = 20;
	private int imgY = 70;
	private boolean imgMove = false;
	private int imgMoveOffsetX = 0;
	private int imgMoveOffsetY = 0;
	
	@Override
	public void create () {
		batch = new SpriteBatch();
		
		TextureAtlas atlas;
		atlas = new TextureAtlas(Gdx.files.internal("KarpadorAtlas.pack"));
		grassLeft = atlas.findRegion("Tiles/grassLeft");
		grassMiddle = atlas.findRegion("Tiles/grassMid");
		grassRight = atlas.findRegion("Tiles/grassRight");
		playerStanding = atlas.findRegion("Player/p1_stand");
		
		float w = Gdx.graphics.getWidth();
		float h = Gdx.graphics.getHeight();
		
		camera = new OrthographicCamera(w, h);
		camera.setToOrtho(false, w * 100, h * 100);
		
		Gdx.input.setInputProcessor(this);
	}

	@Override
	public void render () {
		Gdx.gl.glClearColor(0, 0, 0, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		batch.begin();
		batch.draw(grassLeft, 0, 0);
		batch.draw(grassMiddle, 70, 0);
		batch.draw(grassRight, 140, 0);
		batch.draw(playerStanding, imgX, imgY);
		batch.end();
	}
	
	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
	}
	
	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		int w = Gdx.graphics.getWidth();
		int h = Gdx.graphics.getHeight();
		
		if (screenX >= imgX && screenX < imgX + playerStanding.packedWidth &&
		    (h - screenY) >= imgY && (h - screenY) < imgY + playerStanding.packedHeight)
		{
			imgMove = true;
			
			imgMoveOffsetX = screenX - imgX;
			imgMoveOffsetY = (h - screenY) - imgY;
		}
		
		return false;
	}

	@Override
	public boolean touchUp(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		imgMove = false;
		
		return false;
	}
	
	@Override
	public boolean touchDragged(int screenX, int screenY, int pointer) {
		// TODO Auto-generated method stub
		if (imgMove)
		{
			int w = Gdx.graphics.getWidth();
			int h = Gdx.graphics.getHeight();
			
			if (screenX >= 0 && screenX <= w &&
				screenY >= 0 && screenY <= h) {
				imgX = screenX - imgMoveOffsetX;
				imgY = (h - screenY) - imgMoveOffsetY;
			}
		}
		
		return false;
	}

	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean scrolled(int amount) {
		// TODO Auto-generated method stub
		return false;
	}
	

	@Override
	public boolean keyDown(int keycode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyUp(int keycode) {
		// TODO Auto-generated method stub
		return false;
{'fraction_non_alphanumeric': 0.11126449475427941, 'fraction_numerical': 0.00966316951960243, 'mean_word_length': 3.8722259583053127, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '935276', 'n_tokens_mistral': 2750, 'n_tokens_neox': 2415, 'n_words': 601}