Confused about seemingly different (0, 0) point

Discussion in 'Programming' started by Baldi, Jul 13, 2019 at 4:52 PM.

  1. Baldi

    Baldi Member

    Joined:
    Feb 17, 2017
    Posts:
    50
    show2.png
    As you can see in the image, the grid and the tiles are misaligned (by exactly one pixel). The camera's X and Y position is exactly at (0, 0) when the screenshot was taken - the same place at which the first tile is drawn, so that makes sense. However, also the lines of the grid are coded to start at that (0, 0) location, but they seem to be starting at (1, 1). At first I just thought I did some little mistake when drawing the grid, however, the quarter circle that you can see in the top left corner in the picture is drawn at (-1, -1), so something is wrong...

    The view x and y coordinate is constantly clamped to 0 when the picture was taken, so it must be the right (0, 0) point (which makes sense since the tiles agree). But in a different script, executed just after drawing the tiles, I literally just say draw_circle(0, 0, 1, false) and it is one pixel misaligned!

    It is as if both codes have a different (0, 0) point... Can someone help?
     
  2. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    110
    Do you ever manipulate the transformation stack?
     
  3. Baldi

    Baldi Member

    Joined:
    Feb 17, 2017
    Posts:
    50
    Since I don't know what that is I do not. Im very sure by now that the grid is showing the true (0, 0) point, but there is just no way the camera is not at (0, 0) since that is where I put it... At the moment I have it "faked" by actually limiting the camera to (1, 1) and adding 1 to the x and y positions of the tiles, that makes it at least seem perfect.

    EDIT: Nevermind, I am now looking at mouse_x and mouse_y and it says that the true (0, 0) point is where the pink dot is in the picture. However it is drawn at (-1, -1)! Very confused...
     
    Last edited: Jul 13, 2019 at 5:45 PM
  4. Baldi

    Baldi Member

    Joined:
    Feb 17, 2017
    Posts:
    50
    Okay so I don't know why it took me so long but now I literally did this in a code:
    draw_set_color(c_red)
    draw_rectangle(0, 0, tile -1, tile -1, false); //tile is 16
    draw_set_color(c_yellow)
    draw_point(0, 0);

    and this is the result:
    show3.png
    the tiny yellow dot (sorry) is a point at (0, 0) and the red rectangle starts at (0, 0) as well. So this is normal? At first I thought, drawing a rectangle just ads an outline of 1 (since the rectangle also has to be tile -1, tile -1 to fit perfectly) but that wouldn't explain why the camera, positioned at (0, 0) is also exactly where the rectangle starts...

    EDIT: It basically looks like draw_line and draw_point just are wrong by +1 to both x and y
     
    Last edited: Jul 13, 2019 at 6:13 PM

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice