How to check tile in front of player

I’m working on my pacman game now, i’ve got it setup to detect which tiles are suppose to be blocked which ive added to an array list. I’m using ShapeRenderer to show which tiles are blocked and which aren’t…Now i’m having trouble deciding which tile is in front of the player to see if it’s blockable…

This is my map class


package com.psillidev.pacman1;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.maps.tiled.*;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Array;

public class Map {
TiledMap tiledMap;
public TiledMapTileLayer layer;
int[] tileLayer = {0} ;
int[] collisionLayer;

Cell tileCell;

Array<Rectangle> blockedTiles = new Array<Rectangle>();

public OrthogonalTiledMapRenderer renderer;
float unitScale;

	public Map() {
		float unitScale = 1/16f;
		
		tiledMap = new TmxMapLoader().load("data/pactest.tmx");
		
		layer = (TiledMapTileLayer) tiledMap.getLayers().get(1);
		renderer = new OrthogonalTiledMapRenderer(tiledMap, 1/16f);
		
		setBlockedTiles();
	}
	
	void setBlockedTiles() {
		for (int y = 0;y < layer.getHeight();y++ ) {
			for (int x = 0; x < layer.getWidth();x++) {
				Cell cell = layer.getCell(x, y);
				if (layer.getCell(x,y)!=null) {
				Rectangle tempRect = new Rectangle(x*16,y*16,16,16);
				
				
				
				blockedTiles.add(tempRect);
				
				//System.out.println(blockedTiles.size);
				
				if (layer.getCell(x, y)==null) continue;
				
				}
			}
				
		}
	
	}
	
	public TiledMap getMap() {
		return tiledMap;
	}
	
	public float getScale() {
		return unitScale;
	}
	
	public Cell getCell(int x, int y) {
		return layer.getCell(x, y);
	}
	
	public Array<Rectangle> getBlockedTiles() {
		return blockedTiles;
	}
	
	public TiledMapTileLayer getLayer() {
		return layer;
	}
	
	public void render(OrthographicCamera camera) {
		renderer.setView(camera);
		//renderer.renderTileLayer(layer);
		//renderer.render();
		renderer.render(tileLayer);
		
		System.out.println(blockedTiles.size);
		
		ShapeRenderer rend = new ShapeRenderer(); 
		rend.begin(ShapeType.Line);
		for (int t = 0;t < blockedTiles.size;t++) {
		rend.rect(blockedTiles.get(t).x, blockedTiles.get(t).y, blockedTiles.get(t).width, blockedTiles.get(t).height); 
		System.out.println("Tile: " + t + " X: " + blockedTiles.get(t).x + " Y: " + blockedTiles.get(t).y + " Width: " + blockedTiles.get(t).width + " Height: " + blockedTiles.get(t).height);
		}
		rend.end();
		
	}
	
}

This is my player class where i’m moving the pacman…


public void move(Map map) {
		
		//for (int b = 0;b < map.getBlockedTiles().size;b++) {
		//	Rectangle tempRect = map.getBlockedTiles().get(b);
		if (direction == 0) {
			
			setY(getY() + (int)(Gdx.graphics.getDeltaTime() + 3));
		}
		
		if (direction ==1) {
			setX(getX() + (int)(Gdx.graphics.getDeltaTime() + 3));
		}
		
		if (direction ==2) {
			setY(getY() - (int)(Gdx.graphics.getDeltaTime() + 3));
		}
		
		if (direction ==3) {
			setX(getX() - (int)(Gdx.graphics.getDeltaTime() + 3));
		}
		//}
		}

I’ve commented a few lines out while playing with the code…I’m stumped.