Help - Search - Members - Calendar
Full Version: Platform Game Script
RPG RPG Revolution Forums > Scripting > Script Submissions > RGSS-Submissions
Creepy
Platform Game Script - By XRXS

I dont know if you people need it. but this script is for creating a platform game in rmxp:

Paste a new screen above main:
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


Platform games- Mario style games
Armor Nick
What are the controls for this script?
Creepy
Up to jump and Z for a high jump
Guardian Drayal
Is there a means of calling this script when it is needed and then turning it off when it is not?
Creepy
When you use this script you have to use it for the whole game.
You were planning on making a mini-game right?
Guardian Drayal
I was and still am planning on the mini-game. I just happened across this while browsing, having intended to make that mini-game without a script. If this can only be used for a whole game...then perhaps I can just put it on the side until I decide I'd like to make a whole game in that regard.
Jack Sparrow
Im sorry, but the jump did not jump very high even when I pressed the z button. It only jumped about 2 frames (i. e. 2 squares worth on the Grid in Edit mode).
kito13
could u post a screenshot please?!!?!?!?!
Omega Coriel
i got a problem with line 25
it says undefined superclass Game_Character
I got a licensed copy of RPGXP and looking at the one most ppl download the wording is very much diffrent so i need someone to help me convert this a bit.
[EDIT: WTF.. i didn't post this here... did i? I haven't tried this script XP
platipus
You can only jump in the same spot? I want to be able to jump over atleast 2-3 spaces forward. =/
jens009
QUOTE (platipus @ Jun 18 2006, 12:47 PM)
You can only jump in the same spot? I want to be able to jump over atleast 2-3 spaces forward. =/
*


Well then you have to modify the script... Or use the powers of event,

Sometimes doing it your way is better
pugonot
inside your script is subheadings with scene_map etc, do i have to paste these at the top of the actual default scripts, replace the defaults? because nothing happens when script is inserted whole. please help
jens009
QUOTE (pugonot @ Jun 18 2006, 06:28 PM)
inside your script is subheadings with scene_map etc, do i have to paste these at the top of the actual default scripts, replace the defaults? because nothing happens when script is inserted whole. please help
*



Its says on Creepy's post that you should paste it above Main
pugonot
cheers, strangley didnt work first time. is there a way to change height of jump?
also i would like to disable to smaller up arrow jump. plus it would be great if such a script could b disabled and enabled?
jens009
QUOTE (pugonot @ Jun 18 2006, 10:13 PM)
cheers, strangley didnt work first time. is there a way to change height of jump?
also i would like to disable to smaller up arrow jump. plus it would be great if such a script could b disabled and enabled?
*


I'm not sure if you could really change the height of the jump b but you could modify this line

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

Change the numbers

No the script cant be disabled/ enabled this script is platform all the way through your game
platipus
how do i make char jump 1 or two spaces? Sorry, I'm not really understanding the scripts.
Prince Of Sorrow
any way to add enemy that's can kill them by jump on there heads ?
BTW
I'd like to turn the script off and on it on special case ? any ways ?!
Rast
QUOTE
I'd like to turn the script off and on it on special case ? any ways ?!


I don't know scripting very well, but try adding in a line at the beggining of the script that says:

CODE
if Platform_Script=true


And then add a line at the end that says:

CODE
else (insert something here)


NOTE 1: I don't really know what you could put after "else" to make the game run normally. Find something.

NOTE 2: I'm not an experianced scripter; Make a backup before you try this, or at least memorize what you did so you can fix it.
Nicky OsO
If you want to make your character jump higher you can make an event:
make an event(parralel process)
conditional branch, button up pressed
and then set move route player y + (the number of spaces you want it to jump higher)


EDIT: This doesn't work,, because you can keep on pressing up as much if you want..
ironhustla
tO JUMP HIGHER FIND THIS LINE $game_player.jump(direction, -2)
Shadez-
QUOTE (ironhustla @ May 6 2008, 09:12 PM) *
tO JUMP HIGHER FIND THIS LINE $game_player.jump(direction, -2)



And what's next? i edited it, and nothing happend huh.gif
willman10000
QUOTE (CREEPY @ Jan 13 2006, 11:05 PM) *
Platform Game Script - By XRXS

I dont know if you people need it. but this script is for creating a platform game in rmxp:
CODE
i removed the script because it would make the post too long

Platform games- Mario style games

here is a translated vesion
CODE
# ▼ ▲ ▼ XRXS50. Action-Maps XC. ▼ ▲ ▼ built 033010
# By Masashi Sakura in soil

#================================================= =============================
# □ customized points
#================================================= =============================
class XRXS50
#
# Action-Maps to map out running an array of ID
#
ENABLE_FULL_ACTY_MAPS = [1, 2]
#
# "Slight drop"
#
ENABLE_SLIDE_DESCENT = true
#
# Orientation jump (true: Directions jump.
# False: that the key is pressed toward the jump. )
#
JUMP_AS_KEY = false
end
#================================================= =============================
# ■ Game_Player
#================================================= =============================
class Game_Player <Game_Character
#------------------------------------------------- -------------------------
# ○ published instance variable
#------------------------------------------------- -------------------------
Existing #
attr_writer: direction_fix
attr_accessor: walk_anime
New #
attr_accessor: now_jumps
attr_writer: xrxs50_direction_sidefix
#------------------------------------------------- -------------------------
# ○ biggest jump Views
#------------------------------------------------- -------------------------
def max_jumps
return 1
end
#------------------------------------------------- -------------------------
# ● face to the left
#------------------------------------------------- -------------------------
alias xrxs50_turn_left turn_left
def turn_left
if @ xrxs50_direction_sidefix
@ direction = 4
else
xrxs50_turn_left
end
end
#------------------------------------------------- -------------------------
# ● face to the right
#------------------------------------------------- -------------------------
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
#------------------------------------------------- -------------------------
# ● main processing
#------------------------------------------------- -------------------------
alias xrxs50_main main
def main
Check #
xrxs50_enable_check
# Recall
xrxs50_main
end
#------------------------------------------------- -------------------------
# ● frame update
#------------------------------------------------- -------------------------
alias xrxs50_update update
def update
# Recall
xrxs50_update
Update # frame (coordinates updated)
if @ xrxs50_enable
update_coordinates
end
end
#------------------------------------------------- -------------------------
Update # ○ frame (coordinates updated)
#------------------------------------------------- -------------------------
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
#------------------------------------------------- -------------------------
# ● players moved
#------------------------------------------------- -------------------------
alias xrxs50_transfer_player transfer_player
def transfer_player
# Recall
xrxs50_transfer_player
Check #
xrxs50_enable_check
end
#------------------------------------------------- -------------------------
# ○ XRXS50 will determine the running
#------------------------------------------------- -------------------------
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

all i did was put it through google translator nothing else

Spoilt for your reading pleasure - Night_Runner
Ketsueki_Hinata
For those of you who want to disable the ''up jump'' you have to find the actual game script that's saying ''if the player's pressing up, move up'' Its in Game_Player under frame update
CODE

when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up

that's what it is initially, we want it to be
CODE

when 2
move_down
when 4
move_left
when 6
move_right
#when 8
# move_up

Hope this helps you guys -^.^-
Or opposed to commenting it out, like I did (In case I later change my mind) you can delete it, It should have the same effect.
Redd
There is a much better script of this on rmxp.org that you can turn off and on. Not sure about jumping 2 or 3 spaces forward, but I do remember the creator saying something about changing the amount of jump.

And jens009 is right. Most of the time it is better to do it your own way or with events.

EDIT: Here is the rmxp.org script:

http://www.rmxp.org/forums/viewtopic.php?t=29178.0

EDIT: EDIT: DAMMIT! Doesn't work anymore. None of the downloads work. IF anyone has ever found a working version or has one even, post it here because this version is crap.
Night_Runner
On line 11, it has:
CODE
ENABLE_FULL_ACTY_MAPS = [1, 2]

This makes maps with IDs 1 and 2 work with the script, so maps 3, 4, 5, etc will run normally.


EDIT:
On line 125 it has:
CODE
$game_player.jump(direction, -2)

Change the -2 to something more appropriate, say -8
Torama
is there a way to make the character move faster is say the Y key was pressed (S button on keyboard) and then if that is pressed and held down and you jump it jumps twice as far? I have a dash script. So maybe even if this just detects the Y pressed and it makes the jump longer
AerteK
Nice script but i dont quite understand what it is used for?
Night_Runner
The basic jist of the entire script:
If the up button is pressed, jump up several squares (just like a normal move event command)
If left is pressed, move down-left / left
If right is pressed, move down-right / right
If nothing is pressed, move down

If sort of makes the game feel like a 2D side scroller, like all the classic Super Mario games, you can walk left and right, jump up and watch as gravity pulls you back to the ground, and if you event it, you can kill your enemies by jumping on their heads smile.gif

But this script is more designed to do this in a mini-game situation smile.gif
apsis
QUOTE (Guardian Drayal @ Jan 22 2006, 06:50 PM) *
I was and still am planning on the mini-game. I just happened across this while browsing, having intended to make that mini-game without a script. If this can only be used for a whole game...then perhaps I can just put it on the side until I decide I'd like to make a whole game in that regard.

You could try makeing a "parallel process" event that calls this script. I think then, if you're not on the same map, the script won't effect you.
Torama
sorry to ressurect this, but the version I have from the same creator actually has it set up so that it is only on maps you select.. maybe I have an older version?

CODE
# ??? XRXS50. Action-Maps XC. ??? built 033010
# by ?? ??

#==============================================================================
# ? ??????????
#==============================================================================
class XRXS50
#
# Action-Maps ?????????ID???
#
ENABLE_FULL_ACTY_MAPS = [1,2,3] # maps used for side scroller
#
# ??????
#
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 = 2 # jump distance
         elsif Input.press?(Input::LEFT)
           direction = -2 # Jump distance
         else
           direction = 0
         end
       end
       $game_player.jump(direction, -3) # jump hight
       $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


Spoilt for your reading pleasure - Night_Runner
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.