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.

Using a picture as a map element

Feel bad doing this after so long, but here goes. Have searched and searched and searched to no avail.

I'm making a cutscene, and am showing a picture for part of the map - an additional map layer, if you like. Trouble is I need it to keep it's map position while the player moves. In other words, if it's over tile 001,001 then if the player moves 50 paces to the right then the picture will still be at map position 001,001.

I've tried messing around with variable algorithms and so far have got nowhere.

Wondering if anyone can help.

RMXP.
 
I haven't been able to find a way to make a picture stay in place, but I have a secondary solution. If you make the picture a fog for the map instead of trying to use a picture, you can achieve the effect you're looking for. There are a couple of problems with this, however:

1. If you want to use another fog, you wouldn't be able to.
2. You can't position fogs and the fog graphic repeats, so you'll need to play around with extra space on the ends of the image.
 
Haven't done this one in a long time..., but I believe you had to create an event where you want to put the picture and then get that events map x and map y coordinate from the control variables command.
After that show the picture with those variables. I think that's how I always did it...

Hope this helps

~Dalton~
 
Dalton's method works, too:

Event Page 1
Trigger: Autorun
@> Variable 1 = This event's Screen X
@> Variable 2 = This event's Screen Y
@> Show Picture using Variable 1 and Variable 2

Page 2
Trigger: Parallel
@> Variable 1 = This event's Screen X
@> Variable 2 = This event's Screen Y
@> Move Picture using Variable 1 and Variable 2


Updated:
Event
Trigger: Parallel
@> Variable 1 = This event's Screen X
@> Variable 2 = This event's Screen Y
@> Show Picture using Variable 1 and Variable 2


I've noticed it can cause a little delay, however. You can't set the frames for transition to "0", so you have to keep it at "1" and that can make the picture jerk around a little during player movement.
 

Jason

Awesome Bro

Why are you carrying on with the eventing way if it doesn't quite work ?

The picture shows ABOVE the player, which is no good in this situation...

Also, the picture doesn't start completely in the top-left corner, it shows a black border around it

:huh: :huh: :huh:
 
