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.

Help with platformer script issues [XP]

Greetings all that read this thread, I thank you for taking time out of your day to try and help me

I am currently working on a platformer game in RPG Maker XP, and I have found that there are some things I need some help with, as I do not know much coding as it is.

First let me specify, for the jumping I am currently using a code that I found on a japanese website a long time ago that I happened upon again recently, it functions moderately well but there are some things I was hoping to alter but I don't have the slightest idea how to do so, I'll post the code first:

Code:
# ▼▲▼ XRXS50. Action-Maps XC. ▼▲▼ built 033010

# by 桜雅 在土

 

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

# □ カスタマイズポイント

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

class XRXS50

 #

 # Action-Maps を稼動させるマップIDの配列

 #

 ENABLE_FULL_ACTY_MAPS = [1, 2]

 #

 # 「斜め降下」

 #

 ENABLE_SLIDE_DESCENT = true

 #

 # 向きジャンプ(true  : 向いている方向へジャンプ。

 #              false : キーが押されている方向へジャンプ。)

 #

 JUMP_AS_KEY = false

end

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

# ■ Game_Player

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

class Game_Player < Game_Character

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

 # ○ 公開インスタンス変数

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

 # 既存

 attr_writer   :direction_fix

 attr_accessor :walk_anime

 # 新規

 attr_accessor :now_jumps

 attr_writer   :xrxs50_direction_sidefix

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

 # ○ 最大ジャンプ回数

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

 def max_jumps

   return 1

 end

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

 # ● 左を向く

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

 alias xrxs50_turn_left turn_left

 def turn_left

   if @xrxs50_direction_sidefix

     @direction = 4

   else

     xrxs50_turn_left

   end

 end

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

 # ● 右を向く

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

 alias xrxs50_turn_right turn_right

 def turn_right

   if @xrxs50_direction_sidefix

     @direction = 6

   else

     xrxs50_turn_right

   end

 end

end

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

# ■ Scene_Map

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

class Scene_Map

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

 # ● メイン処理

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

 alias xrxs50_main main

 def main

   # チェック

   xrxs50_enable_check

   # 呼び戻す

   xrxs50_main

 end

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

 # ● フレーム更新

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

 alias xrxs50_update update

 def update

   # 呼び戻す

   xrxs50_update

   # フレーム更新 (座標系更新)

   if @xrxs50_enable

     update_coordinates

   end

 end

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

 # ○ フレーム更新 (座標系更新)

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

 def update_coordinates

   if $game_player.passable?($game_player.x,$game_player.y,2)

     unless $game_player.moving?

       if XRXS50::ENABLE_SLIDE_DESCENT and

          Input.press?(Input::RIGHT) and

          $game_player.passable?($game_player.x,$game_player.y+1,6)

         $game_player.move_lower_right

       elsif XRXS50::ENABLE_SLIDE_DESCENT and

             Input.press?(Input::LEFT) and

             $game_player.passable?($game_player.x,$game_player.y+1,4)

         $game_player.move_lower_left

       else

         $game_player.move_down

       end

     end

   else

     $game_player.move_down

     $game_player.walk_anime = true unless $game_player.walk_anime

     $game_player.now_jumps  = 0

     if Input.trigger?(Input::X) and

        $game_player.now_jumps < $game_player.max_jumps

       if XRXS50::JUMP_AS_KEY

         direction = $game_player.direction == 4 ? -1 : 1

       else

         if Input.press?(Input::RIGHT)

           direction = 1

         elsif Input.press?(Input::LEFT)

           direction = -1

         else

           direction = 0

         end

       end

       $game_player.jump(direction, -2)

       $game_player.now_jumps += 1

       $game_player.walk_anime = false

     end

   end

 end

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

 # ● プレイヤーの場所移動

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

 alias xrxs50_transfer_player transfer_player

 def transfer_player

   # 呼び戻す

   xrxs50_transfer_player

   # チェック

   xrxs50_enable_check

 end

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

 # ○ XRXS50 が稼動するか判定

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

 def xrxs50_enable_check

   if XRXS50::ENABLE_FULL_ACTY_MAPS.include?($game_map.map_id)

     $game_player.now_jumps = 0 if $game_player.now_jumps.nil?

     @xrxs50_enable = true

     $game_player.direction_fix = true

     $game_player.xrxs50_direction_sidefix = true

   else

     @xrxs50_enable = false

     $game_player.direction_fix = false

     $game_player.xrxs50_direction_sidefix = false

   end

 end

end

Now, at this point in time the code causes a very angular jump, where the player goes up at an angle and then sharply changes direction downward, It was my thought that maybe if they traveled a tile ahead before falling the jump would at least look slightly more arched and less like they hit something (I'm using pixel movement as well right now if that helps anything at all).
The gravity of the descent is also rather odd, it seems like the player slows down on the fall, but I don't know where to change that to speed it up even slightly. So if someone could help me fix up the code to alleviate these issues it'd be much appreciated.

On a similar note, I would like to remove upward movement in the script, but not remove the up key itself.
To explain this: I would like to get rid of the player's ability to move up on the map, but I am working on my sprite set so that when facing up, the player looks up, and also be able to shoot upward as well by pressing up, while not being able to move up (If that was worded a little confusing I can try to show an example of what I mean).

I do have more questions but rather than pile up a list I'd be happy if someone could just help me with these things, I'm wholeheartedly willing to credit all those who've helped me in any way, and I thank in advance all those who offer to help at all :)

Thank you again
-Adam
 

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