Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
Hi folks, I have a question about the RMXP.
I want to do some kind of side scrolling fighting game. Similar to the snes Turtle games or Street of Rage you already know. It becomes very simple and consists only of punch and kick. But my problem now is the following: The character should only be allowed to look left and right. Above and below should be deactivated or used differently. Can I change how the player behaves up and down somewhere?
Thanks for reading my question.
 

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
57
Reaction score
52
First Language
Português - BR
Primarily Uses
RMMZ
Ruby:
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Turn Down
  #--------------------------------------------------------------------------
  def turn_down
    set_direction(2)
  end
  #--------------------------------------------------------------------------
  # * Turn Left
  #--------------------------------------------------------------------------
  def turn_left
    set_direction(4)
  end
  #--------------------------------------------------------------------------
  # * Turn Right
  #--------------------------------------------------------------------------
  def turn_right
    set_direction(6)
  end
  #--------------------------------------------------------------------------
  # * Turn Up
  #--------------------------------------------------------------------------
  def turn_up
    set_direction(8)
  end
  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  def move_lower_left
    # If no direction fix
    unless @direction_fix
      # Face down is facing right or up
      set_direction(4) if @direction == reverse_dir(4)
      set_direction(2) if @direction == reverse_dir(2)
    end
    # When a down to left or a left to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      # Update coordinates
      @x -= 1
      @y += 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right
  #--------------------------------------------------------------------------
  def move_lower_right
    # If no direction fix
    unless @direction_fix
      # Face right if facing left, and face down if facing up
      set_direction(6) if @direction == reverse_dir(6)
      set_direction(2) if @direction == reverse_dir(2)
    end
    # When a down to right or a right to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      # Update coordinates
      @x += 1
      @y += 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left
  #--------------------------------------------------------------------------
  def move_upper_left
    # If no direction fix
    unless @direction_fix
      # Face left if facing right, and face up if facing down
      set_direction(4) if @direction == reverse_dir(4)
      set_direction(8) if @direction == reverse_dir(8)
    end
    # When an up to left or a left to up course is passable
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      # Update coordinates
      @x -= 1
      @y -= 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Right
  #--------------------------------------------------------------------------
  def move_upper_right
    # If no direction fix
    unless @direction_fix
      # Face right if facing left, and face up if facing down
      set_direction(6) if @direction == reverse_dir(6)
      set_direction(8) if @direction == reverse_dir(8)
    end
    # When an up to right or a right to up course is passable
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      # Update coordinates
      @x += 1
      @y -= 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Set Direction
  #--------------------------------------------------------------------------
  def set_direction(d)
    @direction  = d if !@direction_fix && d != 0
    @stop_count = 0
  end
  #--------------------------------------------------------------------------
  # * Reverse Direction
  #--------------------------------------------------------------------------
  def reverse_dir(d)
    return 10 - d
  end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Set Direction
  #--------------------------------------------------------------------------
  alias __210927_aliased_set_direction set_direction
  def set_direction(d)
    __210927_aliased_set_direction(d) if ((d - 5).abs == 1)
  end
end
 

ovate

tale
Veteran
Joined
Dec 16, 2016
Messages
893
Reaction score
1,523
First Language
English
Primarily Uses
N/A
Script above works on vx ace and vx.

Edit: it does work for xp, not at first glance- if default facing direction is down or up.

- - - - -

Temporary solution

Tools tab > Script Editor or press F11 key

Look for the script Game_Player which is below Game_Event

On 216 line put # in front of move_down and on 222 line put # in front of move_up

Should look like this-

Code:
        #move_down
      when 4
        move_left
      when 6
        move_right
      when 8
        #move_up

Up and down still works on menu however disabled player moving direction for up and down.
 
Last edited:

Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
thank you all. My problem is solved. I can do the rest of my idea with events
 

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
57
Reaction score
52
First Language
Português - BR
Primarily Uses
RMMZ
I would definitely not recommend using # at the beginning of lines to make the interpreter ignore them directly in the base code, this is not good practice.
And my code definitely works on XP. lol

