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.

[XP] Map Zoom + Diagonal Scroll (Either - Simultaneous Prefered)

Well, there goes my first request here  :tongue:. I hope it's nothing too complicated for scripters  :huh:.

The title is rather self explanatory. There is no way to zoom with events and the scroll map feature is very blocky.

-The Zooming-

It allows, well, to zoom. I will not likely need more then a 50% (150%) zoom in, if that changes anything. Note that only the map should be zoomed, not the pictures, although if that is too hard, you may skip it. It would also be appreciated if there was possibility of controling acceleration/deceleration (as a bezier curve instead of linear) but again, it is optional if too difficult.

-The Scrolling-

It should be as smooth as possible. Meaning that the scroll should travel in a straight line from point A to point B. The script seen here does not work as such, because it only uses perfect diagonals (45o degree) and goes horizontal/vertical for the remaining tiles, thus having a two-step scroll. I need it as one-step. Also, speed control of the scroll is important and if possible (if not too much trouble), acceleration/deceleration on top of that.

The ideal would be to directly scroll to a (x, y) location on the map, although I can manage with just a relative scroll (+x, +y). It would also be nice to have a "recenter_player" feature.

-Merging-

As said in title, it would be best if both actions could occur at the same time, zoming and centering on one event in call script. I realize that may be difficult, but if anyone could do it, then it would be nice.

---

I hope I gave all details needed. If not, I'll gladly supply them. Thank you for your time.
 
Wow, I need something almost identical to this.

Wachunga made a scrolling script a while back that did the things you're mentioning. Problem was, it was very finnicky, only doing it when "it wanted to".

I can't search for it right now, but if you search for it, I think it's like "Wachunga's Map Scroll" or "Map Pan" or something, it could help out whoever works on this.
 
For the scrolling...

Why dont you just change your main characters graphic to "none" (if he is on the map swap him for an event or something) and then modify his passability... and move him... mh?
 
Avadan":28jmbj26 said:
For the scrolling...

Why dont you just change your main characters graphic to "none" (if he is on the map swap him for an event or something) and then modify his passability... and move him... mh?
I was going to suggest this. You could move an event to where the player is, give it the same graphic and make the player invisible then move it down left or upper left or what ever.
EASY!!!
Unless it's not for cutscenes.

Never seen a map zoom script, I don't think one was ever made else it would be a 20 page topic with everyone saying how great it was and what it is compatible with and a list of errors.
 
The Wachunga script is the one I linked to in the "here" (although it's so small - hard to see). But again, it only supports 45 degree diagonals. Which happens to be the little problem of having a invisible trough character, since it would be difficult to have the 410 angle of, say, a +3 +7 movement (sin(3/7)=41 right? Didn't have trigonometry classes yet).

