[Resolved] Sprite coordinates not visually updating

Is there any common known reason to why new coordinates given to sprites don't update on the screen? Naturally, I've checked that my coordinates update exactly as intended, but I don't see my sprites changing their positions visually on the screen at all.

I'm keeping a solid 40 FPS, so Graphics.update is definitely being called properly. I've checked that the methods in question are definitely being run at a constant rate by printing the details.

Below are the methods currently in question.
  1.  def render
  2.     # Update necessary modules
  3.     Graphics.update
  4.     Input.update
  5.     # Update player
  6.     @player.update
  7.     # Update all sprites
  8.     @spriteset.tiles.each {|tile| tile.update}
  9.   end
Expand to see the code.

The "@player" variable here refers to my Player class, which is the main sprite object that inherits RPG::Sprite, but as its coordinates dynamically changes, and I've proven so by outputting the coordinates into a console repeatedly, the sprite's position visually on the screen stays the same. Here's the player class (note it's completely unfinished, and I'm no master in coding. I tend to fix things as I go, right now I only wish to fix the graphic coordinate issue):
  1. #============================================================================
  2. # ** Player
  3. #----------------------------------------------------------------------------
  4. #  This class contains the player sprite and its functions.
  5. #============================================================================
  6.  
  7. class Player < RPG::Sprite
  8.   #--------------------------------------------------------------------------
  9.   # * Constants
  10.   #--------------------------------------------------------------------------
  11.   Left = 0 ; Right = 1
  12.   #--------------------------------------------------------------------------
  13.   # * Public Instance Variables
  14.   #--------------------------------------------------------------------------
  15.   attr_accessor :dir
  16.   #--------------------------------------------------------------------------
  17.   # * Object Initialization
  18.   #      graphic : string name of the character graphic
  19.   #--------------------------------------------------------------------------
  20.   def initialize(graphic)
  21.     super()
  22.     # Set bitmap
  23.     self.bitmap = RPG::Cache.character(graphic,0)
  24.     # Set coordinates
  25.     self.x = 96
  26.     self.y = 288
  27.     self.z = (Game::PlayerLayer * 500) + 250
  28.     width   = self.bitmap.width / 4
  29.     height  = self.bitmap.height / 4
  30.     self.src_rect.set(0,0,width,height)
  31.     # Set variables
  32.     @dir    = Right
  33.     @step   = 0
  34.     @moving = false
  35.     @jumping= false
  36.     @falling= false
  37.     @tiles  = 0
  38.     @route  = nil
  39.     # Set destination coordinates
  40.     @destination = nil
  41.     # Set source rectangle
  42.     set_graphic
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # * Update
  46.   #--------------------------------------------------------------------------
  47.   def update
  48.     return unless self.visible
  49.     super
  50.     # Set graphic
  51.     set_graphic
  52.     # If moving: update movement
  53.     update_movement if moving?
  54.     # Return if processing
  55.     return if Game.processing?
  56.     # If there's no tile under the player
  57.     if Engine.scene.passable?(self.tile_x,self.tile_y+1) and !@jumping
  58.       @falling = true
  59.       @moving = true
  60.       return
  61.     elsif !Engine.scene.passable?(self.tile_x,self.tile_y+1) and @falling
  62.       @falling = false
  63.       @moving = false
  64.       return
  65.     end
  66.     # If jump key and not jumping
  67.     if Input.trigger?(Game::JumpKey) and !@jumping
  68.       jump
  69.     end
  70.     # Check for movement keys
  71.     if Input.press?(Input::LEFT)
  72.       move_left
  73.       return
  74.     elsif Input.press?(Input::RIGHT)
  75.       move_right
  76.       return
  77.     end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # * Update Movement
  81.   #--------------------------------------------------------------------------
  82.   def update_movement
  83.     # If destination isn't nil
  84.     unless @destination.nil?
  85.       # If destination has been reached
  86.       if [self.tile_x,self.tile_y] == @destination
  87.         @destination = nil
  88.         @route = nil
  89.         @step = 0
  90.       else
  91.         case @dir
  92.         when Left
  93.           self.x -= 4
  94.         when Right
  95.           self.x += 4
  96.         end
  97.         unless (@jumping or @falling)
  98.           @step += 1
  99.           @step %= 4
  100.         end
  101.       end
  102.       return
  103.     end
  104.     # When jumping
  105.     if @jumping
  106.       if Engine.scene.passable?(self.tile_x,self.tile_y-1) and
  107.         ![self.tile_x,self.tile_y] == @tiles
  108.         self.y -= 8
  109.       else
  110.         @falling = true
  111.         @jumping = false
  112.       end
  113.     end
  114.     # When falling
  115.     if @falling
  116.       if Engine.scene.passable?(self.tile_x,self.tile_y+1)
  117.         self.y += 8
  118.       else
  119.         @falling = false
  120.       end
  121.     end
  122.     # If route isn't empty
  123.     unless @route.nil?
  124.       if @route == "move_left"
  125.         if Engine.scene.passable?(self.tile_x-1,self.tile_y)
  126.           @destination = [self.tile_x-1,self.tile_y]
  127.           @dir = Left
  128.         else
  129.           @route = nil
  130.         end
  131.       elsif @route == "move_right"
  132.         if Engine.scene.passable?(self.tile_x+1,self.tile_y)
  133.           @destination = [self.tile_x+1,self.tile_y]
  134.           @dir = Right
  135.         else
  136.           @route = nil
  137.         end
  138.       end
  139.       return
  140.     end
  141.     # If not falling or jumping: set moving off
  142.     unless (@falling and @jumping)
  143.       @moving = false
  144.     end
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * Move Left
  148.   #--------------------------------------------------------------------------
  149.   def move_left
  150.     return unless @route.nil?
  151.     @route = 'move_left'
  152.     @moving = true
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # * Move Right
  156.   #--------------------------------------------------------------------------
  157.   def move_right
  158.     return unless @route.nil?
  159.     @route = 'move_right'
  160.     @moving = true
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # * Jump
  164.   #--------------------------------------------------------------------------
  165.   def jump
  166.     @tiles   = [self.tile_x,self.tile_y-3]
  167.     @moving  = true
  168.     @jumping = true
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * Moving?
  172.   #--------------------------------------------------------------------------
  173.   def moving?
  174.     @moving
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * Tile X
  178.   #--------------------------------------------------------------------------
  179.   def tile_x
  180.     self.x / 32
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Tile Y
  184.   #--------------------------------------------------------------------------
  185.   def tile_y
  186.     self.y / 32
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * Set Graphic
  190.   #--------------------------------------------------------------------------
  191.   def set_graphic
  192.     return unless self.visible
  193.     # Obtain width and height of frames
  194.     width   = self.bitmap.width / 4
  195.     height  = self.bitmap.height / 4
  196.     self.ox = width / 2
  197.     self.oy = height - 32
  198.     # Set ch
  199.     ch = (@jumping or @falling) ? height * 2 : 0
  200.     # Direction case
  201.     case @dir
  202.     when Left
  203.       self.src_rect.set(@step * width,ch,width,height)
  204.     when Right
  205.       self.src_rect.set(@step * width,height+ch,width,height)
  206.     end
  207.   end
  208. end
