Android [SOLVED] Camera screwing up graphic

Discussion in 'GameMaker Studio 2 Community Tech Support' started by I'm lost, Aug 12, 2019.

  1. I'm lost

    I'm lost Member

    Joined:
    Jul 11, 2018
    Posts:
    19
    Hello everyone,
    I'm so sick of this problem and 'Ive been trying to solve it for such a long time, that I've decided to look for help somewhere else.

    I'm talking about cameras. In all of my games I have one big problem with cameras. And that is smooth camera movement to player. I have this simple easing camera movement code:
    Code:
    camera.x = (target.x - camera.x)/20;
    camera.y = (target.y - camera.y)/20;
    
    At the first sight, it works really well, the camera is smoothly following player. But then I noticed when camera is just few pixels from it's target, and it's x and y position is gaining high amount of decimal places, it starts to deform every sprite and background, that room contains. I tried rounding this x and y position, this reduces the problem a bit, but i still can see little deformation.

    But it's not just with camera easing, it also happens with phones, which has much smaller display than PC.
    Let's have an example:

    I have my player figure sprite
    This is PC outcome
    upload_2019-8-12_12-31-45.png


    And this is Android's
    upload_2019-8-12_12-32-22.png



    It's really demoralizing when I test something on computer and it looks pretty, then I try it on phone and it looks like pile of sh*t.

    It has to do something with display size and device responsivity, when I had this problem with other games, I just scaled every sprite and room up to 4 times!! It looked good, but then my tiny 8 bit arcade game had almost 100MB, mobile game just can't be that big.
    My another nooby solution was to turn on pixel-interpolation, but that makes everything blurry.

    This problem makes me so desperate that I'm starting to consider about abadoning Gamemaker, because it's just ruining all of my games.

    I want some more advanced solution. Please, help me, I would really appreciate it!!
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,306
    Best practices for emulating pixel graphics on modern systems:
    • Draw everything at integer positions, not just the camera. Otherwise their offsets relative to the camera would still be a fractional value. That causes pixels to clip off with interpolation off or blur up with interpolation on.
    • Keep pixel interpolation off. The blurring is what interpolation is supposed to do between pixels.
    • Scale using the view instead of manually resizing graphical resources, and even then only by integer amounts (e.g. 256x144 view with a port of 1024x576, 480x270 view with a port of 1920x1080, etc.).
    • Always respect the aspect ratio and never just use full scale.
    It's not GM's fault that you get poor results by failing to treat pixel graphics as a discrete-value environment. And if you think just changing engines is enough without adapting your technique, the grass isn't any greener on the other side.
     
    I'm lost likes this.
  3. I'm lost

    I'm lost Member

    Joined:
    Jul 11, 2018
    Posts:
    19

    Thanks for your advice, now it's a bit more clear to me

    Just one question:
    How am I supposed to scale, if I want to make something just a bit bigger, like these menu buttons I made
    https://giphy.com/gifs/KFtXzYpvJDqT...um=landing&utm_campaign=Media Links&utm_term=

    You can see that every time I click on that button, it gets dark and scales up a bit (1.1), is that the right solution? Because I have the same problem as with the player sprite, that it has deformed text on phone:
    MOBILE.png



    And by the way,
    I never said it's GM's fault, I blame myself, not the engine. It was just one of the options to move on, if I wouldn't find ANY solution.
     
  4. I'm lost

    I'm lost Member

    Joined:
    Jul 11, 2018
    Posts:
    19
    Finally got the solution!!

    The parameter I was looking for was application surface size. When I do surface_resize(application_surface, x1, x2) and raise the size, it removes basically every camera lagging I've seen before the change (I dont even have to round the position).

    Of course respecting the aspect ration and scaling was also the part of the problem, I simply scaled everything by 1.5 and that obviosly didnt look good.
     
  5. curato

    curato Member

    Joined:
    Jun 30, 2016
    Posts:
    312
    can't you just do something like this to keep your stuff pixel perfect?
    Code:
    camera.x += round((target.x - camera.x)/20);
    camera.y += round((target.y - camera.y)/20);
    you may also want to consider having a threshold of if you are within a certain small distance just snap to the target to avoid any weird wiggle back and forth
     

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