<commit_before>#include "player.h"

Player::Player()
{
	
}


Player::Player(Level* lev)
{
	moveVector = sf::Vector2f(0,0);
	position = lev->getPlayerStart();
//	std::cout << "pos: " << position.x << "," << position.y << "\n";
//	initPlayer();
	movementSpeed = 8;
	level = lev;
	collectedScrews = 0;
//	orientation = DIRECTION_LEFT;
//	s = SoundHandler::getSoundHandler();
//	shooting = false;
//	reload_time = 40;
//	shoot_threshold = 0;
//	leben = 100.0f;
	roboto_bold.loadFromFile("assets/Roboto-Bold.ttf");
	tex_player.loadFromFile("assets/robot_ani.png");
	ani = new Animation();
	ani->setSpriteSheet(tex_player);
	ani->addFrame(sf::IntRect(0, 0, 80, 80));
	ani->addFrame(sf::IntRect(80, 0, 80, 80));
	animatedSprite = new AnimatedSprite(sf::seconds(0.2), true, false);
}


void Player::move()
{
	
	
	
	sf::Vector2f mV = moveVector*movementSpeed;
	
	//std::cout << "move\n" << mV.x << "  " <<mV.y<<"\n";
	
	
	
	// Bounding box of the player(after the move)
	sf::FloatRect* player_box = new sf::FloatRect(position + mV,sf::Vector2f(ROBOTSIZE,ROBOTSIZE));
	
	//check if hit exit
	if(level->isExit(position + mV,player_box))
	{
		resetLevel(new Level(level->getNextLevel()));
		std::cout << "Exit\n";
	}
	
	//check for wall Collisions
	mV = level->wallCollision(position,player_box,mV);
	
	// Update the player location
	sf::Vector2f new_location(position + mV);
	//std::cout << "pos: " << position.x << "," << position.y << "\n";
	

	//std::cout << "move\n" << mV.x << "  " <<mV.y<<"\n";

	
	
	// Check if new position is inside the game area
	if(new_location.x >= 0
		&& new_location.x + ROBOTSIZE <= level->getBounds().x
		&& new_location.y >= 0
		&& new_location.y + ROBOTSIZE <= level->getBounds().y)
	{
	//	std::cout<< collision << "\n";
		position = new_location; // Update location
	}
	collectedScrews += level->screwCollision(position,player_box);
	
	animatedSprite->update(sf::seconds(0.02));
	animatedSprite->setPosition(position);
}

void Player::setMovementDirection(int direction)
{
	
	switch(direction)
	{
		case DIRECTION_LEFT:
		moveVector = sf::Vector2f(-1,0);
		break;

		case DIRECTION_LEFT_UP:
		moveVector = sf::Vector2f(-1,-1);
		break;
		
		case DIRECTION_LEFT_DOWN:
		moveVector = sf::Vector2f(-1,1);
		break;

		case DIRECTION_RIGHT:
		moveVector = sf::Vector2f(1,0);
		break;
		
		case DIRECTION_RIGHT_UP:
		moveVector = sf::Vector2f(1,-1);
		break;
		
		case DIRECTION_RIGHT_DOWN:
		moveVector = sf::Vector2f(1,1);
		break;

		case DIRECTION_UP:
		moveVector = sf::Vector2f(0,-1);
		break;

		case DIRECTION_DOWN:
		moveVector = sf::Vector2f(0,1);
		break;

		default:
		//moveVector = sf::Vector2f(0,0);
		break;
	}
}


sf::Vector2f Player::getPosition()
{<commit_msg>bugfix<commit_after>#include "player.h"

Player::Player()
{
	
}


Player::Player(Level* lev)
{
	moveVector = sf::Vector2f(0,0);
	position = lev->getPlayerStart();
//	std::cout << "pos: " << position.x << "," << position.y << "\n";
//	initPlayer();
	movementSpeed = 8;
	level = lev;
	collectedScrews = 0;
//	orientation = DIRECTION_LEFT;
//	s = SoundHandler::getSoundHandler();
//	shooting = false;
//	reload_time = 40;
//	shoot_threshold = 0;
//	leben = 100.0f;
	roboto_bold.loadFromFile("assets/Roboto-Bold.ttf");
	tex_player.loadFromFile("assets/robot_ani.png");
	ani = new Animation();
	ani->setSpriteSheet(tex_player);
	ani->addFrame(sf::IntRect(0, 0, 80, 80));
	ani->addFrame(sf::IntRect(80, 0, 80, 80));
	animatedSprite = new AnimatedSprite(sf::seconds(0.2), true, false);
}


void Player::move()
{
	
	
	
	sf::Vector2f mV = moveVector*movementSpeed;
	
	//std::cout << "move\n" << mV.x << "  " <<mV.y<<"\n";
	
	
	
	// Bounding box of the player(after the move)
	sf::FloatRect* player_box = new sf::FloatRect(position + mV,sf::Vector2f(ROBOTSIZE,ROBOTSIZE));
	
	//check if hit exit
	if(level->isExit(position + mV,player_box))
	{
		resetLevel(new Level(level->getNextLevel()));
		std::cout << "Exit\n";
	}
	
	//check for wall Collisions
	mV = level->wallCollision(position,player_box,mV);
	
	// Update the player location
	sf::Vector2f new_location(position + mV);
	//std::cout << "pos: " << position.x << "," << position.y << "\n";
	

	//std::cout << "move\n" << mV.x << "  " <<mV.y<<"\n";

	
	
	// Check if new position is inside the game area
	if(new_location.x >= 0
		&& new_location.x + ROBOTSIZE <= level->getBounds().x
		&& new_location.y >= 0
		&& new_location.y + ROBOTSIZE <= level->getBounds().y)
	{
	//	std::cout<< collision << "\n";
		position = new_location; // Update location
	}
	collectedScrews += level->screwCollision(position,player_box);
	
	animatedSprite->update(sf::seconds(0.02));
	animatedSprite->setPosition(position);
}

void Player::setMovementDirection(int direction)
{
	
	switch(direction)
	{
		case DIRECTION_LEFT:
		moveVector = sf::Vector2f(-1,0);
		break;

		case DIRECTION_LEFT_UP:
		moveVector = sf::Vector2f(-1,-1);
		break;
		
		case DIRECTION_LEFT_DOWN:
		moveVector = sf::Vector2f(-1,1);
		break;

		case DIRECTION_RIGHT:
		moveVector = sf::Vector2f(1,0);
		break;
		
		case DIRECTION_RIGHT_UP:
		moveVector = sf::Vector2f(1,-1);
		break;
		
		case DIRECTION_RIGHT_DOWN:
		moveVector = sf::Vector2f(1,1);
		break;

		case DIRECTION_UP:
		moveVector = sf::Vector2f(0,-1);
		break;

		case DIRECTION_DOWN:
		moveVector = sf::Vector2f(0,1);
		break;

		default:
		moveVector = sf::Vector2f(0,0);
		break;
	}
}


sf::Vector2f Player::getPosition()
{
{'fraction_non_alphanumeric': 0.1834044922962688, 'fraction_numerical': 0.02338964173009096, 'mean_word_length': 4.116809116809117, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 31, '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': '6836592', 'n_tokens_mistral': 2273, 'n_tokens_neox': 2046, 'n_words': 370}