0

I have looked at the pygame documentation, but it's not clear from it why blitting an image and subtracting the camera coordinates from it works creating the effect of a moving camera.

Example (assuming pygame initialization is all done)

screen.blit(background, (0-posX,0 - posY)
screen.blit(player, (playerX - posX, playerY - posY)

Looping through this produces the desired effect of moving the camera around. But, I would have thought since the screen is defined with (0,0) being at the top of the screen that I would need to add camera coordinates rather than subtract them.

Can somebody explain what I'm missing in how the blit function works? It seems counter intuitive to me.

Rethipher
  • 336
  • 1
  • 14
  • I don't understand how this is useful. Your problem has been solved. The `blit` function simply draws the Surface at the specified coordinates. Am I misunderstanding the question? – Galen Nare Mar 01 '16 at 23:19
  • It's a simple enough example, but since I don't understand how it works, more complex problems will lose me, so I would like to understand it when I'm doing more complex things like trying to add grids of objects and map that can either be collided with or not. – Rethipher Mar 01 '16 at 23:30
  • Try giving a specific problem. The information that can be given is on the docs. You know what information you have already. Simply do a Google search for extended information on the `blit()` function. – Galen Nare Mar 02 '16 at 00:15
  • I understand you want to be helpful, but I've already tried googling it and didn't find anything. That's why I'm asking for more detailed information here, which is my specific question, more detailed information about where blit starts drawing the image, i.e. what coordinate is considered zero, because it doesn't appear to be (0,0) at the top left corner as I had originally assumed. – Rethipher Mar 02 '16 at 00:21
  • What are you confused about? Everything that gets blitted outside the screen will NOT appear on the screen. That's what your camera is for. – Fredrik Mar 02 '16 at 07:44

0 Answers0