Expand to see the code.

The methods that refer to the "Engine" module returns the boolean values I intend them to return, so that isn't very important to include here.

Anyone got any ideas on what I am doing wrong?

Thanks!
The sprites, including the player's sprite, are in the spriteset's @character_sprites. There shouldn't be a problem If you're calling spriteset.update somewhere.
I'm just guessing here, but an events' moving? method should return true if it's currently moving from one tile to the next one. Yours returns true only when jumping and falling.
This doesn't base itself upon any of the default scripts. There is no such thing as a Spriteset_Map, only my sprites drawn on the screen.

But I fixed it. Thanks for the reply. Was an issue with the Graphics module that I had to change.
For general enlightment, might want to share your fix for this?

Also, setting RPG::Sprite as the superclass for a playable instance is, while functional, pretty cluttery and could or should cause you problems sooner or later that you probably wouldn't have going the normal way (class Game_Player; def initialize('graphic'); @graphic = RPG::Sprite.new; @graphic.bitmap = RPG::Cache.characters(graphic); end; end - very roughly and probably containing a thousand syntax errors, but you get me)...
However, everything could just as well work out fine, so yeah... whatever floats your boat ^^ Just saying having a visual class as superclass for a functional class seems odd.
Well, the whole project that I am working on has none of the default RMXP scripts, only classes and modules present in the DLL. This caused some strange issues with the Graphics module in the way I set up the rendering process of the whole system. For an unknown reason, Graphics.transition did not execute as intended, so the Graphics kept being frozen from Graphics.freeze. Naturally this doesn't make any sense, and I'm sure that it's entirely due to my bad way of scripting the system, so I'm not entirely sure how to get around this ignoring of the transition method, but I'll look into it. Currently I'm only commenting out my Graphics.freeze method until I need to meddle with it. I only wish to make sure that my game handling of sprites works as intended first.

And yes, I do actually agree there, and decided to change it into what you suggested. It works as I intended it to, but it sounds much more ideal to assign the sprite to a seperate variable indeed. Thanks for that input.
Hm... as for Graphics.transition, that shouldn't cause you any problems as long as it's properly called. Zeriab's Community Evolutionary Script Project is a pretty good example on how you can make it work... I hope that'll give you an idea on what's going on with your script.

On a side note, that topic somehow made me further look into developing outside RPG Maker tools, getting my hands on Ruby/Gosu. You seem to get tired of RMXP's default system as well, so yeah... maybe you'll have les headaches trying Gosu out, which is completely transparent and way less resource-expensive (and therefore has a better performance). Just a suggestion ;)
Sounds fair enough. I'll have a look at that, thanks!

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=71162