<commit_before>package game;

import entities.Entity;
import entities.EntityFactory;
import gen.Generator;
import gen.environment.Ground;
import gen.environment.Map;
import javafx.scene.canvas.GraphicsContext;
import static game.State.*;

import engine.Tileset;

public class World {

	/** SINGELTON */
	private static World singleton;

	// class components
	private Generator gen;
	private Map map;
	private EntityFactory fac;
	private Game game;

	// variables
	private int size = 5;
	private int offsetX, offsetY, viewSizeX, viewSizeY;


	public static World getWorld() {
		if (singleton == null) {

			singleton = new World();
		}
		return singleton;
	}

	private World() {
		gen = new Generator(350, 225);
		map = gen.newLevel();
		fac = EntityFactory.getFactory();
		game = Game.getGame();

		updateView();
	}

	public Map getMap() {
		return this.map;
	}

	public void setSize(int size) {
		this.size = size;

	}

	public void tick(double elapsedTime) {
		fac.getPlayer().tick(elapsedTime);
		for (Entity mob : fac.getMobs()) {
			mob.tick(elapsedTime);
		}
		fac.smartDeletNow();

		if (Events.getEvents().isESC()) {
			game.setState(MENU);
		}
		if (Events.getEvents().isM()) {
			if (game.getState() == MAP) {
				Entity player = EntityFactory.getFactory().getPlayer();

				game.setState(VIEW);
				updateView();
				initView(player.getX(), player.getY());
			} else {
				game.setState(MAP);
				updateView();
			}
			Events.getEvents().clear();
		}
	}

	public void render(GraphicsContext gc) {
		// set color and render ground tile
		// if (Game.getGame().getState() != MAP)
		for (int x = 0; x < viewSizeX; x++) {
			for (int y = 0; y < viewSizeY; y++) {
				if (map.getGround(x + offsetX, y + offsetY) != Ground.WALL) {
					int[] tile = map.getTileNumber(x + offsetX, y + offsetY);
					gc.drawImage(Tileset.getTileset().tileset, (16 + 1) * tile[0], (16 +1) * tile[1], 16, 16, x * size, y * size, 32, 32);
				} else {
					gc.setFill(Game.getColor(map.getGround(x + offsetX, y + offsetY)));
					gc.fillRect(x * size, y * size, size, size);
					
				}
			}
		}

		 for (Entity mob : fac.getMobs()) {
		 mob.render(gc, size, offsetX, offsetY);
		 }
		 fac.getPlayer().render(gc, size, offsetX, offsetY);
	}

	public void updateView() {
		// set size parameters
		if (Game.getGame().getState() == MAP) {
			size = 4;
		} else {
			size = 32;
		}

		// set view size and be sure to be smaller than the map
		viewSizeX = Math.min(1400 / size, map.getN());
		viewSizeY = Math.min(900 / size, map.getM());

		checkOffset();
	}
<commit_msg>no scaling on size with tiles<commit_after>package game;

import entities.Entity;
import entities.EntityFactory;
import gen.Generator;
import gen.environment.Ground;
import gen.environment.Map;
import javafx.scene.canvas.GraphicsContext;
import static game.State.*;

import engine.Tileset;

public class World {

	/** SINGELTON */
	private static World singleton;

	// class components
	private Generator gen;
	private Map map;
	private EntityFactory fac;
	private Game game;

	// variables
	private int size = 5;
	private int offsetX, offsetY, viewSizeX, viewSizeY;


	public static World getWorld() {
		if (singleton == null) {

			singleton = new World();
		}
		return singleton;
	}

	private World() {
		gen = new Generator(350, 225);
		map = gen.newLevel();
		fac = EntityFactory.getFactory();
		game = Game.getGame();

		updateView();
	}

	public Map getMap() {
		return this.map;
	}

	public void setSize(int size) {
		this.size = size;

	}

	public void tick(double elapsedTime) {
		fac.getPlayer().tick(elapsedTime);
		for (Entity mob : fac.getMobs()) {
			mob.tick(elapsedTime);
		}
		fac.smartDeletNow();

		if (Events.getEvents().isESC()) {
			game.setState(MENU);
		}
		if (Events.getEvents().isM()) {
			if (game.getState() == MAP) {
				Entity player = EntityFactory.getFactory().getPlayer();

				game.setState(VIEW);
				updateView();
				initView(player.getX(), player.getY());
			} else {
				game.setState(MAP);
				updateView();
			}
			Events.getEvents().clear();
		}
	}

	public void render(GraphicsContext gc) {
		// set color and render ground tile
		// if (Game.getGame().getState() != MAP)
		for (int x = 0; x < viewSizeX; x++) {
			for (int y = 0; y < viewSizeY; y++) {
				if (map.getGround(x + offsetX, y + offsetY) != Ground.WALL) {
					int[] tile = map.getTileNumber(x + offsetX, y + offsetY);
					gc.drawImage(Tileset.getTileset().tileset, (16 + 1) * tile[0], (16 +1) * tile[1], 16, 16, x * size, y * size, size, size);
				} else {
					gc.setFill(Game.getColor(map.getGround(x + offsetX, y + offsetY)));
					gc.fillRect(x * size, y * size, size, size);
					
				}
			}
		}

		 for (Entity mob : fac.getMobs()) {
		 mob.render(gc, size, offsetX, offsetY);
		 }
		 fac.getPlayer().render(gc, size, offsetX, offsetY);
	}

	public void updateView() {
		// set size parameters
		if (Game.getGame().getState() == MAP) {
			size = 4;
		} else {
			size = 16;
		}

		// set view size and be sure to be smaller than the map
		viewSizeX = Math.min(1400 / size, map.getN());
		viewSizeY = Math.min(900 / size, map.getM());

		checkOffset();
	}

{'fraction_non_alphanumeric': 0.15300546448087432, 'fraction_numerical': 0.01288056206088993, 'mean_word_length': 3.2077175697865354, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '5481952', 'n_tokens_mistral': 2090, 'n_tokens_neox': 1779, 'n_words': 465}