3
\$\begingroup\$

I am noob to game development, and while using a simple graphics library in Python to make a 2D game, I noticed that the coordinate system of the library had its upper left corner as (0,0), whereas conventionally (at least in math) the lower left corner is set as (0,0).

I want to keep the world space in my physics calculations, but want to map the world space coordinates into the screen space. Furthermore, I want the world space sizes to be a scale of 10 larger than the screen space sizes.

In terms of programming methodology, how should I go about doing this in the most modular fashion?

\$\endgroup\$
3
  • 3
    \$\begingroup\$ Conventionally this is done with a view-projection matrix to map world coordinates to screenspace. Are existing questions about view-projection matrices not providing what you need for your case? \$\endgroup\$
    – DMGregory
    Nov 3, 2017 at 2:45
  • \$\begingroup\$ @DMGregory: Most view-projection questions are about mapping 3D to 2D and not mapping 2D to 2D, but I guess the concept is the same: build a matrix that can transform a vector from one space to the other. This answer to From screen space to world space for a 2D game is the closes to spelling out "how", but excludes the rotation aspect. \$\endgroup\$
    – idbrii
    Jun 9 at 21:22
  • \$\begingroup\$ Hint: 2D is just 3D with z=0, then all the rest of the math works identically. You can then remove any terms that get zeroed out. \$\endgroup\$
    – DMGregory
    Jun 10 at 0:25

1 Answer 1

-1
\$\begingroup\$

Would something like

http://www.pentadact.com/2015-01-27-help-me-with-a-trigonometry-problem-for-heat-signature/

Help? He has the solution he found a bit further down in the post.

I'll assume you don't need rotation, because you don't directly mention it in your post.

Actually, assuming that, it just looks like you need to define a world 10 times larger than your screen, and then transform the screen across it. Any objects on screen are at the screen coordinates of

(actualX-screenXTransform,actualY-screenYTransform)

Unless I'm grossly misunderstanding something, that should be it.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ This is a link only answer. Although it can help the OP fix their problem, if the link gets taken down, your answer will be completely useless for future users. Can you edit your answer and provide the actual information for the question to be answered? Not that you can leave the link there, just that it should not be the focus of the answer. \$\endgroup\$
    – Vaillancourt
    Nov 3, 2017 at 23:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .