I have a question about implementing a viewport/camera, I am playing around with the HTML5 canvas and have started to implement a tile engine. At the moment it is massively inefficient, I have a 2d array 100x100 and each frame my code is looping through the whole thing (very bad i know). I would like to use a viewport/camera to determine which area of the area in being view and reduce the rendering loop.
here is an example, I haven’t added the camera offset yet because I’m not sure how
here is a link to it
if anyone could give me some advice or point me in right direction that would be great.