GMS 2 Question about room size and pixelated art

Discussion in 'Programming' started by Suzaku, Mar 13, 2019.

  1. Suzaku

    Suzaku Member

    Joined:
    Jan 27, 2019
    Posts:
    44
    I want to put a pixel-art ground and background in my room and so I changed the room size to something near 300x119(I was using 1024x768 before) to match the art size, and since then the character is moving too fast EVEN if I set the character's speed to 1, so I put 0.1 and this seems to have fixed it but now the room camera seems to move pixel by pixel and this creates a weird effect like getting stuck at each step. The whole problem can be fixed if I just set back the room size to 1024x768 and resize all my arts to make them bigger, but that sounds like a garbage way to do this. I want to know: how to deal with the room size when the art is pixelated like that?

    Here is a example of art size that I want to use:
    upload_2019-3-13_14-46-30.png
    125x119

    PS: I usually just draw my arts on aseprite and then I put them into gamemaker in the Assets layer and then in a instance layer I put a fake flat ground object behind the assets. I hope that wont cause any troubles too.
     
    Last edited: Mar 13, 2019
  2. curato

    curato Member

    Joined:
    Jun 30, 2016
    Posts:
    179
    as far as the PS. I you have art you want to be a background and doesn't do anything I would just drop the art in a background layer instead. That could be your issue if that object is trying to refresh behind your other objects.
     
    Suzaku likes this.
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,541
    Odd, because even in NES games the characters move close to 1 pixel per step. So I wonder if your code is increasing x two or more times each step...GM allows sub-pixel movement by default, which can cause all sorts of minor annoyances, such as blurring and stuttering.

    For sub-pixel movement I have second pair of movement variables: hsp_f and vsp_f. Then my movent code is basically
    Code:
    hsp_f+=hsp;
    while hsp_f<0 {
       hsp_f++;
       x--;
    }
    while hsp_f>1 {
       hsp_f--;
       x++;
    }
    
    This keeps x at an integer at all times without affecting movement speed. As a result, the camera will stay at an integer at all times. Everything will be at an integer. People complain this looks jittery to them, but they are either doing something wrong or they should not be doing pixel art.
     
    Suzaku likes this.
  4. Suzaku

    Suzaku Member

    Joined:
    Jan 27, 2019
    Posts:
    44
    I guess if my object moves at any speed lower than 1, it will move at a speed that is actually lower than 60 fps, like if I put hspeed to 0.5, it will move at 1/2 of 60 fps and because my room camera follows that object it will also moves at that speed so that produces a weird effect like if the game was running at 30 fps. Am I right? At least thats exactly what I feel its happening.

    I even created a new project to test this, to be sure its nothing wrong with my main project. I took this printscreen just to show something, but I cant show the effect as its just a static photo.
    upload_2019-3-13_23-29-35.png
     
    Last edited: Mar 14, 2019
  5. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,541
    Rather, what happens is when you move with a speed of 1, every step you will move one pixel and the camera will move 1 pixel. If you move at a speed of 2, every step you will move 2 pixels and the camera will move 2 pixels. But if you move at any non-integer speeds, then the player and the camera will be subject to GM's internal rounding subroutine. Since the camera is following the player, the camera will have fractional coordinates just like the player. The player isn't drawn to the screen at his coordinates, though. Rather, everything is drawn to the screen at coordinates relative to the camera's coordinates. And since the camera is at fractional coordinates, EVERYTHING is at fractional coordinates. Now everything in the room is getting drawn at coordinates relative to the camera but rounded off, which could mean some things get rounded up and some get rounded down. And then the next thing you know, everything's jumping around all over the place. Such is the dilemma of pixel art games...
     
    Suzaku likes this.

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