Moving backgroud coordinate issue

I’m making a top down shooter game. The way I’m moving the player is by keeping him in the center of the screen and moving the background instead. But as I move it, the coordinates of the screen change continuously and I’m not able to detect the fixed coordinates for enemy object on screen.

you shouldn’t move the player at all.

just say image (player, width/2, 100); or so

the keys change playerX – and ++

the background image moves:

image(backgroundImg, 0 - playerX, 0);

Remark

Issue is more when the image has scrolled totally left or right and it’s on its end. Because then, the player moves and the background is fixed.

Chrisir