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.

Map Scrolling and 1 Player Menus

This is a nice 2 part Request.

I remember seeing a script not to long about about scrolling the camera around on the map, and even the ability to have it follow a NPC as if it was a player... but for the life of me i cant remember where/who/what it is.

2nd Request

Trying to find a 1 Player Menu, that allows you to customize the menu items and preferably a single scene. I remember seing a few of these back in the day but cant find them, or demo so old they dont work.

Thanks
 

Star

Sponsor

Code:
#==============================================================================

# ** Map Auto-Scroll

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

# SephirothSpawn

# Version 1.0

# 2008-09-23

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

# * Description:

#

#   This script was designed to make map auto-scrolling even better, providing

#   diagonal movements to any position. You may scroll to the center of any

#   position, targeting the player, an event, an object you create, or

#   a predefined position.

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

# * Instructions:

#

#   Place the script below the SDK (if included) and above main.

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

# * Syntax:

#

#   Scrolling to character (player/events)

#    - $game_map.scroll_to_character(id, speed)

#    - Script : scroll_to_character(id, speed)

#      id: 0-Player, N-Event ID

#

#   Scrolling to object (any object with .x and .y methods)

#    - $game_map.scroll_to_object(object, speed)

#    - Script : scroll_to_object(object, speed)

#

#   Scroll to position

#    - $game_map.scroll_to_target(x, y, speed)

#    - Script : scroll_to_target(x, y, speed)

#

#    speed: display distance change (16 = default 4 speed)

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

# * Terms & Conditions:

#

#   Copyright (C) 2007 SephirothSpawn (Timothy Hoffman)

#   Free for non-commercial use.

#   10 USD commercial license. Contact via. [email=SephirothSpawn@hotmail.com]SephirothSpawn@hotmail.com[/email]

#

#   Any modifications to the system are not to be re-distributed without my

#   consent.

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

 

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

# ** SDK Log

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

 

if Object.const_defined?(:SDK)

  SDK.log('Map Auto-Scroll', 'SephirothSpawn', 1.0, '2008-09-23')

end

 

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

# * Begin SDK Enable Test

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

if Object.const_defined?(:SDK) == false || !SDK.enabled?('Map Auto-Scroll')

 

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

# ** 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 @scroll_target_x != nil

      # Update autoscroll

      update_autoscroll

    end

    # Original update

    seph_autoscroll_gmmap_update

  end

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

  # * Frame Update: Autoscroll

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

  def update_autoscroll

    # If vertical scroll

    if @display_x == @scroll_target_x

      # Gets distance

      distance = [@scroll_speed, (@scroll_target_y - @display_y).abs].min

      # If scroll up

      if @display_y > @scroll_target_y

        scroll_up(distance)

      # If scroll down

      else

        scroll_down(distance)

      end

    # If horizontal scroll

    elsif @display_y == @scroll_target_y

      # Gets distance

      distance = [@scroll_speed, (@scroll_target_x - @display_x).abs].min

      # If scroll left

      if @display_x > @scroll_target_x

        scroll_left(distance)

      # If scroll right

      else

        scroll_right(distance)

      end

    # If diagonal scroll

    else

      # Get differences

      diff_x = (@scroll_target_x - @display_x).abs

      diff_y = (@scroll_target_y - @display_y).abs

      # Reconfigure autoscroll rest

      distance = Math.hypot(diff_x, diff_y)

      # Gets distance

      distance = [@scroll_speed, distance].min

      # Gets angle

      a = Math.atan2((@scroll_target_y - @display_y).abs, 

        (@scroll_target_x - @display_x).abs.to_f)

      # Gets other triangle sides

      so = Math.sin(a) * distance

      sa = Math.cos(a) * distance

      # Put both distances in array

      sides = [sa, so]

      # Get x and y distance moves

      if diff_x > diff_y

        x_move, y_move = sides.max, sides.min

      else

        x_move, y_move = sides.min, sides.max

      end

      # If move left

      if @display_x > @scroll_target_x

        scroll_left(x_move)

      # If move right

      else

        scroll_right(x_move)

      end

      # If move up

      if @display_y > @scroll_target_y

        scroll_up(y_move)

      else

        scroll_down(y_move)

      end

    end

    # If target reached

    if @scroll_target_x == @display_x && @scroll_target_y == @display_y

      @scroll_target_x, @scroll_target_y = nil, 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 = Game_Map::Default_Scroll_Speed)

    $game_map.scroll_to_character(id, speed)

  end

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

  # * Scroll to object

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

  def scroll_to_object(object, speed = Game_Map::Default_Scroll_Speed)

    $game_map.scroll_to_object(object, speed)

  end

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

  # * Scroll to target

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

  def scroll_to_target(x, y, speed = Game_Map::Default_Scroll_Speed)

    $game_map.scroll_to_target(x, y, speed)

  end

end

 

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

# * End SDK Enable Test

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

end

I can't find the thread, but this is by SephirothSpawn.

I think you just use $game_map.scroll_to_character(EventID or 0 for player, Speed)

I don't know anything about a 1 player CMS tho
 

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