Fractional Movement Speed

Discussion in 'RGSS3 Script Requests' started by DumbPomelo, Jun 20, 2019.

  1. DumbPomelo

    DumbPomelo Villager Member

    Messages:
    18
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMVXA
    I'd like to give player a slight boost in movement speed, among other things, to cut down time on backtracking.
    However, setting speed to something uneven like "@move_speed = 4.2" causes their sprite to jitter back and forth a few pixels in direction of movement on occassion. Sometimes the pixel shift lingers even after movement is over, causing their graphic to be permanently displaced.

    I was also using this bugfix snippet, and it made the effect much worse, the sprite now shakes during walking as if an earthquake is taking place.

    Code:
    ##------
    ## Display rounding error fix created by Neon Black.
    ##
    ## When certain slow display panning speeds are used, events will improperly
    ## round floating values to determine their position on screen.  This causes
    ## them to appear off from the tilemap by a single pixel.  Though minor this is
    ## noticable.  This snippet fixes this behaviour.
    ##
    ## This snippet may be used in any project.
    ##
    ## -- Original Topic:
    ## http://forums.rpgmakerweb.com/index.php?/topic/17448-event-jitter-fix-display-rounding-error-fix
    ##------
    class Game_Map ## Rounds X and Y display values DOWN so the nearest 32 is found.
      def display_x
        (@display_x * 32).floor.to_f / 32
      end
     
      def display_y
        (@display_y * 32).floor.to_f / 32
      end
     
      def adjust_x(x)
        if loop_horizontal? && x < display_x - (width - screen_tile_x) / 2
          x - display_x + @map.width
        else
          x - display_x
        end
      end
     
      def adjust_y(y)
        if loop_vertical? && y < display_y - (height - screen_tile_y) / 2
          y - display_y + @map.height
        else
          y - display_y
        end
      end
    end

    What can I try to remedy this before giving up and going back to 4 speed?
     
    #1
  2. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,035
    Likes Received:
    380
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    You cannot do it, at least not if you do not plan on messing up with the grid system. However, you should be able to do it with a pixel based movement system, but then you have to bear all the downsides that a pixel based movement system brings when it comes to events interaction and collisions.
     
    #2

Share This Page