<commit_before>#include "mainwindow.h"
#include <cmath>

/**
 * Performs appropriate actions every time timer is called.
 *
 
 grab keyboard x error bad window
 merrick said it seems like an issue that you can't fix with my code, but rather something about 
 qt or the vm
 
 get rid of player image, set player coordinates, set explosion image to that location,
 recreate player
 
 * @return nothing
 */
void MainWindow::handleTimer()
{
	bg->scroll(0, WINDOW_MAX_X);
	bg2->scroll(0, WINDOW_MAX_X);
	
	c->move();
	a->move();
	d->move();
	mb->move();
	t->move();
	moveCount++;

	
	
	/**
	if(mousePressed)
	{
		p->moveUp(game_min_y);
	}
	else if(moveCount == 15)
	{
		moveCount = 0;
		p->moveDown(game_min_y);
	}
	**/
	
	
}

/**
 * Function is called every time a tile is clicked.
 *
 * @param e Mouse event
 * @return nothing
 */
void MainWindow::keyPressEvent(QKeyEvent *e)
{
	//setFocusPolicy(Qt::StrongFocus);
	//std::cout<<"key";
	switch(e->key())
	{
		case Qt::Key_Up:
			std::cout<<"Up\n";
			p->moveUp(game_min_y);
			p->moveUp(game_min_y);
			p->moveUp(game_min_y);
			break;
		case Qt::Key_Down:
			std::cout<<"Down\n";
			p->moveDown(game_max_y);
			p->moveDown(game_max_y);
			p->moveDown(game_max_y);
			break;
		default:
			QWidget::keyPressEvent(e);
	}
	
	/**
	if(e->key() == Qt::Key_Q)
	{
		std::cout<<"Up\n";
		//p->moveUp();
	}
	else if(e->key() == Qt::Key_Down)
	{
		std::cout<<"Down\n";
		//p->moveDown();
	}
	**/
}

 
 
/**
 * Pauses the app.
 *
 * @return nothing
 */
void MainWindow::pauseApp()
{
	//p->moveDown(game_max_y);
	p->moveUp(game_min_y);
/**
	if(timer->isActive())
	{
		timer->stop();
	}
	else
	{
		timer->start();
	}
	**/
}

/**
 * Sets up the game every time the start button is pressed.
 *
 * @return nothing
 */
void MainWindow::startGame()
{
	userName = userNameLine->text();
	if(userName != "")
	{
		gameStarted = true;
		nameLine->setText(userName);
		userNameLine->setText("");
		errors->setText("");
		livesLine->setText("3");
		pointsLine->setText("0");
		popupView->close();
		userName = userNameLine->text();
		
		createBackground();
		playerImage = new QPixmap("images/astronaut.jpg");
		*playerImage = playerImage->scaledToHeight(70);
		p = new Player(playerImage);
		timer->start();
		//p->setPos(500, 500);
	
		scene->addItem(p);
		
		c = new Coin(coinImage, WINDOW_MAX_X - 50, 300, this);
		scene->addItem(c);
		
		a = new Alien(alienImage, WINDOW_MAX_X - 75, 400, this);
		scene->addItem(a);
		
		d = new Doctor(doctorImage, WINDOW_MAX_X, WINDOW_MAX_Y -100, this);
		scene->addItem(d);
		
		mb = new MoneyBag(moneybagImage, WINDOW_MAX_X, 250, this);
		scene->addItem(mb);
		
		t = new Turtle(turtleImage, WINDOW_MAX_X, WINDOW_MAX_Y-45, this);
		scene->addItem(t);
		
		this->grabKeyboard();
		
	}
	else
	{
		errorsExists = true;
		errors->setText("Enter a name above!");
	}
}

void MainWindow::callPopup()
{
	popupView->show();
}