And to make the character start in a horizontal direction:
Ruby:
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Turn Down
  #--------------------------------------------------------------------------
  def turn_down
    set_direction(2)
  end
  #--------------------------------------------------------------------------
  # * Turn Left
  #--------------------------------------------------------------------------
  def turn_left
    set_direction(4)
  end
  #--------------------------------------------------------------------------
  # * Turn Right
  #--------------------------------------------------------------------------
  def turn_right
    set_direction(6)
  end
  #--------------------------------------------------------------------------
  # * Turn Up
  #--------------------------------------------------------------------------
  def turn_up
    set_direction(8)
  end
  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  def move_lower_left
    # If no direction fix
    unless @direction_fix
      # Face down is facing right or up
      set_direction(4) if @direction == reverse_dir(4)
      set_direction(2) if @direction == reverse_dir(2)
    end
    # When a down to left or a left to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      # Update coordinates
      @x -= 1
      @y += 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right
  #--------------------------------------------------------------------------
  def move_lower_right
    # If no direction fix
    unless @direction_fix
      # Face right if facing left, and face down if facing up
      set_direction(6) if @direction == reverse_dir(6)
      set_direction(2) if @direction == reverse_dir(2)
    end
    # When a down to right or a right to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      # Update coordinates
      @x += 1
      @y += 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left
  #--------------------------------------------------------------------------
  def move_upper_left
    # If no direction fix
    unless @direction_fix
      # Face left if facing right, and face up if facing down
      set_direction(4) if @direction == reverse_dir(4)
      set_direction(8) if @direction == reverse_dir(8)
    end
    # When an up to left or a left to up course is passable
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      # Update coordinates
      @x -= 1
      @y -= 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Right
  #--------------------------------------------------------------------------
  def move_upper_right
    # If no direction fix
    unless @direction_fix
      # Face right if facing left, and face up if facing down
      set_direction(6) if @direction == reverse_dir(6)
      set_direction(8) if @direction == reverse_dir(8)
    end
    # When an up to right or a right to up course is passable
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      # Update coordinates
      @x += 1
      @y -= 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Set Direction
  #--------------------------------------------------------------------------
  def set_direction(d)
    @direction  = d if !@direction_fix && d != 0
    @stop_count = 0
  end
  #--------------------------------------------------------------------------
  # * Reverse Direction
  #--------------------------------------------------------------------------
  def reverse_dir(d)
    return 10 - d
  end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias __210927_aliased_initialize initialize
  def initialize
    __210927_aliased_initialize
    @direction = 6
  end
  #--------------------------------------------------------------------------
  # * Set Direction
  #--------------------------------------------------------------------------
  alias __210927_aliased_set_direction set_direction
  def set_direction(d)
    __210927_aliased_set_direction(d) if ((d - 5).abs == 1)
  end
end
 

Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
The solution from ovate was enough for me at first, but now that I tried JorgeMakers script again, I noticed that it worked perfectly and I was looking for exactly that. Thank you both.
 

Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
When I use your script everything works fine. There is only one problem: When I restart with F12, the following message appears when I select New Game.
 

Attachments

  • Unbenannt-1.png
    Unbenannt-1.png
    5 KB · Views: 1

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
57
Reaction score
52
First Language
Português - BR
Primarily Uses
RMMZ
I cannot reproduce the error here. It might be a problem with other scripts you use in your project.
 

Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
Hmm ok that's strange because I don't use any other script at all. But if it doesn't happen to you, something must be wrong with my game.
 

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
57
Reaction score
52
First Language
Português - BR
Primarily Uses
RMMZ
If my script is the only one you're using in your project, then for some reason your game is reloading the scripts when you press F12. That's an assumption, but I also don't know why that would be happening.
 

Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
I actually only use your script. It was right of me to past it over Main, wasn't it?
 

Attachments

  • Unbenannt-1.png
    Unbenannt-1.png
    21.2 KB · Views: 5

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
57
Reaction score
52
First Language
Português - BR
Primarily Uses
RMMZ
Replace with this code:
It won't solve anything, I just want you to tell me if the window that says "TEST" appears after you press F12.