I guess JBrist is quite right about that. It is by no means a perfect solution and pictures always show above the player (but doesn't that also apply for the scripting method?) so ist is a bit tricky...
What I always use this method fore is when something needs to have a light around it in the dark like lampposts.
For such stuff it works just right.
 

Jason

Awesome Bro

Yeah I can understand using it for cosmetic lighting, since that'd work fine.

Is there a way I wonder (Obviously scripting...), to change the z axis of the image, so it appears below the player and/or map, but above the panorama...
 
First of all, I want to apologize to Dalton. I must've only read the first two lines in that picture you posted and then went to experiment. Your method (creating the image in the parallel) actually works better than my method (creating the image in autorun and moving it in parallel). Sorry 'bout that. :blush:

Anyway, there's definitely a way to make a game show pictures below characters and above the tileset. Here's what I can provide in terms of scripting (explanation of what I did at top):
Code:
=begin

Alright, here are the changes I've made:

*Added viewport4, to distinguish between the player and the map (Line 30)

*Change viewport1 to viewport4 in character sprite creation (Lines 52 and 55)

*Created a z coordinate for viewport4 (Line 33)

*Altered z coordinate for viewport2 (handles pics) (Line 31)

*Added viewport4 to Dispose and Update (Line 99 and Line 171, respectively)

 

I made the value of viewport2 = 100 and the value of veiwport4 = 200.  This way,

characters have a higher z coordinate than pictures and pictures can be

displayed above the tileset.

=end

 

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

# ** Spriteset_Map

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

#  This class brings together map screen sprites, tilemaps, etc.

#  It's used within the Scene_Map class.

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

 

class Spriteset_Map

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

  # * Object Initialization

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

  def initialize

    # Make viewports

    @viewport1 = Viewport.new(0, 0, 640, 480)

    @viewport2 = Viewport.new(0, 0, 640, 480)

    @viewport3 = Viewport.new(0, 0, 640, 480)

    @viewport4 = Viewport.new(0, 0, 640, 480)

    @viewport2.z = 100

    @viewport3.z = 5000

    @viewport4.z = 200

    # Make tilemap

    @tilemap = Tilemap.new(@viewport1)

    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)

    for i in 0..6

      autotile_name = $game_map.autotile_names[i]

      @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)

    end

    @tilemap.map_data = $game_map.data

    @tilemap.priorities = $game_map.priorities

    # Make panorama plane

    @panorama = Plane.new(@viewport1)

    @panorama.z = -1000

    # Make fog plane

    @fog = Plane.new(@viewport1)

    @fog.z = 3000

    # Make character sprites

    @character_sprites = []

    for i in $game_map.events.keys.sort

      sprite = Sprite_Character.new(@viewport4, $game_map.events[i])

      @character_sprites.push(sprite)

    end

    @character_sprites.push(Sprite_Character.new(@viewport4, $game_player))

    # Make weather

    @weather = RPG::Weather.new(@viewport1)

    # Make picture sprites

    @picture_sprites = []

    for i in 1..50

      @picture_sprites.push(Sprite_Picture.new(@viewport2,

        $game_screen.pictures[i]))

    end

    # Make timer sprite

    @timer_sprite = Sprite_Timer.new

    # Frame update

    update

  end

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

  # * Dispose

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

  def dispose

    # Dispose of tilemap

    @tilemap.tileset.dispose

    for i in 0..6

      @tilemap.autotiles[i].dispose

    end

    @tilemap.dispose

    # Dispose of panorama plane

    @panorama.dispose

    # Dispose of fog plane

    @fog.dispose

    # Dispose of character sprites

    for sprite in @character_sprites

      sprite.dispose

    end

    # Dispose of weather

    @weather.dispose

    # Dispose of picture sprites

    for sprite in @picture_sprites

      sprite.dispose

    end

    # Dispose of timer sprite

    @timer_sprite.dispose

    # Dispose of viewports

    @viewport1.dispose

    @viewport2.dispose

    @viewport3.dispose

    @viewport4.dispose

  end

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

  # * Frame Update

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

  def update

    # If panorama is different from current one

    if @panorama_name != $game_map.panorama_name or

       @panorama_hue != $game_map.panorama_hue

      @panorama_name = $game_map.panorama_name

      @panorama_hue = $game_map.panorama_hue

      if @panorama.bitmap != nil

        @panorama.bitmap.dispose

        @panorama.bitmap = nil

      end

      if @panorama_name != ""

        @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)

      end

      Graphics.frame_reset

    end

    # If fog is different than current fog

    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue

      @fog_name = $game_map.fog_name

      @fog_hue = $game_map.fog_hue

      if @fog.bitmap != nil

        @fog.bitmap.dispose

        @fog.bitmap = nil

      end

      if @fog_name != ""

        @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)

      end

      Graphics.frame_reset

    end

    # Update tilemap

    @tilemap.ox = $game_map.display_x / 4

    @tilemap.oy = $game_map.display_y / 4

    @tilemap.update

    # Update panorama plane

    @panorama.ox = $game_map.display_x / 8

    @panorama.oy = $game_map.display_y / 8

    # Update fog plane

    @fog.zoom_x = $game_map.fog_zoom / 100.0

    @fog.zoom_y = $game_map.fog_zoom / 100.0

    @fog.opacity = $game_map.fog_opacity

    @fog.blend_type = $game_map.fog_blend_type

    @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox

    @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy

    @fog.tone = $game_map.fog_tone

    # Update character sprites

    for sprite in @character_sprites

      sprite.update

    end

    # Update weather graphic

    @weather.type = $game_screen.weather_type

    @weather.max = $game_screen.weather_max

    @weather.ox = $game_map.display_x / 4

    @weather.oy = $game_map.display_y / 4

    @weather.update

    # Update picture sprites

    for sprite in @picture_sprites

      sprite.update

    end

    # Update timer sprite

    @timer_sprite.update

    # Set screen color tone and shake position

    @viewport1.tone = $game_screen.tone

    @viewport1.ox = $game_screen.shake

    # Set screen flash color

    @viewport3.color = $game_screen.flash_color

    # Update viewports

    @viewport1.update

    @viewport3.update

    @viewport4.update

  end

end

At the moment, you'd replace Spriteset_map with that, but my scripting abilities are still limited. This would affect all pictures and I don't know how to access the values in there so you can change them for different pictures. If someone wants, you can make a request for a better version of this. At least the code I altered should give a scripter a very good idea of what to do.

There's still the extra border issue, but I have no idea how to fix that. :X
 

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