void MainWindow::cancelPopup()
{
	userNameLine->setText("");
	errors->setText("");
	popupView->close();<commit_msg>Trying to debug error messages<commit_after>#include "mainwindow.h"
#include <cmath>

/**
 * Performs appropriate actions every time timer is called.
 *
 
 grab keyboard x error bad window
 merrick said it seems like an issue that you can't fix with my code, but rather something about 
 qt or the vm
 
 get rid of player image, set player coordinates, set explosion image to that location,
 recreate player
 
 * @return nothing
 */
void MainWindow::handleTimer()
{
	bg->scroll(0, WINDOW_MAX_X);
	bg2->scroll(0, WINDOW_MAX_X);
	
	c->move();
	a->move();
	d->move();
	mb->move();
	t->move();
	moveCount++;

	
	
	/**
	if(mousePressed)
	{
		p->moveUp(game_min_y);
	}
	else if(moveCount == 15)
	{
		moveCount = 0;
		p->moveDown(game_min_y);
	}
	**/
	
	
}

/**
 * Function is called every time a tile is clicked.
 *
 * @param e Mouse event
 * @return nothing
 */
void MainWindow::keyPressEvent(QKeyEvent *e)
{
	//setFocusPolicy(Qt::StrongFocus);
	//std::cout<<"key";
	switch(e->key())
	{
		case Qt::Key_Up:
			std::cout<<"Up\n";
			p->moveUp(game_min_y);
			p->moveUp(game_min_y);
			p->moveUp(game_min_y);
			break;
		case Qt::Key_Down:
			std::cout<<"Down\n";
			p->moveDown(game_max_y);
			p->moveDown(game_max_y);
			p->moveDown(game_max_y);
			break;
		default:
			QWidget::keyPressEvent(e);
	}
	
	/**
	if(e->key() == Qt::Key_Q)
	{
		std::cout<<"Up\n";
		//p->moveUp();
	}
	else if(e->key() == Qt::Key_Down)
	{
		std::cout<<"Down\n";
		//p->moveDown();
	}
	**/
}

 
 
/**
 * Pauses the app.
 *
 * @return nothing
 */
void MainWindow::pauseApp()
{
	//p->moveDown(game_max_y);
	p->moveUp(game_min_y);
/**
	if(timer->isActive())
	{
		timer->stop();
	}
	else
	{
		timer->start();
	}
	**/
}

/**
 * Sets up the game every time the start button is pressed.
 *
 * @return nothing
 */
void MainWindow::startGame()
{
	userName = userNameLine->text();
	if(userName != "")
	{
		gameStarted = true;
		nameLine->setText(userName);
		userNameLine->setText("");
		errors->setText("");
		livesLine->setText("3");
		pointsLine->setText("0");
		popupView->close();
		userName = userNameLine->text();
		
		createBackground();
		playerImage = new QPixmap("images/astronaut.jpg");
		*playerImage = playerImage->scaledToHeight(70);
		p = new Player(playerImage);
		timer->start();
		//p->setPos(500, 500);
	
		scene->addItem(p);
		
		c = new Coin(coinImage, WINDOW_MAX_X - 50, 300, this);
		scene->addItem(c);
		
		a = new Alien(alienImage, WINDOW_MAX_X - 75, 400, this);
		scene->addItem(a);
		
		d = new Doctor(doctorImage, WINDOW_MAX_X, WINDOW_MAX_Y -100, this);
		scene->addItem(d);
		
		mb = new MoneyBag(moneybagImage, WINDOW_MAX_X, 250, this);
		scene->addItem(mb);
		
		t = new Turtle(turtleImage, WINDOW_MAX_X, WINDOW_MAX_Y-45, this);
		scene->addItem(t);
		
		this->grabKeyboard();
		
	}
	else
	{
		errorsExists = true;
		errors->setText("Enter a name above!");
	}
}

void MainWindow::callPopup()
{
	popupView->grabKeyboard();
	popupView->show();
}

void MainWindow::cancelPopup()
{
	userNameLine->setText("");
	errors->setText("");
	popupView->close();
{'fraction_non_alphanumeric': 0.1824357912178956, 'fraction_numerical': 0.011267605633802818, 'mean_word_length': 3.715625, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 102, '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': '1821367', 'n_tokens_mistral': 2591, 'n_tokens_neox': 2327, 'n_words': 468}