Here is my game prototype.
The code of the camera feature in this 2D game is achieved by having offsetting the object's positions depending on what arrow key was pressed from the user.
These objects(2 objects right now in the game ie: block and background image) are able to move by adding a KeyListener interface and overriding their keyPressed method with my own logic.
The problem is I need to do this for every object that appears on screen except for the character Spiderman in the future as well.
Any ideas on a better or an ideal code design to achieve the same effect in my 2D game? The game is coded in Java.
On a side note: I have a idea for a code design for the camera but the camera needs to know which object are on screen and offset their position by a certain amount when the user presses a key. Seems like I am overcomplicated the feature by coming up with this idea.
P.S. Is a camera feature even suppose to have access to the objects appearing on the screen of the game? Is that the camera job even suppose to have access to a list of game objects in the game?