All two-dimensional games live and render within the concept of a visual two-dimensional grid. We interact with the grid using X,Y coordinates, where X represents horizontal and Y represents vertical.
Generally speaking, the point (0,0) is the bottom left of the game area (grid) on a computer screen. This can be within a window or full-screen. A grid is bound by Width and Height, and the highest X and Y values are the top-right corner of the grid. For example, if the grid was 800 (width) x 600 (height), the coordinates (800,600) would represent the top-right corner.
Actually, a two-dimensional game is often at least 2 grids. There's the rendered grid, i.e. visual output in a window or full-screen display. Then there's the virtual game space.
Coordinates are used to plot points on the grid. Think of each point (X,Y coordinate pair) on the grid as a pixel. The objects in our game, such as monsters, walls, scenery and flying objects, live in and move in a virtual space that, using math, is translated into points on the grid.
For example, I might be building a side-scrolling shooter. There will be a player, obstacles, opponents and bullets. These will all take up space in a game area that is much larger than the grid rendered on the screen. The game's "draw" loop is to make a picture (i.e., visual grid) from the state of all the objects in the virtual grid.
Generally speaking, the game logic should interact squarely with the virtual space, and the rendering (translation from virtual space to visual grid) should happen separately and as a last step.
One of the most helpful and versatile structures in game programming is the two-dimensional vector.
In the world of math, a vector is a quantity with both magnitude (size) and direction. Vectors are expressed as (X,Y).
How can a point on the screen represent size and direction, when it's just a dot? If we consider (X,Y) relative to the origin point on the grid, (0,0), then (X,Y) represent a line drawn out (size) at an angle (direction) relative to the origin.
For this reason, two-dimensional (X,Y) vectors can be used to describe position and also trajectory. For example, we can hold an object's current position as one vector, and its angle and speed as another vector.
Because a vector is expressed as (X,Y), it requires math to derive the angle and speed from the vector.
The notation (X,Y) represents Cartesian coordinates, i.e., a grid.
Angle and speed (or magnitude) represent Polar coordiantes, which deal with circles starting at an origin point, rather than a rectangular grid.
We use geometry to convert between vectors and polar coordinates.