Is it possible for character/object goes off map & loops back from the other side without using loop map?

XENVITA

https://xenvita.carrd.co/
Member
Joined
Apr 10, 2020
Messages
13
Reaction score
1
First Language
Chinese
Primarily Uses
RMVX
Hi, I was just wondering this is possible or if there's a code for it somewhere. Basically I wanna make a character/object goes off the map and loops back from the other side of the same map WITHOUT using scroll type loop map? Hope it doesn't sound confusing or anything > <

Untitled.png
 

Restart

Veteran
Veteran
Joined
Mar 15, 2019
Messages
848
Reaction score
708
First Language
English
Primarily Uses
RMMV
You can cheat and put in something like

if (this.x==0){this.locate( OTHERSIDEOFMAP,this.y)
into your moveroute
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,432
Reaction score
604
First Language
Italian
Primarily Uses
RMVXA
@Restart that code is using JavaScript syntax and is definitely not going to work in VX Ace.

However, doing that is definitely possible. I do not remember if it is the same when using custom movement, but you could simply have a parallel process event run every N frames (N is any number that fits your need) that simply moves the object to the other side of the screen once it reaches either side of the map.

Code:
event = $game_map.events[your_event_id_goes_here]
if (event.x == 0)
  event.moveto($game_map.width - 1, event.y)
elsif (event.x == $game_map.width - 1)
  event.moveto(0, event.y)
end
# Similarly for the Y coordinate
 
Last edited:

Restart

Veteran
Veteran
Joined
Mar 15, 2019
Messages
848
Reaction score
708
First Language
English
Primarily Uses
RMMV
yeah I just meant something like that, obvs not that exact code
 

XENVITA

https://xenvita.carrd.co/
Member
Joined
Apr 10, 2020
Messages
13
Reaction score
1
First Language
Chinese
Primarily Uses
RMVX
@Restart that code is using JavaScript syntax and is definitely not going to work in VX Ace.

However, doing that is definitely possible. I do not remember if it is the same when using custom movement, but you could simply have a parallel process event run every N frames (N is any number that fits your need) that simply moves the object to the other side of the screen once it reaches either side of the map.

Code:
event = $game_map.events[your_event_id_goes_here]
if (event.x == 0)
  event.moveto($game_map.width - 1, event.y)
else if (event.x = $game_map.width - 1)
  event.moveto(0, event.y)
end
# Similarly for the Y coordinate
Thank you for the help, though I'm a little confuse by this cause I'm not sure how to do that. Is it possible if you provide some kind of demonstration or where I should input these? ;;
 

Ateliae

Illustrator
Veteran
Joined
Jun 4, 2016
Messages
65
Reaction score
27
First Language
English
Primarily Uses
RMVXA
If it's eventing wise for a scene, can't you just "Teleport" or "Move" the object there after they walk towards the edge to give the illusion?
 

XENVITA

https://xenvita.carrd.co/
Member
Joined
Apr 10, 2020
Messages
13
Reaction score
1
First Language
Chinese
Primarily Uses
RMVX
If it's eventing wise for a scene, can't you just "Teleport" or "Move" the object there after they walk towards the edge to give the illusion?
This one I have is a type of vehicle that takes up 6 tiles for a size, wouldn't it look strange when it suddenly disappear and ''pops up'' from the other side? I rather for it to move smoothly off the map and on the other side of the map. :<
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,432
Reaction score
604
First Language
Italian
Primarily Uses
RMVXA
Here is a screenshot of my event. I recommend using a move_straight line inside the event itself to move your event from the parallel process itself. It ensures that the parallel process only checks the event position once the movement ends and also make your movement smoother.

index.php


Feel free to disable the "Walking Animation" option as well, the event does not need it.
 

Attachments

  • TeleportEvent.png
    TeleportEvent.png
    57 KB · Views: 50

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,653
Reaction score
15,283
First Language
English
Primarily Uses
RMMV
You don't need a parallel process or fiber.yield for this. Just do a Custom Move Route that has:
Code:
Move Left
Script: @x = $game_map.width - 1 if @x == 0

Or if it's moving right:
Code:
Move Right
Script: @x = 0 if @x == $game_map.width - 1

However, a character that takes up 6 tiles is not going to move smoothly off or on the map. If it's a single event with a large sprite, when the event (which is the middle of the sprite) hits the edge, the whole thing will disappear and reappear on the other side.
 

XENVITA

https://xenvita.carrd.co/
Member
Joined
Apr 10, 2020
Messages
13
Reaction score
1
First Language
Chinese
Primarily Uses
RMVX
Here is a screenshot of my event. I recommend using a move_straight line inside the event itself to move your event from the parallel process itself. It ensures that the parallel process only checks the event position once the movement ends and also make your movement smoother.

index.php


Feel free to disable the "Walking Animation" option as well, the event does not need it.
I got this error, I'm unsure what it means...
 

Attachments

  • Untitled.png
    Untitled.png
    26.4 KB · Views: 3

XENVITA

https://xenvita.carrd.co/
Member
Joined
Apr 10, 2020
Messages
13
Reaction score
1
First Language
Chinese
Primarily Uses
RMVX
You don't need a parallel process or fiber.yield for this. Just do a Custom Move Route that has:
Code:
Move Left
Script: @x = $game_map.width - 1 if @x == 0

Or if it's moving right:
Code:
Move Right
Script: @x = 0 if @x == $game_map.width - 1

However, a character that takes up 6 tiles is not going to move smoothly off or on the map. If it's a single event with a large sprite, when the event (which is the middle of the sprite) hits the edge, the whole thing will disappear and reappear on the other side.
I tried yours, though it moves back and forth instead and didn't go off the map. :0
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,432
Reaction score
604
First Language
Italian
Primarily Uses
RMVXA
I got this error, I'm unsure what it means...
It means that you used $game_map.width -1 instead of $game_map.width - 1. If you put a space before the minus sign and put no space after it, the inerpreter reads it as $game_map.width and then -1 as a negative number.

@Shaz doing that in a custom move route is very buggy. Since the X coordinate reaches 0 before the movement ends and your character is still moving (defined as @real_x != @x), instead of having the event teleport to the other side you simply have a sliding sprite that goes in the opposite direction. You have to use moveto($game_map.width - 1, @y) instead.

EDIT: the op ninjed me.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,653
Reaction score
15,283
First Language
English
Primarily Uses
RMMV
Can you show a screenshot of your event please?
 

XENVITA

https://xenvita.carrd.co/
Member
Joined
Apr 10, 2020
Messages
13
Reaction score
1
First Language
Chinese
Primarily Uses
RMVX
It means that you used $game_map.width -1 instead of $game_map.width - 1. If you put a space before the minus sign and put no space after it, the inerpreter reads it as $game_map.width and then -1 as a negative number.

@Shaz doing that in a custom move route is very buggy. Since the X coordinate reaches 0 before the movement ends and your character is still moving (defined as @real_x != @x), instead of having the event teleport to the other side you simply have a sliding sprite that goes in the opposite direction. You have to use moveto($game_map.width - 1, @y) instead.

EDIT: the op ninjed me.
Oh, it worked nicely! Thank you so much! Is not exactly perfect cause I made a type of vehicle that takes up to 6 tiles and because is set as a character moving on its own, it shows up a bit weird from the other side but is no big deal if something like this can't be fixed. ^^;;;
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,432
Reaction score
604
First Language
Italian
Primarily Uses
RMVXA
@XENVITA there are ways to fix that, one of those is to display it as a sprite rather than a vehicle, this way you can move it outside of the map without any constraint imposed by the Character class. However, I am not sure what you are going to do with that so I cannot tell whether or not it is a good idea.
 

XENVITA

https://xenvita.carrd.co/
Member
Joined
Apr 10, 2020
Messages
13
Reaction score
1
First Language
Chinese
Primarily Uses
RMVX
@XENVITA there are ways to fix that, one of those is to display it as a sprite rather than a vehicle, this way you can move it outside of the map without any constraint imposed by the Character class. However, I am not sure what you are going to do with that so I cannot tell whether or not it is a good idea.
I actually didn't make it as a vehicle, I turned it as a [!$] character sprite cause the size of the vehicle is 6 tiles graphic. It just that it kinda register it's middle tile as the character on something you can interact.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,432
Reaction score
604
First Language
Italian
Primarily Uses
RMVXA
It was a bad choice of words on my end, I apologize. What I meant is that anything that belongs to the Game_Character class, and events belong to that class as well, can only move withing the boundaries of the map. Depending on how you are using it, you might or might not use a simple sprite (or a picture) instead of an event. It is more complicated and requires a bit of planning, but it can be done and also ensures a smooth movement and an equally smooth transition from one part of the map to the other.

However, before telling you how to do it, I would like to know how you are going to use it. It might not be worth the effort.
 

Restart

Veteran
Veteran
Joined
Mar 15, 2019
Messages
848
Reaction score
708
First Language
English
Primarily Uses
RMMV
For another workaround option, you can just put a border of empty tiles around the edge of your usable map, and use a camera script to make sure the player never sees it.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,281
Reaction score
755
First Language
English
Primarily Uses
RMVXA
you can just put a border of empty tiles around the edge of your usable map
I was thinking of the same thing, with maybe an over character tile that looks like empty screen.
 

hinola

Veteran
Veteran
Joined
Jun 27, 2015
Messages
61
Reaction score
85
First Language
Français
Primarily Uses
RMVXA
Hey

You can try this script
It allow the use of the loop function without the camera loop

You just have to copy this lines to a script call in an event.
It works well on a parallel event that you delete right after.

Ruby:
lock_horizontal_loop
lock_vertical_loop
unlock_horizontal_loop
unlock_vertical_loop

these commands automatically "center" the camera on the player.
Ruby:
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias_method :initialize_before_loop, :initialize
  def initialize
    initialize_before_loop
    @display_loop_h = true
    @display_loop_v = true
  end
  #--------------------------------------------------------------------------
  # * Loop horizontally ?
  #--------------------------------------------------------------------------
  def display_loop_horizontal?
    loop_horizontal? && @display_loop_h
  end
  #--------------------------------------------------------------------------
  # * Loop vertically ?
  #--------------------------------------------------------------------------
  def display_loop_vertical?
    loop_vertical? && @display_loop_v
  end
  #--------------------------------------------------------------------------
  # * Center screen
  #--------------------------------------------------------------------------
  def center_screen
    $game_player.center($game_player.x, $game_player.y)
  end
  #--------------------------------------------------------------------------
  # * Lock / Unlock display loops
  #--------------------------------------------------------------------------
  def lock_horizontal_loop;     @display_loop_h = false; center_screen;   end
  def lock_vertical_loop;       @display_loop_v = false; center_screen;   end
  def unlock_horizontal_loop;   @display_loop_h = true;  center_screen;   end
  def unlock_vertical_loop;     @display_loop_v = true;  center_screen;   end
  #--------------------------------------------------------------------------
  # * Calculate X Coordinate, Minus Display Coordinate
  #--------------------------------------------------------------------------
  def adjust_x(x)
    if display_loop_horizontal? && x < @display_x - (width - screen_tile_x) / 2
      x - @display_x + @map.width
    else
      x - @display_x
    end
  end
  #--------------------------------------------------------------------------
  # * Calculate Y Coordinate, Minus Display Coordinate
  #--------------------------------------------------------------------------
  def adjust_y(y)
    if display_loop_vertical? && y < @display_y - (height - screen_tile_y) / 2
      y - @display_y + @map.height
    else
      y - @display_y
    end
  end
  #--------------------------------------------------------------------------
  # * Set Display Position
  #--------------------------------------------------------------------------
  def set_display_pos(x, y)
    x = [0, [x, width - screen_tile_x].min].max unless display_loop_horizontal?
    y = [0, [y, height - screen_tile_y].min].max unless display_loop_vertical?
    @display_x = (x + width) % width
    @display_y = (y + height) % height
    @parallax_x = x
    @parallax_y = y
  end
  #--------------------------------------------------------------------------
  # * Scroll Down
  #--------------------------------------------------------------------------
  def scroll_down(distance)
    if display_loop_vertical?
      @display_y += distance
      @display_y %= @map.height
      @parallax_y += distance if @parallax_loop_y
    else
      last_y = @display_y
      @display_y = [@display_y + distance, height - screen_tile_y].min
      @parallax_y += @display_y - last_y
    end
  end
  #--------------------------------------------------------------------------
  # * Scroll Left
  #--------------------------------------------------------------------------
  def scroll_left(distance)
    if display_loop_horizontal?
      @display_x += @map.width - distance
      @display_x %= @map.width 
      @parallax_x -= distance if @parallax_loop_x
    else
      last_x = @display_x
      @display_x = [@display_x - distance, 0].max
      @parallax_x += @display_x - last_x
    end
  end
  #--------------------------------------------------------------------------
  # * Scroll Right
  #--------------------------------------------------------------------------
  def scroll_right(distance)
    if display_loop_horizontal?
      @display_x += distance
      @display_x %= @map.width
      @parallax_x += distance if @parallax_loop_x
    else
      last_x = @display_x
      @display_x = [@display_x + distance, (width - screen_tile_x)].min
      @parallax_x += @display_x - last_x
    end
  end
  #--------------------------------------------------------------------------
  # * Scroll Up
  #--------------------------------------------------------------------------
  def scroll_up(distance)
    if display_loop_vertical?
      @display_y += @map.height - distance
      @display_y %= @map.height
      @parallax_y -= distance if @parallax_loop_y
    else
      last_y = @display_y
      @display_y = [@display_y - distance, 0].max
      @parallax_y += @display_y - last_y
    end
  end
end

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# - command_354
#   Return to title now return to profile screen
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Lock / Unlock display loops
  #--------------------------------------------------------------------------
  def lock_horizontal_loop;     $game_map.lock_horizontal_loop;       end
  def lock_vertical_loop;       $game_map.lock_vertical_loop;         end
  def unlock_horizontal_loop;   $game_map.unlock_horizontal_loop;     end
  def unlock_vertical_loop;     $game_map.unlock_vertical_loop;       end
end
Last edit : 19/04/20
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Hey there everyone! My laptop broke unexpectedly recently and I lost some files I hadn't backed up . . .
Pro tip to anyone looking for advice based on existing game mechanics: a lot of people reading your request won't have played the games you're talking about. Always assume your readers won't have, and explain what the mechanic actually *does* rather than just name-dropping the game. I see this a lot.
 …So I was looking at a question someone had asked and did some related experimentation. Apparently the Jump… movement route command works like the ultimate through. Including letting you move around outside the confines of the map entirely. o_O
Jump.png
Okay so today I heard the dumbest theory I have heard in a loooooooong while. It's so stupid I just have to share... Appearantly I have learned to draw 'hot chicks' so that 'real men' get physically excited by looking at it and I can then swoop in and 'turn' them.... Wow... Just... Amazing how some brains works...
What the writer wrote: "The curtain is blue."
The readers: "There must be a hidden meaning behind this, perhaps to convey the character emotions ...".
What the writer has in mind: "The curtain is frickin' blue".

Forum statistics

Threads
115,849
Messages
1,093,393
Members
151,045
Latest member
EmDaMM
Top