Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Picture locking to the map

Batman

Sponsor

Does anyone know if there's a way to lock a picture to the map? So that it doesn't move with the screen, but instead stay somewhere on the map? Without having the picture in the tileset?

This would open up a whole range of possibilities for me.
 
I know that modern algebra has created a script that does just that for VX. Whether it will copy over to XP remains to be seen. If worse comes to worse there are ways to do it via events, albeit very laggy and annoying to implement. The trick is to check the players X and Y coordinates on the map and align the picture to that.
 

Ares

Member

I think I once found a script by Glitchfinder that does that. I'll see if I can find it for you.

EDIT:
Here it is!
[rgss]#==============================================================================
# ** Game_Picture
#------------------------------------------------------------------------------
#  This class handles the picture. It's used within the Game_Screen class
#  ($game_screen).
#==============================================================================
 
class Game_Picture
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor   :anchor                    # rotation angle
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias glitch_anchor_pic_game_picture_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     number : picture number
  #--------------------------------------------------------------------------
  def initialize(number)
    @anchor = false
    glitch_anchor_pic_game_picture_initialize(number)
  end
end
 
#==============================================================================
# ** Sprite_Picture
#------------------------------------------------------------------------------
#  This sprite is used to display the picture.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================
 
class Sprite_Picture < Sprite
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias glitch_anchor_pic_sprite_picture_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    glitch_anchor_pic_sprite_picture_update
    if @picture.anchor == true
      self.ox = $game_map.display_x / 4
      self.oy = $game_map.display_y / 4
    end
  end
end
[/rgss]
Put that somewhere above "Main". Then you can put this right after the event command that creates the picture in a script call:
[rgss]$game_screen.pictures 
 
Or if you just put this above main...

Code:
 

#==============================================================================

# ** Sprite_Picture

#------------------------------------------------------------------------------

#  This sprite is used to display the picture.It observes the Game_Character

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Sprite_Picture < Sprite

  #--------------------------------------------------------------------------

  # * Alias Methods

  #--------------------------------------------------------------------------

  alias glitch_anchor_pic_sprite_picture_update update

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    glitch_anchor_pic_sprite_picture_update

    if @picture_name.include?("$")

      self.ox = $game_map.display_x / 4

      self.oy = $game_map.display_y / 4

    end

  end

end

 

... now all of your pictures which have $ in their name will have this ability. :)
 
Well it's probably because you have a big map. The pictures which are locked are placed a the top left coordinates and they are locked there. Try putting the picture in the game then go to the top-left corner of the map.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top