So yeah, we just need to make those two compatible  :smile: (oh, and does Trebor's zoom affect pictures?). Could be usefull for alot of people.
 
I'll make one real quick. I have been looking for scripts to sharpen my math skills. :)


Ok. I remade a better autoscroll. It can work to any angle, and speed is a little more precise (now you just send a bigger number).

Code:
#==============================================================================
# ** Game_Map
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  Map_Width             = 20
  Map_Height            = 15
  Default_Scroll_Speed  = 16
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_autoscroll_gmmap_scrlg?, :scrolling?
  alias_method :seph_autoscroll_gmmap_update, :update
  #--------------------------------------------------------------------------
  # * Scrolling?
  #--------------------------------------------------------------------------
  def scrolling?
    return seph_autoscroll_gmmap_scrlg? || @autoscoll_rest != nil
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If autoscroll target exist
    if @autoscroll_rest != nil
      # Update autoscroll
      update_autoscroll
    end
    # Original update
    seph_autoscroll_gmmap_update
  end
  #--------------------------------------------------------------------------
  # * Frame Update: Autoscroll
  #--------------------------------------------------------------------------
  def update_autoscroll
    # Change from scroll speed to distance in map coordinates
    distance = [@scroll_speed, @autoscroll_rest].min
    # If vertical scroll
    if @display_x == @scroll_target_x
      # If scroll up
      if @display_y > @scroll_target_y
        scroll_up(distance)
      # If scroll down
      else
        scroll_down(distance)
      end
      # Subtract distance
      @autoscroll_rest -= distance
    # If horizontal scroll
    elsif @display_y == @scroll_target_y
      # If scroll left
      if @display_x > @scroll_target_x
        scroll_left(distance)
      # If scroll right
      else
        scroll_right(distance)
      end
      # Subtract distance
      @autoscroll_rest -= distance
    # If diagonal scroll
    else
      # Gets angle
      a = Math.atan2((@scroll_target_y - @display_y).abs, 
        (@scroll_target_x - @display_x).abs.to_f)
      # Get 360 Degree Angle
      a2 = a * 180 / Math::PI
      if (@scroll_target_x - @display_x) > 0
        a2 = (@scroll_target_y - @display_y) > 0 ? 360 - a2 : a2
      else
        a2 = 180 + ((@scroll_target_y - @display_y) > 0 ? a2 : -a2)
      end
      # Gets other triangle sides
      so = Math.sin(a) * distance
      sa = Math.cos(a) * distance
      # Get difference
      if a2.between?(0, 45) || a2.between?(135, 225) || a2.between?(315, 360)
        x_move = sa
        y_move = so
      else
        x_move = so
        y_move = sa
      end
      # If move left
      if @display_x > @scroll_target_x
        scroll_left(x_move)
      # If move right
      else
        scroll_right(x_move)
      end
      # Gets y distance
      # If move up
      if @display_y > @scroll_target_y
        scroll_up(y_move)
      else
        scroll_down(y_move)
      end
      # Get differences
      diff_x = (@scroll_target_x - @display_x).abs
      diff_y = (@scroll_target_y - @display_y).abs
      # Reconfigure autoscroll rest
      @autoscroll_rest = Math.hypot(diff_x, diff_y)
    end
    # If 0 difference
    if @autoscroll_rest == 0
      @autoscroll_rest = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Scroll to character
  #--------------------------------------------------------------------------
  def scroll_to_character(id = 0, speed = Default_Scroll_Speed)
    # Get character
    if id == 0
      chr = $game_player
    elsif @events.has_key?(id)
      chr = @events[id]
    else
      p 'Unable to find character for id: ' + id.to_s
      return
    end
    # Scroll to target
    scroll_to_target(chr.x, chr.y, speed)
  end
  #--------------------------------------------------------------------------
  # * Scroll to object
  #--------------------------------------------------------------------------
  def scroll_to_object(object, speed = Default_Scroll_Speed)
    # If x and y definable attributes
    if object.respond_to?(:x) && object.respond_to?(:y)
      # Scroll to target
      scroll_to_target(object.x, object.y, speed)
    end
    # Return bad object
    p 'Object undefined x and/or y method: ' + object.to_s
  end
  #--------------------------------------------------------------------------
  # * Scroll to target
  #--------------------------------------------------------------------------
  def scroll_to_target(x, y, speed = Default_Scroll_Speed)
    # Return if already scrolling
    return if scrolling?
    # If invalid position
    if $game_map.valid?(x, y) == false
      p 'Bad x and y position given: ' + x.to_s + ', ' + y.to_s
      return
    end
    # Gets target display x & y
    max_x = ($game_map.width - Map_Width) * 128
    max_y = ($game_map.height - Map_Height) * 128        
    t_display_x = [0, [x * 128 - Game_Player::CENTER_X, max_x].min].max
    t_display_y = [0, [y * 128 - Game_Player::CENTER_Y, max_y].min].max
    # Get differences
    diff_x = (t_display_x - @display_x).abs
    diff_y = (t_display_y - @display_y).abs
    # If x difference 0
    if diff_x == 0
      @autoscroll_rest = diff_y
    # If y difference is 0
    elsif diff_y == 0
      @autoscroll_rest = diff_x
    # If diagonal movement
    else
      @autoscroll_rest = Math.hypot(diff_x, diff_y)
    end
    # Save coordinates and speed
    @scroll_target_x = t_display_x
    @scroll_target_y = t_display_y
    @scroll_speed = speed
  end
end

#==============================================================================
# ** Interpreter
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Scroll to character
  #--------------------------------------------------------------------------
  def scroll_to_character(id = 0, speed = Default_Scroll_Speed)
    $game_map.scroll_to_character(id, speed)
  end
  #--------------------------------------------------------------------------
  # * Scroll to object
  #--------------------------------------------------------------------------
  def scroll_to_object(object, speed = Default_Scroll_Speed)
    $game_map.scroll_to_object(object, speed)
  end
  #--------------------------------------------------------------------------
  # * Scroll to target
  #--------------------------------------------------------------------------
  def scroll_to_target(x, y, speed = Default_Scroll_Speed)
    $game_map.scroll_to_target(x, y, speed)
  end
end


I haven't yet made it compatable with the map-zoom. That's on my list of things to do for tomorrow.
 
I try ^_^

Well it seems it is slightly flawed. How, I still don't know, but I made an event to scroll the map down and to the right, then made it autoscroll to an event, it scrolled x but not y and ended up making the screen shake like it was having a ceisure (sp?). I know it just itsn't using the right sides for the triangle, so I just got to get those fixed and that should be it. A little trig refresher. lol
 
SephirothSpawn":3n2h5nyh said:
I try ^_^

Well it seems it is slightly flawed. How, I still don't know, but I made an event to scroll the map down and to the right, then made it autoscroll to an event, it scrolled x but not y and ended up making the screen shake like it was having a ceisure (sp?). I know it just itsn't using the right sides for the triangle, so I just got to get those fixed and that should be it. A little trig refresher. lol

Didn't your old tilemap rewrite have a map zoom option? (I use it, but I haven't tried the zoom feature on it yet)
 
This is generally frowned upon to bump someone else's topic but ... pretend I'm saying something meaningful here because I would like this incorporated very much big time <3

Also: I love you. And have a nice day?
 
It'll be awhile before I get the map zoom and merge. I am extremely backed up with commercial request and such, and have a lot of angry customers. That and the SDK/MACL/RMXPSE & personal projects, I figure if I script 14 hours a day, in 4 months I might be caught up to where I need to be.

I'll try to get to this in a week or so. Just keep on top of me.
 
SephirothSpawn":3l16i06f said:
It'll be awhile before I get the map zoom and merge. I am extremely backed up with commercial request and such, and have a lot of angry customers. That and the SDK/MACL/RMXPSE & personal projects, I figure if I script 14 hours a day, in 4 months I might be caught up to where I need to be.

I'll try to get to this in a week or so. Just keep on top of me.

Don't stress yourself out, Sephy. I love you again and I will give you my special baby oil neckrub to ease your weary back! Just lemme go get a bus schedule ...
 

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