<commit_before>package jump;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.Timer;

public class Game implements ActionListener, KeyListener{

	public static Game jumper;
	public final int WIDTH = 800, HEIGHT = 800;
	public Render renderObject;
	public Rectangle hero;
	public ArrayList<Rectangle> columns;
	public int ticks, jump, score;
	public boolean gameOver, started;
	public Random rand;

	public Game(){
		JFrame jframe = new JFrame();
		Timer timer = new Timer(20, this);

		renderObject = new Render();
		rand = new Random();
		hero = new Rectangle(WIDTH - 750, HEIGHT - 140, 20, 20);
		columns = new ArrayList<Rectangle>();

		jframe.add(renderObject);
		jframe.setTitle("    JUMPER      ");
		jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jframe.setSize(WIDTH, HEIGHT);
		jframe.setLocationRelativeTo(null);
		jframe.addKeyListener(this);
		jframe.setResizable(false);
		jframe.setVisible(true);

		addColumn(true);
		addColumn(true);
		addColumn(true);
		addColumn(true);

		timer.start();
	}

	public void addColumn(boolean start){
		int space = 800;
		int width = 20 + rand.nextInt(150);
		int height = 50 + rand.nextInt(100);

		if (start){
			columns.add(new Rectangle(WIDTH + width + columns.size() * 300, HEIGHT - height - 120, width, height));
			columns.add(new Rectangle(WIDTH + width + (columns.size() - 1) * 300, 0, width, HEIGHT - height - space));
		}
		else
		{
			columns.add(new Rectangle(columns.get(columns.size() - 1).x + 600, HEIGHT - height - 120, width, height));
			columns.add(new Rectangle(columns.get(columns.size() - 1).x, 0, width, HEIGHT - height - space));
		}
	}

	public void paintColumn(Graphics g, Rectangle column){
		g.setColor(Color.red);
		g.fillRect(column.x, column.y, column.width, column.height);
	}

	public void jump(){
		if (gameOver){
			hero = new Rectangle(WIDTH - 750, HEIGHT - 140, 20, 20);
			columns.clear();
			jump = 0;
			score = 0;

			addColumn(true);
			addColumn(true);
			addColumn(true);
			addColumn(true);

			gameOver = false;
		}

		if (!started){
			started = true;
		}
		else if (!gameOver && hero.y == HEIGHT - 140)
		{
			if (jump > 0){
				jump = 0;
			}

			jump -= 35;
		}
	}

	public void actionPerformed(ActionEvent e){
		int speed = 12;

		ticks++;   

		if (started){
			for (int i = 0; i < columns.size(); i++){
				Rectangle column = columns.get(i);

				column.x -= speed;
			}

			if (ticks % 2 == 0 && jump < 15){
				jump += 5;
			}

			for (int i = 0; i < columns.size(); i++){
				Rectangle column = columns.get(i);

				if (column.x + column.width < 0){
					columns.remove(column);

					if (column.y == 0){
						addColumn(false);
					}
				}
			}

			hero.y += jump;

			for (Rectangle column : columns){
				if (column.y == 0 && hero.x + hero.width / 2 > column.x + column.width / 2 - 3 && hero.x + hero.width / 2 < column.x + column.width / 2 + 10){
					score++;
				}

				if (column.intersects(hero)){
					gameOver = true;

					if (hero.y <= column.x){
						hero.y = column.x - hero.width;

					}
					else
					{
						if (column.y != 0){
							hero.y = column.y - hero.height;
						}
						else if (hero.y < column.height){
							hero.y = column.height;
						}
					}
				}<commit_msg>Jumper Game<commit_after>package jump;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.Timer;

public class Game implements ActionListener, KeyListener{

	public static Game jumper;
	public final int WIDTH = 800, HEIGHT = 800;
	public Render renderObject;
	public Rectangle hero;
	public ArrayList<Rectangle> columns;
	public int ticks, jump, score;
	public boolean gameOver, started;
	public Random rand;

	public Game(){
		JFrame jframe = new JFrame();
		Timer timer = new Timer(20, this);

		renderObject = new Render();
		rand = new Random();
		hero = new Rectangle(WIDTH - 750, HEIGHT - 140, 20, 20);
		columns = new ArrayList<Rectangle>();

		jframe.add(renderObject);
		jframe.setTitle("    JUMPER      ");
		jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jframe.setSize(WIDTH, HEIGHT);
		jframe.setLocationRelativeTo(null);
		jframe.addKeyListener(this);
		jframe.setResizable(false);
		jframe.setVisible(true);

		addColumn(true);
		addColumn(true);
		addColumn(true);
		addColumn(true);

		timer.start();
	}

	public void addColumn(boolean start){
		int space = 800;
		int width = 20 + rand.nextInt(150);
		int height = 50 + rand.nextInt(100);

		if (start){
			columns.add(new Rectangle(WIDTH + width + columns.size() * 300, HEIGHT - height - 120, width, height));
			columns.add(new Rectangle(WIDTH + width + (columns.size() - 1) * 300, 0, width, HEIGHT - height - space));
		}
		else
		{
			columns.add(new Rectangle(columns.get(columns.size() - 1).x + 600, HEIGHT - height - 120, width, height));
			columns.add(new Rectangle(columns.get(columns.size() - 1).x, 0, width, HEIGHT - height - space));
		}
	}

	public void paintColumn(Graphics g, Rectangle column){
		g.setColor(Color.red);
		g.fillRect(column.x, column.y, column.width, column.height);
	}

	public void jump(){
		if (gameOver){
			hero = new Rectangle(WIDTH - 750, HEIGHT - 140, 20, 20);
			columns.clear();
			jump = 0;
			score = 0;

			addColumn(true);
			addColumn(true);
			addColumn(true);
			addColumn(true);

			gameOver = false;
		}

		if (!started){
			started = true;
		}
		else if (!gameOver && hero.y == HEIGHT - 140)
		{
			if (jump > 0){
				jump = 0;
			}

			jump -= 35;
		}
	}

	public void actionPerformed(ActionEvent e){
		int speed = 12;

		ticks++;   

		if (started){
			for (int i = 0; i < columns.size(); i++){
				Rectangle column = columns.get(i);

				column.x -= speed;
			}

			if (ticks % 2 == 0 && jump < 15){
				jump += 5;
			}

			for (int i = 0; i < columns.size(); i++){
				Rectangle column = columns.get(i);

				if (column.x + column.width < 0){
					columns.remove(column);

					if (column.y == 0){
						addColumn(false);
					}
				}
			}

			hero.y += jump;

			for (Rectangle column : columns){
		if (column.y == 0 && hero.x + hero.width / 2 > column.x + column.width / 2 - 3 && hero.x + hero.width / 2 < column.x + column.width / 2 + 10){
					score++;
				}

				if (column.intersects(hero)){
					gameOver = true;

					if (hero.y <= column.x){
						hero.y = column.x - hero.width;

					}
					else
					{
						if (column.y != 0){
							hero.y = column.y - hero.height;
						}
						else if (hero.y < column.height){
							hero.y = column.height;
						}
					}
				}
{'fraction_non_alphanumeric': 0.14705882352941177, 'fraction_numerical': 0.02569960022844089, 'mean_word_length': 2.9090401785714284, 'pattern_counts': {'":': 0, '<': 21, '<?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': '6041030', 'n_tokens_mistral': 3043, 'n_tokens_neox': 2387, 'n_words': 623}