Couple questions about camera and movement on 2d tiled game

Hey guys

I’m working on a 2d top-down tiled game. I’m doing it to learn but will probably turn it into a another farming game similar to harvest moon. I’ve got the map loaded and character displayed and all that, but i’m having a little bit of trouble with a couple things.

I’ve got my camera set up and it follows the player around…but i’m having trouble getting it to stop scrolling when the player gets near the end of the map. Below is my code. I’ve only done the x axis and i’ve just been playing with the values.


public void render() {		
		//handleInput();
		
		GL10 gl = Gdx.graphics.getGL10();
		gl.glClearColor(0, 0, 0, 1);
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		gl.glViewport((int)glViewport.x, (int)glViewport.y, (int)glViewport.width,(int) glViewport.height);
		
		map.renderer.setView(camera);
		map.render();
		
		map.renderer.getSpriteBatch().setProjectionMatrix(camera.combined);
		map.renderer.getSpriteBatch().begin();
		
		
		
		mainPlayer.Draw((SpriteBatch) map.renderer.getSpriteBatch());
		
		map.renderer.getSpriteBatch().end();

//move camera to follow player	
	if (mainPlayer.getPosition().x >= 15 && mainPlayer.getPosition().x <= 30) {
		camera.position.x = mainPlayer.getPosition().x;
		
		}
		System.out.println(camera.position.x);
		camera.position.y = mainPlayer.getPosition().y;
		
		camera.update();
		camera.apply(gl);
		
	}

below is a picture of what i’m talking about. I don’t want the black area to be seen.

http://s21.postimg.org/wt6tgs7bn/cameratest.jpg

I’ve been searching around a bit and I know how i’m going to do my collision detection. I’m going to do it the same way dermetfan does it in his video tutorial. How would be the best way to keep the player on the map? Just do a check to make sure the cell isn’t null? Also, i’m a bit confused as how to warp to the next map when the player hits the edges of the map.

Also, this is more of an opinion from you guys, but what should I do next? I know this is a pretty dumb question, but i’m doing this to learn as well as turning it into a game…I thought about adding particle effects next because they interest me. I still have quite a few things to implement though…time system, gui, tools, and NPC’s which I still have no clue how i’m going to do.