I coded up a simple 2D Camera for my HTML5 Canvas-Based Game Engine but I noticed the performance wasn't very good. So a lot of people suggested only rendering things that are shown by the camera but I haven't found anything that helps how to implement this.
I'm thinking about iterating over through all my game entities then checking their rendering positions, etc. But is this efficient?
if(renderCoords[i].x >= 0 &&
renderCoords[i].y >= 0 &&
renderCoords[i].x <= camera.getWidth()+camera.offset.x &&
renderCoords[i].y <= camera.getHeight()+camera.offset.y) {
//render
}
It's not tiled-based, just thought I mentioned that. Just doesn't seem clean to me.