|
| | Agrandir ou rétrécir le héros ou l'équipe | |
| | Auteur | Message |
---|
xonon Poète Anonyme
Nombre de messages : 233 Age : 31 Projet(s) en cours : Snoworld Niveau Rpg Maker : Moyen Jeux Préférés : Okami, FF12, Dragon Quest 8, ... Date d'inscription : 27/07/2007
| Sujet: Agrandir ou rétrécir le héros ou l'équipe Dim 29 Juil 2007, 15:19 | |
| Auteur: inconnu Fonction: permet d'agrandir ou de rétrécir le héros ou l'équipe Screens:Suivez bien car il y a assez bien de scripts à installer et qu'ils sont générallement long: Ouvrez l'éditeur de scripts ( F11), créez un nouveau script au-dessus de "Main" et nommez-le "Caterpillar", puis collez-y le code suivant: - Code:
-
TRAIN_ACTOR_TRANSPARENT_SWITCH = true TRAIN_ACTOR_TRANSPARENT_SWITCHES_INDEX = 20 # ------------------------------------ DOWN_LEFT = 1 DOWN_RIGHT = 3 UP_LEFT = 7 UP_RIGHT = 9 JUMP = 5 # ------------------------------------ class Game_Party_Actor < Game_Character # ------------------------------------ def initialize super() @through = true end # ------------------------------------ def setup(actor) if actor != nil @character_name = actor.character_name @character_hue = actor.character_hue else @character_name = "" @character_hue = 0 end @opacity = 255 @blend_type = 0 end # ------------------------------------ def screen_z(height = 0) if $game_player.x == @x and $game_player.y == @y return $game_player.screen_z(height) - 1 end super(height) end # ------------------------------------ def move_down(turn_enabled = true) if turn_enabled turn_down end if passable?(@x, @y, Input::DOWN) turn_down @y += 1 end end # ------------------------------------ def move_left(turn_enabled = true) if turn_enabled turn_left end if passable?(@x, @y, Input::LEFT) turn_left @x -= 1 end end # ------------------------------------ def move_right(turn_enabled = true) if turn_enabled turn_right end if passable?(@x, @y, Input::RIGHT) turn_right @x += 1 end end # ------------------------------------ def move_up(turn_enabled = true) if turn_enabled turn_up end if passable?(@x, @y, Input::UP) turn_up @y -= 1 end end # ------------------------------------ def move_lower_left unless @direction_fix @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction) end if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN)) @x -= 1 @y += 1 end end # ------------------------------------ def move_lower_right unless @direction_fix @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction) end if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN)) @x += 1 @y += 1 end end # ------------------------------------ def move_upper_left unless @direction_fix @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction) end if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP)) @x -= 1 @y -= 1 end end # ------------------------------------ def move_upper_right unless @direction_fix @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction) end if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP)) @x += 1 @y -= 1 end end # ------------------------------------ def set_move_speed(move_speed) @move_speed = move_speed end end
class Spriteset_Map # ------------------------------------ def setup_actor_character_sprites? return @setup_actor_character_sprites_flag != nil end # ------------------------------------ def setup_actor_character_sprites(characters) if !setup_actor_character_sprites? index_game_player = 0 @character_sprites.each_index do |i| if @character_sprites[i].character.instance_of?(Game_Player) index_game_player = i break end end for character in characters.reverse @character_sprites.unshift( Sprite_Character.new(@viewport1, character) ) end @setup_actor_character_sprites_flag = true end end end
class Scene_Map # ------------------------------------ def setup_actor_character_sprites(characters) @spriteset.setup_actor_character_sprites(characters) end end
class Game_Party # ------------------------------------ def set_transparent_actors(transparent) @transparent = transparent end # ------------------------------------ def setup_actor_character_sprites if @characters == nil @characters = [] for i in 1 .. 4 @characters.push(Game_Party_Actor.new) end end if @actors_chach == nil @actors_chach = [] end if @actors_chach != @actors @actors_chach = @actors.clone for i in 1 .. 4 @characters[i - 1].setup(actors[i]) end end if $scene.instance_of?(Scene_Map) $scene.setup_actor_character_sprites(@characters) end end # ------------------------------------ def update_party_actors setup_actor_character_sprites transparent = $game_player.transparent if transparent == false if TRAIN_ACTOR_TRANSPARENT_SWITCH transparent = $game_switches[TRAIN_ACTOR_TRANSPARENT_SWITCHES_INDEX] else transparent = $game_player.transparent end end for character in @characters character.transparent = transparent character.set_move_speed($game_player.get_move_speed) character.update end end # ------------------------------------ def moveto_party_actors( x, y ) setup_actor_character_sprites for character in @characters character.moveto( x, y ) end if @move_list == nil @move_list = [] end for i in 0 .. 10 @move_list[i] = nil end end def move_party_actors if @move_list == nil @move_list = [] for i in 0 .. 10 @move_list[i] = nil end end @move_list.each_index do |i| if @characters[i] != nil case @move_list[i].type when Input::DOWN @characters[i].move_down(@move_list[i].args[0]) when Input::LEFT @characters[i].move_left(@move_list[i].args[0]) when Input::RIGHT @characters[i].move_right(@move_list[i].args[0]) when Input::UP @characters[i].move_up(@move_list[i].args[0]) when DOWN_LEFT @characters[i].move_lower_left when DOWN_RIGHT @characters[i].move_lower_right when UP_LEFT @characters[i].move_upper_left when UP_RIGHT @characters[i].move_upper_right when JUMP @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1]) end end end end
class Move_List_Element # ------------------------------------ def initialize(type,args) @type = type @args = args end def type() return @type end def args() return @args end end # ------------------------------------ def add_move_list(type,*args) @move_list.unshift(Move_List_Element.new(type,args)).pop end # ------------------------------------ def move_down_party_actors(turn_enabled = true) move_party_actors add_move_list(Input::DOWN,turn_enabled) end # ------------------------------------ def move_left_party_actors(turn_enabled = true) move_party_actors add_move_list(Input::LEFT,turn_enabled) end # ------------------------------------ def move_right_party_actors(turn_enabled = true) move_party_actors add_move_list(Input::RIGHT,turn_enabled) end # ------------------------------------ def move_up_party_actors(turn_enabled = true) move_party_actors add_move_list(Input::UP,turn_enabled) end # ------------------------------------ def move_lower_left_party_actors move_party_actors add_move_list(DOWN_LEFT) end # ------------------------------------ def move_lower_right_party_actors move_party_actors add_move_list(DOWN_RIGHT) end # ------------------------------------ def move_upper_left_party_actors move_party_actors add_move_list(UP_LEFT) end # ------------------------------------ def move_upper_right_party_actors move_party_actors add_move_list(UP_RIGHT) end # ------------------------------------ def jump_party_actors(x_plus, y_plus) move_party_actors add_move_list(JUMP,x_plus, y_plus) end end
module Game_Player_Module # ------------------------------------ def update $game_party.update_party_actors super end # ------------------------------------ def moveto( x, y ) super $game_party.moveto_party_actors( x, y ) end # ------------------------------------ def move_down(turn_enabled = true) if passable?(@x, @y, Input::DOWN) $game_party.move_down_party_actors(turn_enabled) end super(turn_enabled) end # ------------------------------------ def move_left(turn_enabled = true) if passable?(@x, @y, Input::LEFT) $game_party.move_left_party_actors(turn_enabled) end super(turn_enabled) end # ------------------------------------ def move_right(turn_enabled = true) if passable?(@x, @y, Input::RIGHT) $game_party.move_right_party_actors(turn_enabled) end super(turn_enabled) end # ------------------------------------ def move_up(turn_enabled = true) if passable?(@x, @y, Input::UP) $game_party.move_up_party_actors(turn_enabled) end super(turn_enabled) end # ------------------------------------ def move_lower_left if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN)) $game_party.move_lower_left_party_actors end super end # ------------------------------------ def move_lower_right if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN)) $game_party.move_lower_right_party_actors end super end # ------------------------------------ def move_upper_left if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP)) $game_party.move_upper_left_party_actors end super end # ------------------------------------ def move_upper_right if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP)) $game_party.move_upper_right_party_actors end super end # ------------------------------------ def jump(x_plus, y_plus) new_x = @x + x_plus new_y = @y + y_plus if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0) $game_party.jump_party_actors(x_plus, y_plus) end super(x_plus, y_plus) end # ------------------------------------ def get_move_speed return @move_speed end end
class Game_Player include Game_Player_Module end | |
| | | xonon Poète Anonyme
Nombre de messages : 233 Age : 31 Projet(s) en cours : Snoworld Niveau Rpg Maker : Moyen Jeux Préférés : Okami, FF12, Dragon Quest 8, ... Date d'inscription : 27/07/2007
| Sujet: Re: Agrandir ou rétrécir le héros ou l'équipe Dim 29 Juil 2007, 15:20 | |
| Ensuite créez un nouveau script au-dessus de "Main" et nommez-le "Sprite_Character", collez-y le code suivant: - Code:
-
#============================================================================== # ■ Sprite_Character #------------------------------------------------------------------------------ # キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを # 監視し、スプライトの状態を自動的に変化させます。 #==============================================================================
class Sprite_Character < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :character # キャラクター #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # character : キャラクター (Game_Character) #-------------------------------------------------------------------------- def initialize(viewport, character = nil) super(viewport) @character = character if (character.is_a?(Game_Event) and character.list!=nil and character.list[0].code == 108 and character.list[0].parameters == ["w_sm"]) # Here @event_size = true # Here, ^ too else # Here @event_size = false # Here end # Here if $game_map.worldmap # Here @zoom_y = 0.3 # Here @zoom_x = 0.3 # Here elsif $game_map.bigger # Optional @zoom_y = 1.9 # Optional @zoom_x = 1.9 # Optional else # Here @zoom_y = 1 # Here @zoom_x = 1 # Here end # Here update end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # タイル ID、ファイル名、色相のどれかが現在のものと異なる場合 if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue # タイル ID とファイル名、色相を記憶 @tile_id = @character.tile_id @character_name = @character.character_name @character_hue = @character.character_hue # タイル ID が有効な値の場合 if @tile_id >= 384 self.bitmap = RPG::Cache.tile($game_map.tileset_name, @tile_id, @character.character_hue) self.src_rect.set(0, 0, 32, 32) self.ox = 16 self.oy = 32 # タイル ID が無効な値の場合 else self.bitmap = RPG::Cache.character(@character.character_name, @character.character_hue) @cw = bitmap.width / 4 @ch = bitmap.height / 4 self.ox = @cw / 2 self.oy = @ch if @character.is_a?(Game_Player) or @event_size or @character.is_a?(Game_Party_Actor) # Here, for Caterpillar users, if you don't use it: # if @character.is_a?(Game_Player) or @event_size self.zoom_x = @zoom_x # Here self.zoom_y = @zoom_y # Here end end end # 可視状態を設定 self.visible = (not @character.transparent) # グラフィックがキャラクターの場合 if @tile_id == 0 # 転送元の矩形を設定 sx = @character.pattern * @cw sy = (@character.direction - 2) / 2 * @ch self.src_rect.set(sx, sy, @cw, @ch) end # スプライトの座標を設定 self.x = @character.screen_x self.y = @character.screen_y self.z = @character.screen_z(@ch) # 不透明度、合成方法、茂み深さを設定 self.opacity = @character.opacity self.blend_type = @character.blend_type self.bush_depth = @character.bush_depth # アニメーション if @character.animation_id != 0 animation = $data_animations[@character.animation_id] animation(animation, true) @character.animation_id = 0 end end end | |
| | | xonon Poète Anonyme
Nombre de messages : 233 Age : 31 Projet(s) en cours : Snoworld Niveau Rpg Maker : Moyen Jeux Préférés : Okami, FF12, Dragon Quest 8, ... Date d'inscription : 27/07/2007
| Sujet: Re: Agrandir ou rétrécir le héros ou l'équipe Dim 29 Juil 2007, 15:21 | |
| Ensuite créez un nouveau script au-dessus de "Main" et nommez-le "Game_Player", puis collez-y le code suivant: - Code:
-
#============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ # プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #==============================================================================
class Game_Player < Game_Character attr_accessor :move_speed # Here #-------------------------------------------------------------------------- # ● 定数 #-------------------------------------------------------------------------- CENTER_X = (320 - 16) * 4 # 画面中央の X 座標 * 4 CENTER_Y = (240 - 16) * 4 # 画面中央の Y 座標 * 4 #-------------------------------------------------------------------------- # ● 通行可能判定 # x : X 座標 # y : Y 座標 # d : 方向 (0,2,4,6,8) ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用) #-------------------------------------------------------------------------- def passable?(x, y, d) # 新しい座標を求める new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) # 座標がマップ外の場合 unless $game_map.valid?(new_x, new_y) # 通行不可 return false end # デバッグモードが ON かつ CTRL キーが押されている場合 if $DEBUG and Input.press?(Input::CTRL) # 通行可 return true end super end #-------------------------------------------------------------------------- # ● 画面中央に来るようにマップの表示位置を設定 #-------------------------------------------------------------------------- def center(x, y) max_x = ($game_map.width - 20) * 128 max_y = ($game_map.height - 15) * 128 $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max end #-------------------------------------------------------------------------- # ● 指定位置に移動 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def moveto(x, y) super # センタリング center(x, y) # エンカウント カウントを作成 make_encounter_count end #-------------------------------------------------------------------------- # ● 歩数増加 #-------------------------------------------------------------------------- def increase_steps super # 移動ルート強制中ではない場合 unless @move_route_forcing # 歩数増加 $game_party.increase_steps # 歩数が偶数の場合 if $game_party.steps % 2 == 0 # スリップダメージチェック $game_party.check_map_slip_damage end end end #-------------------------------------------------------------------------- # ● エンカウント カウント取得 #-------------------------------------------------------------------------- def encounter_count return @encounter_count end #-------------------------------------------------------------------------- # ● エンカウント カウント作成 #-------------------------------------------------------------------------- def make_encounter_count # サイコロを 2 個振るイメージ if $game_map.map_id != 0 n = $game_map.encounter_step @encounter_count = rand(n) + rand(n) + 1 end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh @move_speed = move_speed # Here # パーティ人数が 0 人の場合 if $game_party.actors.size == 0 # キャラクターのファイル名と色相をクリア @character_name = "" @character_hue = 0 # メソッド終了 return end # 先頭のアクターを取得 actor = $game_party.actors[0] # キャラクターのファイル名と色相を設定 @character_name = actor.character_name @character_hue = actor.character_hue # 不透明度と合成方法を初期化 @opacity = 255 @blend_type = 0 end #-------------------------------------------------------------------------- # ● 同位置のイベント起動判定 #-------------------------------------------------------------------------- def check_event_trigger_here(triggers) result = false # イベント実行中の場合 if $game_system.map_interpreter.running? return result end # 全イベントのループ for event in $game_map.events.values # イベントの座標とトリガーが一致した場合 if event.x == @x and event.y == @y and triggers.include?(event.trigger) # ジャンプ中以外で、起動判定が同位置のイベントなら if not event.jumping? and event.over_trigger? event.start result = true end end end return result end #-------------------------------------------------------------------------- # ● 正面のイベント起動判定 #-------------------------------------------------------------------------- def check_event_trigger_there(triggers) result = false # イベント実行中の場合 if $game_system.map_interpreter.running? return result end # 正面の座標を計算 new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0) new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0) # 全イベントのループ for event in $game_map.events.values # イベントの座標とトリガーが一致した場合 if event.x == new_x and event.y == new_y and triggers.include?(event.trigger) # ジャンプ中以外で、起動判定が正面のイベントなら if not event.jumping? and not event.over_trigger? event.start result = true end end end # 該当するイベントが見つからなかった場合 if result == false # 正面のタイルがカウンターなら if $game_map.counter?(new_x, new_y) # 1 タイル奥の座標を計算 new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0) new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0) # 全イベントのループ for event in $game_map.events.values # イベントの座標とトリガーが一致した場合 if event.x == new_x and event.y == new_y and triggers.include?(event.trigger) # ジャンプ中以外で、起動判定が正面のイベントなら if not event.jumping? and not event.over_trigger? event.start result = true end end end end end return result end #-------------------------------------------------------------------------- # ● 接触イベントの起動判定 #-------------------------------------------------------------------------- def check_event_trigger_touch(x, y) result = false # イベント実行中の場合 if $game_system.map_interpreter.running? return result end # 全イベントのループ for event in $game_map.events.values # イベントの座標とトリガーが一致した場合 if event.x == x and event.y == y and [1,2].include?(event.trigger) # ジャンプ中以外で、起動判定が正面のイベントなら if not event.jumping? and not event.over_trigger? event.start result = true end end end return result end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ローカル変数に移動中かどうかを記憶 last_moving = moving? # 移動中、イベント実行中、移動ルート強制中、 # メッセージウィンドウ表示中のいずれでもない場合 unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing # 方向ボタンが押されていれば、その方向へプレイヤーを移動 case Input.dir4 when 2 move_down when 4 move_left when 6 move_right when 8 move_up end end # ローカル変数に座標を記憶 last_real_x = @real_x last_real_y = @real_y super # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合 if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # マップを下にスクロール $game_map.scroll_down(@real_y - last_real_y) end # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合 if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # マップを左にスクロール $game_map.scroll_left(last_real_x - @real_x) end # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合 if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # マップを右にスクロール $game_map.scroll_right(@real_x - last_real_x) end # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合 if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # マップを上にスクロール $game_map.scroll_up(last_real_y - @real_y) end # 移動中ではない場合 unless moving? # 前回プレイヤーが移動中だった場合 if last_moving # 同位置のイベントとの接触によるイベント起動判定 result = check_event_trigger_here([1,2]) # 起動したイベントがない場合 if result == false # デバッグモードが ON かつ CTRL キーが押されている場合を除き unless $DEBUG and Input.press?(Input::CTRL) # エンカウント カウントダウン if @encounter_count > 0 @encounter_count -= 1 end end end end # C ボタンが押された場合 if Input.trigger?(Input::C) # 同位置および正面のイベント起動判定 check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end end | |
| | | xonon Poète Anonyme
Nombre de messages : 233 Age : 31 Projet(s) en cours : Snoworld Niveau Rpg Maker : Moyen Jeux Préférés : Okami, FF12, Dragon Quest 8, ... Date d'inscription : 27/07/2007
| Sujet: Re: Agrandir ou rétrécir le héros ou l'équipe Dim 29 Juil 2007, 15:27 | |
| Puis créez un nouveau script au-dessus de "Main" et nommez-le "Game_Map", et collez-y le code suivant: - Code:
-
#============================================================================== # ■ Game_Map #------------------------------------------------------------------------------ # マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。 # このクラスのインスタンスは $game_map で参照されます。 #==============================================================================
class Game_Map #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :tileset_name # タイルセット ファイル名 attr_accessor :autotile_names # オートタイル ファイル名 attr_accessor :panorama_name # パノラマ ファイル名 attr_accessor :panorama_hue # パノラマ 色相 attr_accessor :fog_name # フォグ ファイル名 attr_accessor :fog_hue # フォグ 色相 attr_accessor :fog_opacity # フォグ 不透明度 attr_accessor :fog_blend_type # フォグ ブレンド方法 attr_accessor :fog_zoom # フォグ 拡大率 attr_accessor :fog_sx # フォグ SX attr_accessor :fog_sy # フォグ SY attr_accessor :battleback_name # バトルバック ファイル名 attr_accessor :display_x # 表示 X 座標 * 128 attr_accessor :display_y # 表示 Y 座標 * 128 attr_accessor :need_refresh # リフレッシュ要求フラグ attr_reader :passages # 通行 テーブル attr_reader :priorities # プライオリティ テーブル attr_reader :terrain_tags # 地形タグ テーブル attr_reader :events # イベント attr_reader :fog_ox # フォグ 原点 X 座標 attr_reader :fog_oy # フォグ 原点 Y 座標 attr_reader :fog_tone # フォグ 色調 attr_accessor :worldmap # Here attr_accessor :bigger # Optional #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @map_id = 0 @display_x = 0 @display_y = 0 @worldmap = false # Here @bigger = false # Optional end #-------------------------------------------------------------------------- # ● セットアップ # map_id : マップ ID #-------------------------------------------------------------------------- def setup(map_id) # マップ ID を @map_id に記憶 @map_id = map_id # マップをファイルからロードし、@map に設定 @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id)) if self.name.include?("*W") # Here @bigger = false # Here @worldmap = true # Optional $game_player.move_speed = 2 # Optional elsif self.name.include?("*B") # Optional @worldmap = false # Optional @bigger = true # Optional $game_player.move_speed = 4 # Optional else # Here @worldmap = false # Here @bigger = false # Optional $game_player.move_speed = 4 # Optional end # Here
# 公開インスタンス変数にタイルセットの情報を設定 tileset = $data_tilesets[@map.tileset_id] @tileset_name = tileset.tileset_name @autotile_names = tileset.autotile_names @panorama_name = tileset.panorama_name @panorama_hue = tileset.panorama_hue @fog_name = tileset.fog_name @fog_hue = tileset.fog_hue @fog_opacity = tileset.fog_opacity @fog_blend_type = tileset.fog_blend_type @fog_zoom = tileset.fog_zoom @fog_sx = tileset.fog_sx @fog_sy = tileset.fog_sy @battleback_name = tileset.battleback_name @passages = tileset.passages @priorities = tileset.priorities @terrain_tags = tileset.terrain_tags # 表示座標を初期化 @display_x = 0 @display_y = 0 # リフレッシュ要求フラグをクリア @need_refresh = false # マップイベントのデータを設定 @events = {} for i in @map.events.keys @events[i] = Game_Event.new(@map_id, @map.events[i]) end # コモンイベントのデータを設定 @common_events = {} for i in 1...$data_common_events.size @common_events[i] = Game_CommonEvent.new(i) end # フォグの各情報を初期化 @fog_ox = 0 @fog_oy = 0 @fog_tone = Tone.new(0, 0, 0, 0) @fog_tone_target = Tone.new(0, 0, 0, 0) @fog_tone_duration = 0 @fog_opacity_duration = 0 @fog_opacity_target = 0 # スクロール情報を初期化 @scroll_direction = 2 @scroll_rest = 0 @scroll_speed = 4 end #-------------------------------------------------------------------------- # ● マップ ID の取得 #-------------------------------------------------------------------------- def map_id return @map_id end #-------------------------------------------------------------------------- # ● 幅の取得 #-------------------------------------------------------------------------- def width return @map.width end #-------------------------------------------------------------------------- # ● 高さの取得 #-------------------------------------------------------------------------- def height return @map.height end #-------------------------------------------------------------------------- # ● エンカウントリストの取得 #-------------------------------------------------------------------------- def encounter_list return @map.encounter_list end #-------------------------------------------------------------------------- # ● エンカウント歩数の取得 #-------------------------------------------------------------------------- def encounter_step return @map.encounter_step end #-------------------------------------------------------------------------- # ● マップデータの取得 #-------------------------------------------------------------------------- def data return @map.data end #-------------------------------------------------------------------------- # ● BGM / BGS 自動切り替え #-------------------------------------------------------------------------- def autoplay if @map.autoplay_bgm $game_system.bgm_play(@map.bgm) end if @map.autoplay_bgs $game_system.bgs_play(@map.bgs) end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh # マップ ID が有効なら if @map_id > 0 # すべてのマップイベントをリフレッシュ for event in @events.values event.refresh end # すべてのコモンイベントをリフレッシュ for common_event in @common_events.values common_event.refresh end end # リフレッシュ要求フラグをクリア @need_refresh = false end #-------------------------------------------------------------------------- # ● 下にスクロール # distance : スクロールする距離 #-------------------------------------------------------------------------- def scroll_down(distance) @display_y = [@display_y + distance, (self.height - 15) * 128].min end #-------------------------------------------------------------------------- # ● 左にスクロール # distance : スクロールする距離 #-------------------------------------------------------------------------- def scroll_left(distance) @display_x = [@display_x - distance, 0].max end #-------------------------------------------------------------------------- # ● 右にスクロール # distance : スクロールする距離 #-------------------------------------------------------------------------- def scroll_right(distance) @display_x = [@display_x + distance, (self.width - 20) * 128].min end #-------------------------------------------------------------------------- # ● 上にスクロール # distance : スクロールする距離 #-------------------------------------------------------------------------- def scroll_up(distance) @display_y = [@display_y - distance, 0].max end #-------------------------------------------------------------------------- # ● 有効座標判定 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def valid?(x, y) return (x >= 0 and x < width and y >= 0 and y < height) end #-------------------------------------------------------------------------- # ● 通行可能判定 # x : X 座標 # y : Y 座標 # d : 方向 (0,2,4,6,8,10) # ※ 0,10 = 全方向通行不可の場合を判定 (ジャンプなど) # self_event : 自分 (イベントが通行判定をする場合) #-------------------------------------------------------------------------- def passable?(x, y, d, self_event = nil) # 与えられた座標がマップ外の場合 unless valid?(x, y) # 通行不可 return false end # 方向 (0,2,4,6,8,10) から 障害物ビット (0,1,2,4,8,0) に変換 bit = (1 << (d / 2 - 1)) & 0x0f # すべてのイベントでループ for event in events.values # 自分以外のタイルと座標が一致した場合 if event.tile_id >= 0 and event != self_event and event.x == x and event.y == y and not event.through # 障害物ビットがセットされている場合 if @passages[event.tile_id] & bit != 0 # 通行不可 return false # 全方向の障害物ビットがセットされている場合 elsif @passages[event.tile_id] & 0x0f == 0x0f # 通行不可 return false # それ以外で プライオリティが 0 の場合 elsif @priorities[event.tile_id] == 0 # 通行可 return true end end end # レイヤーの上から順に調べるループ for i in [2, 1, 0] # タイル ID を取得 tile_id = data[x, y, i] # タイル ID 取得失敗 if tile_id == nil # 通行不可 return false # 障害物ビットがセットされている場合 elsif @passages[tile_id] & bit != 0 # 通行不可 return false # 全方向の障害物ビットがセットされている場合 elsif @passages[tile_id] & 0x0f == 0x0f # 通行不可 return false # それ以外で プライオリティが 0 の場合 elsif @priorities[tile_id] == 0 # 通行可 return true end end # 通行可 return true end #-------------------------------------------------------------------------- # ● 茂み判定 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- | |
| | | xonon Poète Anonyme
Nombre de messages : 233 Age : 31 Projet(s) en cours : Snoworld Niveau Rpg Maker : Moyen Jeux Préférés : Okami, FF12, Dragon Quest 8, ... Date d'inscription : 27/07/2007
| Sujet: Re: Agrandir ou rétrécir le héros ou l'équipe Dim 29 Juil 2007, 15:30 | |
| Suite du code ci-dessus: - Code:
-
def bush?(x, y) if @map_id != 0 for i in [2, 1, 0] tile_id = data[x, y, i] if tile_id == nil return false elsif @passages[tile_id] & 0x40 == 0x40 return true end end end return false end #-------------------------------------------------------------------------- # ● カウンター判定 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def counter?(x, y) if @map_id != 0 for i in [2, 1, 0] tile_id = data[x, y, i] if tile_id == nil return false elsif @passages[tile_id] & 0x80 == 0x80 return true end end end return false end #-------------------------------------------------------------------------- # ● 地形タグの取得 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def terrain_tag(x, y) if @map_id != 0 for i in [2, 1, 0] tile_id = data[x, y, i] if tile_id == nil return 0 elsif @terrain_tags[tile_id] > 0 return @terrain_tags[tile_id] end end end return 0 end #-------------------------------------------------------------------------- # ● 指定位置のイベント ID 取得 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def check_event(x, y) for event in $game_map.events.values if event.x == x and event.y == y return event.id end end end #-------------------------------------------------------------------------- # ● スクロールの開始 # direction : スクロールする方向 # distance : スクロールする距離 # speed : スクロールする速度 #-------------------------------------------------------------------------- def start_scroll(direction, distance, speed) @scroll_direction = direction @scroll_rest = distance * 128 @scroll_speed = speed end #-------------------------------------------------------------------------- # ● スクロール中判定 #-------------------------------------------------------------------------- def scrolling? return @scroll_rest > 0 end #-------------------------------------------------------------------------- # ● フォグの色調変更の開始 # tone : 色調 # duration : 時間 #-------------------------------------------------------------------------- def start_fog_tone_change(tone, duration) @fog_tone_target = tone.clone @fog_tone_duration = duration if @fog_tone_duration == 0 @fog_tone = @fog_tone_target.clone end end #-------------------------------------------------------------------------- # ● フォグの不透明度変更の開始 # opacity : 不透明度 # duration : 時間 #-------------------------------------------------------------------------- def start_fog_opacity_change(opacity, duration) @fog_opacity_target = opacity * 1.0 @fog_opacity_duration = duration if @fog_opacity_duration == 0 @fog_opacity = @fog_opacity_target end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # 必要ならマップをリフレッシュ if $game_map.need_refresh refresh end # スクロール中の場合 if @scroll_rest > 0 # スクロール速度からマップ座標系での距離に変換 distance = 2 ** @scroll_speed # スクロールを実行 case @scroll_direction when 2 # 下 scroll_down(distance) when 4 # 左 scroll_left(distance) when 6 # 右 scroll_right(distance) when 8 # 上 scroll_up(distance) end # スクロールした距離を減算 @scroll_rest -= distance end # マップイベントを更新 for event in @events.values event.update end # コモンイベントを更新 for common_event in @common_events.values common_event.update end # フォグのスクロール処理 @fog_ox -= @fog_sx / 8.0 @fog_oy -= @fog_sy / 8.0 # フォグの色調変更処理 if @fog_tone_duration >= 1 d = @fog_tone_duration target = @fog_tone_target @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d @fog_tone_duration -= 1 end # フォグの不透明度変更処理 if @fog_opacity_duration >= 1 d = @fog_opacity_duration @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d @fog_opacity_duration -= 1 end end def name # Here $map_infos[@map_id] # Here end # Here end | |
| | | xonon Poète Anonyme
Nombre de messages : 233 Age : 31 Projet(s) en cours : Snoworld Niveau Rpg Maker : Moyen Jeux Préférés : Okami, FF12, Dragon Quest 8, ... Date d'inscription : 27/07/2007
| Sujet: Re: Agrandir ou rétrécir le héros ou l'équipe Dim 29 Juil 2007, 15:31 | |
| Suite du code ci-dessus: - Code:
-
def bush?(x, y) if @map_id != 0 for i in [2, 1, 0] tile_id = data[x, y, i] if tile_id == nil return false elsif @passages[tile_id] & 0x40 == 0x40 return true end end end return false end #-------------------------------------------------------------------------- # ● カウンター判定 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def counter?(x, y) if @map_id != 0 for i in [2, 1, 0] tile_id = data[x, y, i] if tile_id == nil return false elsif @passages[tile_id] & 0x80 == 0x80 return true end end end return false end #-------------------------------------------------------------------------- # ● 地形タグの取得 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def terrain_tag(x, y) if @map_id != 0 for i in [2, 1, 0] tile_id = data[x, y, i] if tile_id == nil return 0 elsif @terrain_tags[tile_id] > 0 return @terrain_tags[tile_id] end end end return 0 end #-------------------------------------------------------------------------- # ● 指定位置のイベント ID 取得 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def check_event(x, y) for event in $game_map.events.values if event.x == x and event.y == y return event.id end end end #-------------------------------------------------------------------------- # ● スクロールの開始 # direction : スクロールする方向 # distance : スクロールする距離 # speed : スクロールする速度 #-------------------------------------------------------------------------- def start_scroll(direction, distance, speed) @scroll_direction = direction @scroll_rest = distance * 128 @scroll_speed = speed end #-------------------------------------------------------------------------- # ● スクロール中判定 #-------------------------------------------------------------------------- def scrolling? return @scroll_rest > 0 end #-------------------------------------------------------------------------- # ● フォグの色調変更の開始 # tone : 色調 # duration : 時間 #-------------------------------------------------------------------------- def start_fog_tone_change(tone, duration) @fog_tone_target = tone.clone @fog_tone_duration = duration if @fog_tone_duration == 0 @fog_tone = @fog_tone_target.clone end end #-------------------------------------------------------------------------- # ● フォグの不透明度変更の開始 # opacity : 不透明度 # duration : 時間 #-------------------------------------------------------------------------- def start_fog_opacity_change(opacity, duration) @fog_opacity_target = opacity * 1.0 @fog_opacity_duration = duration if @fog_opacity_duration == 0 @fog_opacity = @fog_opacity_target end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # 必要ならマップをリフレッシュ if $game_map.need_refresh refresh end # スクロール中の場合 if @scroll_rest > 0 # スクロール速度からマップ座標系での距離に変換 distance = 2 ** @scroll_speed # スクロールを実行 case @scroll_direction when 2 # 下 scroll_down(distance) when 4 # 左 scroll_left(distance) when 6 # 右 scroll_right(distance) when 8 # 上 scroll_up(distance) end # スクロールした距離を減算 @scroll_rest -= distance end # マップイベントを更新 for event in @events.values event.update end # コモンイベントを更新 for common_event in @common_events.values common_event.update end # フォグのスクロール処理 @fog_ox -= @fog_sx / 8.0 @fog_oy -= @fog_sy / 8.0 # フォグの色調変更処理 if @fog_tone_duration >= 1 d = @fog_tone_duration target = @fog_tone_target @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d @fog_tone_duration -= 1 end # フォグの不透明度変更処理 if @fog_opacity_duration >= 1 d = @fog_opacity_duration @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d @fog_opacity_duration -= 1 end end def name # Here $map_infos[@map_id] # Here end # Here end | |
| | | xonon Poète Anonyme
Nombre de messages : 233 Age : 31 Projet(s) en cours : Snoworld Niveau Rpg Maker : Moyen Jeux Préférés : Okami, FF12, Dragon Quest 8, ... Date d'inscription : 27/07/2007
| Sujet: Re: Agrandir ou rétrécir le héros ou l'équipe Dim 29 Juil 2007, 15:33 | |
| Ensuite créez un script au-dessus de Main et nommez-le "Scene_Title", puis collez-y le code suivant: - Code:
-
#============================================================================== # ■ Scene_Title #------------------------------------------------------------------------------ # タイトル画面の処理を行うクラスです。 #==============================================================================
class Scene_Title #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # 戦闘テストの場合 if $BTEST battle_test return end # データベースをロード $data_actors = load_data("Data/Actors.rxdata") $data_classes = load_data("Data/Classes.rxdata") $data_skills = load_data("Data/Skills.rxdata") $data_items = load_data("Data/Items.rxdata") $data_weapons = load_data("Data/Weapons.rxdata") $data_armors = load_data("Data/Armors.rxdata") $data_enemies = load_data("Data/Enemies.rxdata") $data_troops = load_data("Data/Troops.rxdata") $data_states = load_data("Data/States.rxdata") $data_animations = load_data("Data/Animations.rxdata") $data_tilesets = load_data("Data/Tilesets.rxdata") $data_common_events = load_data("Data/CommonEvents.rxdata") $data_system = load_data("Data/System.rxdata") # システムオブジェクトを作成 $game_system = Game_System.new # タイトルグラフィックを作成 @sprite = Sprite.new @sprite.bitmap = RPG::Cache.title($data_system.title_name) $map_infos = load_data("Data/MapInfos.rxdata") # Here for key in $map_infos.keys # Here $map_infos[key] = $map_infos[key].name # Here end # Here # コマンドウィンドウを作成 s1 = "Nouvelle partie" s2 = "Continuer" s3 = "Quitter" @command_window = Window_Command.new(192, [s1, s2, s3]) @command_window.back_opacity = 160 @command_window.x = 320 - @command_window.width / 2 @command_window.y = 288 #コンティニュー有効判定 # セーブファイルがひとつでも存在するかどうかを調べる # 有効なら @continue_enabled を true、無効なら false にする @continue_enabled = false for i in 0..3 if FileTest.exist?("Save#{i+1}.sav") @continue_enabled = true end end # コンティニューが有効な場合、カーソルをコンティニューに合わせる # 無効な場合、コンティニューの文字をグレー表示にする if @continue_enabled @command_window.index = 1 else @command_window.disable_item(1) end # タイトル BGM を演奏 $game_system.bgm_play($data_system.title_bgm) # ME、BGS の演奏を停止 Audio.me_stop Audio.bgs_stop # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # コマンドウィンドウを解放 @command_window.dispose # タイトルグラフィックを解放 @sprite.bitmap.dispose @sprite.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # コマンドウィンドウを更新 @command_window.update # C ボタンが押された場合 if Input.trigger?(Input::C) # コマンドウィンドウのカーソル位置で分岐 case @command_window.index when 0 # ニューゲーム command_new_game when 1 # コンティニュー command_continue when 2 # シャットダウン command_shutdown end end end #-------------------------------------------------------------------------- # ● コマンド : ニューゲーム #-------------------------------------------------------------------------- def command_new_game # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # BGM を停止 Audio.bgm_stop # プレイ時間計測用のフレームカウントをリセット Graphics.frame_count = 0 # 各種ゲームオブジェクトを作成 $game_temp = Game_Temp.new $game_system = Game_System.new $game_switches = Game_Switches.new $game_variables = Game_Variables.new $game_self_switches = Game_SelfSwitches.new $game_screen = Game_Screen.new $game_actors = Game_Actors.new $game_party = Game_Party.new $game_troop = Game_Troop.new $game_map = Game_Map.new $game_player = Game_Player.new # 初期パーティをセットアップ $game_party.setup_starting_members # 初期位置のマップをセットアップ $game_map.setup($data_system.start_map_id) # プレイヤーを初期位置に移動 $game_player.moveto($data_system.start_x, $data_system.start_y) # プレイヤーをリフレッシュ $game_player.refresh # マップに設定されている BGM と BGS の自動切り替えを実行 $game_map.autoplay # マップを更新 (並列イベント実行) $game_map.update # マップ画面に切り替え $scene = Scene_Map.new end #-------------------------------------------------------------------------- # ● コマンド : コンティニュー #-------------------------------------------------------------------------- def command_continue # コンティニューが無効の場合 unless @continue_enabled # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # ロード画面に切り替え $scene = Scene_Load.new end #-------------------------------------------------------------------------- # ● コマンド : シャットダウン #-------------------------------------------------------------------------- def command_shutdown # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # BGM、BGS、ME をフェードアウト Audio.bgm_fade(800) Audio.bgs_fade(800) Audio.me_fade(800) # シャットダウン $scene = nil end #-------------------------------------------------------------------------- # ● 戦闘テスト #-------------------------------------------------------------------------- def battle_test # データベース (戦闘テスト用) をロード $data_actors = load_data("Data/BT_Actors.rxdata") $data_classes = load_data("Data/BT_Classes.rxdata") $data_skills = load_data("Data/BT_Skills.rxdata") $data_items = load_data("Data/BT_Items.rxdata") $data_weapons = load_data("Data/BT_Weapons.rxdata") $data_armors = load_data("Data/BT_Armors.rxdata") $data_enemies = load_data("Data/BT_Enemies.rxdata") $data_troops = load_data("Data/BT_Troops.rxdata") $data_states = load_data("Data/BT_States.rxdata") $data_animations = load_data("Data/BT_Animations.rxdata") $data_tilesets = load_data("Data/BT_Tilesets.rxdata") $data_common_events = load_data("Data/BT_CommonEvents.rxdata") $data_system = load_data("Data/BT_System.rxdata") # プレイ時間計測用のフレームカウントをリセット Graphics.frame_count = 0 # 各種ゲームオブジェクトを作成 $game_temp = Game_Temp.new $game_system = Game_System.new $game_switches = Game_Switches.new $game_variables = Game_Variables.new $game_self_switches = Game_SelfSwitches.new $game_screen = Game_Screen.new $game_actors = Game_Actors.new $game_party = Game_Party.new $game_troop = Game_Troop.new $game_map = Game_Map.new $game_player = Game_Player.new # 戦闘テスト用のパーティをセットアップ $game_party.setup_battle_test_members # トループ ID、逃走可能フラグ、バトルバックを設定 $game_temp.battle_troop_id = $data_system.test_troop_id $game_temp.battle_can_escape = true $game_map.battleback_name = $data_system.battleback_name # バトル開始 SE を演奏 $game_system.se_play($data_system.battle_start_se) # バトル BGM を演奏 $game_system.bgm_play($game_system.battle_bgm) # バトル画面に切り替え $scene = Scene_Battle.new end end Utilisation: Pour que le héros soit plus gros, créez une nouvelle carte avec devant, *B (Exemple: *BMAP005) Pour qu'il soit plus petit, créez une nouvelle carte avec devant *W(exemple: *WMAP006) Voilà^^ | |
| | | Contenu sponsorisé
| Sujet: Re: Agrandir ou rétrécir le héros ou l'équipe | |
| |
| | | | Agrandir ou rétrécir le héros ou l'équipe | |
|
Sujets similaires | |
|
| Permission de ce forum: | Vous ne pouvez pas répondre aux sujets dans ce forum
| |
| |
| |
|