I have a 2D array that is 30 across, 20 down. However, the viewport only paints 15 across and 10 down. I had a game like that originally and I’ve been trying to achieve something like this:

Here’s my fiddle: http://jsfiddle.net/sTr7q/
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here I’ve made a rudimentary viewport for you:
http://jsfiddle.net/kmHZt/
You have to keep track of the viewport X and Y (vX, vY) that represent where you are in the world at large. I also kept the viewport width and height as vars instead of hard coding them in.
You can use the arrow keys to change the viewport X and Y which will scroll the map, drawing only the correct tiles.
Hope that helps! Let me know if you have any questions!
EDIT: example of viewport moving with player: http://jsfiddle.net/kmHZt/10/