Ruby:
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Turn Down
  #--------------------------------------------------------------------------
  def turn_down
    set_direction(2)
  end
  #--------------------------------------------------------------------------
  # * Turn Left
  #--------------------------------------------------------------------------
  def turn_left
    set_direction(4)
  end
  #--------------------------------------------------------------------------
  # * Turn Right
  #--------------------------------------------------------------------------
  def turn_right
    set_direction(6)
  end
  #--------------------------------------------------------------------------
  # * Turn Up
  #--------------------------------------------------------------------------
  def turn_up
    set_direction(8)
  end
  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  def move_lower_left
    # If no direction fix
    unless @direction_fix
      # Face down is facing right or up
      set_direction(4) if @direction == reverse_dir(4)
      set_direction(2) if @direction == reverse_dir(2)
    end
    # When a down to left or a left to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      # Update coordinates
      @x -= 1
      @y += 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right
  #--------------------------------------------------------------------------
  def move_lower_right
    # If no direction fix
    unless @direction_fix
      # Face right if facing left, and face down if facing up
      set_direction(6) if @direction == reverse_dir(6)
      set_direction(2) if @direction == reverse_dir(2)
    end
    # When a down to right or a right to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      # Update coordinates
      @x += 1
      @y += 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left
  #--------------------------------------------------------------------------
  def move_upper_left
    # If no direction fix
    unless @direction_fix
      # Face left if facing right, and face up if facing down
      set_direction(4) if @direction == reverse_dir(4)
      set_direction(8) if @direction == reverse_dir(8)
    end
    # When an up to left or a left to up course is passable
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      # Update coordinates
      @x -= 1
      @y -= 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Right
  #--------------------------------------------------------------------------
  def move_upper_right
    # If no direction fix
    unless @direction_fix
      # Face right if facing left, and face up if facing down
      set_direction(6) if @direction == reverse_dir(6)
      set_direction(8) if @direction == reverse_dir(8)
    end
    # When an up to right or a right to up course is passable
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      # Update coordinates
      @x += 1
      @y -= 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Set Direction
  #--------------------------------------------------------------------------
  def set_direction(d)
    @direction  = d if !@direction_fix && d != 0
    @stop_count = 0
  end
  #--------------------------------------------------------------------------
  # * Reverse Direction
  #--------------------------------------------------------------------------
  def reverse_dir(d)
    return 10 - d
  end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias __210927_aliased_initialize initialize
  def initialize
    __210927_aliased_initialize
    @direction = 6
  end
  #--------------------------------------------------------------------------
  # * Set Direction
  #--------------------------------------------------------------------------
  alias __210927_aliased_set_direction set_direction
  def set_direction(d)
    __210927_aliased_set_direction(d) if ((d - 5).abs == 1)
  end
end
p 'TEST'
 

Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
Yes, it says TEST when I start a playtest or press F12 during the playtest.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,742
Reaction score
15,312
First Language
English
Primarily Uses
RMMV

I've moved this thread to RGSS Script Requests. Thank you.

 

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
57
Reaction score
52
First Language
Português - BR
Primarily Uses
RMMZ
Yes, it says TEST when I start a playtest or press F12 during the playtest.
Well, just as I imagined, your version of RMXP is not only loading scripts when starting playtest, but also when restarting playtest.
At least based on my version of the RMXP, that shouldn't happen. Try creating a new project, reinstall the program, I really don't know exactly what's going on.
 

Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
Ok thank you for the effort. I have the Steam version. Maybe this is a little different.
 

Orphelius

Villager
Member
Joined
Sep 3, 2018
Messages
18
Reaction score
2
First Language
German
Primarily Uses
RMXP
I've never heard of xp ace honestly. I have the normal XP Steam version. But this ThallionDarkshine solution doesn't work for me. When I use his script, the scripts are no longer loaded after a reset. ForeverZer0's solution works for me.

if $ game_exists
Thread.new {system ('Game')}
exit
end
$ game_exists = true

The only problem is that it can happen that I open the test play twice. But I'll accept that as long as I can use JorgeMakers script because that's exactly what I'm looking for.
 

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
57
Reaction score
52
First Language
Português - BR
Primarily Uses
RMMZ
Oh well, I've been using XP for years, today I discover something new. lol
It's true, I use XPAce as if it were standard. Thanks for the support, KK20.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
382
Reaction score
149
First Language
English
Primarily Uses
RMXP
But this ThallionDarkshine solution doesn't work for me. When I use his script, the scripts are no longer loaded after a reset.
Can you explain more as to how it doesn't work? I understand if you perhaps made some changes to "Main" that are no longer being called, but you can easily circumvent that by just copying what you have there into TD's script.

But I'm assuming your project, as you described, is just a clean, new project with just the scripts from TD and Jorge. Which, on my end, work fine.
 

Latest Threads

Latest Posts

Latest Profile Posts

I'm so annoyed with myself...I can't get this code to work so it looks like I'm going the plugin route for a problem I should be able to do myself :kaolivid:Great. Now I get to murder save file compatibility. Again.
Can't believe my code from four years ago is still working! Did some expansions, and...
1635194553179.png
In related news, I may have an update for my old Extra status window plugin ready. That is, once I manage to sit down and update the documentation... and the demo project... :kaoswt:
How does one pronounce Godot? I've heard it pronounced a couple of different ways, and I genuinely don't know the proper way.
March 2020 ...
1635188823939.jpeg
... vs October 2021
You look like you had a rough day...Here, have a Baby Panda!

Forum statistics

Threads
116,077
Messages
1,095,542
Members
151,441
Latest member
guertena_1
Top