Sujet n°14386
Posté par Zohran le 21 Jan - 23:46 (2015)
Titre : PMP - Petit bug incorrigible !
Bonsoir, je vous remercie par avance de votre trèèèèèès longue patience envers moi afin de répondre à mes questions. J'ai programmé il n'y pas longtemps un système de collision avec un bruit de "BUMP" lorsque l'on percute un objet. Le script fonctionne super bien, il copie vraiment le système de bump des jeux. Il intègre la course, vélo, apparence dans les hautes herbes. Par contre, j'ai un petit soucis:

1-Lorsque le joueur marche, le bump marche, lorsque je cours, le bump marche, mais lorsque le joueur est à vélo... pas de bump. Pourtant, quand je fais un print pour voir si la condition est rencontrée, c'est bien le cas... du coup je vois pas où est le problème...

2-Sinon, un second petit bug. Normalement j'ai intégré une variable de vitesse pour que la fréquence à laquelle se joue le bump quand on marche et quand on court soit différente. Mais ça ne change pas...

Je vous link les scripts concercés:

Script GamePlayer
Code:
class GamePlayer < GameCharacter
 
  def initialize
    super
    @time_before_collision_sound = 23.8 - @move_speed
  end

  #--------------------------------------------------------------------------
  # * Passable Determinants
  #     x : x-coordinate
  #     y : y-coordinate
  #     d : direction (0,2,4,6,8)
  #         * 0 = Determines if all directions are impassable (for jumping)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    # If coordinates are outside of map
    unless $game_map.valid?(new_x, new_y)
      # Impassable
      return false
    end
    # If debug mode is ON and ctrl key was pressed
    if $DEBUG and Input.press?(Input::CTRL)
      # Passable
      return true
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Set Map Display Position to Center of Screen
  #--------------------------------------------------------------------------
  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 - (Game.screen_width - 16) * 4 , max_x].min].max
    $game_map.display_y = [0, [y * 128 - (Game.screen_height - 16) * 4, max_y].min].max
  end
  #--------------------------------------------------------------------------
  # * Move to Designated Position
  #     x : x-coordinate
  #     y : y-coordinate
  #--------------------------------------------------------------------------
  def moveto(x, y)
    super
    # Centering
    center(x, y)
    # Make encounter count
    make_encounter_count
  end
  #--------------------------------------------------------------------------
  # * Increaase Steps
  #--------------------------------------------------------------------------
  def increase_steps
    super
    # If move route is not forcing
    unless @move_route_forcing
      # Increase steps
      $player.increase_steps_number
    end
  end
  #--------------------------------------------------------------------------
  # * Get Encounter Count
  #--------------------------------------------------------------------------
  def encounter_count
    return @encounter_count
  end
  #--------------------------------------------------------------------------
  # * Make Encounter Count
  #--------------------------------------------------------------------------
  def make_encounter_count
    if $game_map.map_id != 0
      n = $game_map.encounter_step
      @encounter_count = rand(n+1)
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Set character file name and hue
    @character_name = $player.character_name
    @character_hue = $player.character_hue
    # Initialize opacity level and blending method
    @opacity = 255
    @blend_type = 0
  end
  #--------------------------------------------------------------------------
  # * Same Position Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_here(triggers)
    result = false
    # If event is running
    if $game_system.map_interpreter.running?
      return result
    end
    # All event loops
    for event in $game_map.events.values
      # If event coordinates and triggers are consistent
      if event.x == @x and event.y == @y and triggers.include?(event.trigger)
        # If starting determinant is same position event (other than jumping)
        if not event.jumping? and event.over_trigger?
          event.start
          result = true
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Front Envent Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_there(triggers)
    result = false
    # If event is running
    if $game_system.map_interpreter.running?
      return result
    end
    # Calculate front event coordinates
    new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
    new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
    # All event loops
    for event in $game_map.events.values
      # If event coordinates and triggers are consistent
      if event.x == new_x and event.y == new_y and
         triggers.include?(event.trigger)
        # If starting determinant is front event (other than jumping)
        if not event.jumping? and not event.over_trigger?
          event.start
          result = true
        end
      end
    end
    # If fitting event is not found
    if result == false
      # If front tile is a counter
      if $game_map.counter?(new_x, new_y)
        # Calculate 1 tile inside coordinates
        new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
        new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
        # All event loops
        for event in $game_map.events.values
          # If event coordinates and triggers are consistent
          if event.x == new_x and event.y == new_y and
             triggers.include?(event.trigger)
            # If starting determinant is front event (other than jumping)
            if not event.jumping? and not event.over_trigger?
              event.start
              result = true
            end
          end
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Touch Event Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    result = false
    # If event is running
    if $game_system.map_interpreter.running?
      return result
    end
    # All event loops
    for event in $game_map.events.values
      # If event coordinates and triggers are consistent
      if event.x == x and event.y == y and [1,2].include?(event.trigger)
        # If starting determinant is front event (other than jumping)
        if not event.jumping? and not event.over_trigger?
          event.start
          result = true
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Remember whether or not moving in local variables
    time_before_move = 4.7
    last_moving = moving?
    # If moving, event running, move route forcing, and message window
    # display are all not occurring
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      if Input.dir4 != 0
        if @turn_count == nil         
          @turn_count = 0
        end
        @turn_count += 1.175 if @turn_count < time_before_move
      else 
        @turn_count = 0 
      end
      # Move player in the direction the directional button is being pressed
      case Input.dir4
      when 2           
        @turn_count == time_before_move ? move_down  : turn_down       
      when 4       
        @turn_count == time_before_move ? move_left  : turn_left         
      when 6         
        @turn_count == time_before_move ? move_right : turn_right       
      when 8         
        @turn_count == time_before_move ? move_up    : turn_up       
      end
    end
    # Remember coordinates in local variables
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # If character moves down and is positioned lower than the center
    # of the screen
    if @real_y > last_real_y and @real_y - $game_map.display_y > (Game.screen_height - 16) * 4
      # Scroll map down
      $game_map.scroll_down(@real_y - last_real_y)
    end
    # If character moves left and is positioned more let on-screen than
    # center
    if @real_x < last_real_x and @real_x - $game_map.display_x < (Game.screen_width - 16) * 4
      # Scroll map left
      $game_map.scroll_left(last_real_x - @real_x)
    end
    # If character moves right and is positioned more right on-screen than
    # center
    if @real_x > last_real_x and @real_x - $game_map.display_x > (Game.screen_width - 16) * 4
      # Scroll map right
      $game_map.scroll_right(@real_x - last_real_x)
    end
    # If character moves up and is positioned higher than the center
    # of the screen
    if @real_y < last_real_y and @real_y - $game_map.display_y < (Game.screen_height - 16) * 4
      # Scroll map up
      $game_map.scroll_up(last_real_y - @real_y)
    end
    # If not moving
    unless moving?
      # If player was moving last time
      if last_moving
        # Event determinant is via touch of same position event
        result = check_event_trigger_here([1,2])
        # If event which started does not exist
        if result == false
          # Disregard if debug mode is ON and ctrl key was pressed
          unless $DEBUG and Input.press?(Input::CTRL)
            # Encounter countdown
            if @encounter_count > 0
              @encounter_count -= 1
            end
          end
        end
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Same position and front event determinant
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    end
   
    if Input.press?(Input::LEFT) or Input.press?(Input::RIGHT) or Input.press?(Input::UP) or Input.press?(Input::DOWN)
      @step_anime = true
      if @time_before_collision_sound < 0
        @time_before_collision_sound = 23.8 - @move_speed
      end
      @time_before_collision_sound -= 1
    else
      @step_anime = false
      @time_before_collision_sound = 23.8 - @move_speed
    end
  end
 
  def move_down(turn_enabled = true)
    # Turn down
    if turn_enabled
      turn_down
    end
    # If passable
    if passable?(@x, @y, 2)
      # Turn down
      turn_down
      # Update coordinates
      @y += 1
      # Increase steps
      increase_steps
    # If impassable
    else
      if @time_before_collision_sound == 0
        Audio.se_play(Directory.general_sounds+"Collision")
      end
      # Determine if touch event is triggered
      check_event_trigger_touch(@x, @y+1)
    end
  end

  def move_left(turn_enabled = true)
    # Turn left
    if turn_enabled
      turn_left
    end
    # If passable
    if passable?(@x, @y, 4)
      # Turn left
      turn_left
      # Update coordinates
      @x -= 1
      # Increase steps
      increase_steps
    # If impassable
    else
      if @time_before_collision_sound == 0
        Audio.se_play(Directory.general_sounds+"Collision")
      end
      # Determine if touch event is triggered
      check_event_trigger_touch(@x-1, @y)
    end
  end

  def move_right(turn_enabled = true)
    # Turn right
    if turn_enabled
      turn_right
    end
    # If passable
    if passable?(@x, @y, 6)
      # Turn right
      turn_right
      # Update coordinates
      @x += 1
      # Increase steps
      increase_steps
    # If impassable
    else
      if @time_before_collision_sound == 0
        Audio.se_play(Directory.general_sounds+"Collision")
      end
      # Determine if touch event is triggered
      check_event_trigger_touch(@x+1, @y)
    end
  end

  def move_up(turn_enabled = true)
    # Turn up
    if turn_enabled
      turn_up
    end
    # If passable
    if passable?(@x, @y, 8)
      # Turn up
      turn_up
      # Update coordinates
      @y -= 1
      # Increase steps
      increase_steps
    # If impassable
    else
      if @time_before_collision_sound == 0
        Audio.se_play(Directory.general_sounds+"Collision")
      end
      # Determine if touch event is triggered
      check_event_trigger_touch(@x, @y-1)
    end
  end
end

Script SceneMap:
Code:
class SceneMap
 
  attr_accessor:spriteset
 
  def main
    @spriteset = SpritesetMap.new
   
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of sprite set
    @spriteset.dispose
    # Dispose of message window
    #@message_window.dispose
    # If switching to title screen
    #if $scene.is_a?(Scene_Title)
      # Fade out screen
      #Graphics.transition
      #Graphics.freeze
    #end
  end

  def update
    loop do
      $game_map.groups.size.times do |i|
        #if $game_player.terrain_tag == $game_map.groups[i].tag
          $game_map.encounter_step = $game_map.groups[i].encounter_step
        #end
      end
     
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # Update system (timer), screen
      $game_system.update
      $game_screen.update
      # Abort loop if player isn't place moving
      unless $game_temp.player_transferring
        break
      end
      # Run place move
      transfer_player
      # Abort loop if transition processing
      if $game_temp.transition_processing
        break
      end
    end
    # Update sprite set
    @spriteset.update
    # Update message window
    #@message_window.update
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Change to title screen
      $scene = Scene_Title.new
      return
    end
    # If transition processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If showing message window
    if $game_temp.message_window_showing
      return
    end
    # If encounter list isn't empty, and encounter count is 0
    if $game_player.encounter_count == 0 and @groups != []
      # If event is running or encounter is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # Confirm troop
        n = rand($game_map.groups.size)
        @enemy = $game_map.groups[n].random_selected_pokemon
        # If troop is valid
        if $game_map.groups[n].tag == $game_player.terrain_tag
          # Set battle calling flag
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = @enemy
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # If debug mode is ON and F9 key was pressed
    if $DEBUG and Input.press?(Input::F9)
      # Set debug calling flag
      $game_temp.debug_calling = true
    end
    # If player is not moving
    unless $game_player.moving?
      # Run calling of each screen
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
   
    if $game_map.can_use_bicycle and $player.bicycle and $player.use_bicycle
      $game_player.move_speed = 5.2
      if Input.dir4 != 0
        if $game_player.terrain_tag == 1
          $game_player.character_name = $player.character_name+"BicycletteHerbe"
        else
          $game_player.character_name = $player.character_name+"Bicyclette"
        end
      else
        if $game_player.terrain_tag == 1
          $game_player.character_name = $player.character_name+"PauseBicycletteHerbe"
        else
          $game_player.character_name = $player.character_name+"PauseBicyclette"
        end
      end
    elsif $player.shoes and Input.press?(Input::SHIFT) and Input.dir4 != 0
      $game_player.move_speed = 4.8
      if $game_player.terrain_tag == 1
        $game_player.character_name = $player.character_name+"CourseHerbe"
      else
        $game_player.character_name = $player.character_name+"Course"
      end
    else
      $game_player.move_speed = 3.8
      if $game_player.terrain_tag == 1
        $game_player.character_name = $player.character_name+"Herbe"
      else
        $game_player.character_name = $player.character_name
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Battle Call
  #--------------------------------------------------------------------------
  def call_battle
    # Clear battle calling flag
    $game_temp.battle_calling = false
    # Clear menu calling flag
    $game_temp.menu_calling = false
    $game_temp.menu_beep = false
    # Make encounter count
    $game_player.make_encounter_count
    # Memorize map BGM and stop BGM
    $game_temp.map_bgm = $game_system.playing_bgm
    $game_system.bgm_stop
    # Play battle start SE
    $game_system.se_play($data_system.battle_start_se)
    # Play battle BGM
    $game_system.bgm_play($game_system.battle_bgm)
    # Straighten player position
    $game_player.straighten
    # Switch to battle screen
    @pokemon = Pokemon.new(@enemy)
    @ground1 = $game_map.player_ground_name
    @ground2 = $game_map.enemy_ground_name
    @background = $game_map.background_name
    @sky = $game_map.sky
    @safari = $game_map.safari_mode
    $scene = Battle.new(@pokemon,@ground1,@ground2,@background,@sky,@safari)
  end
  #--------------------------------------------------------------------------
  # * Shop Call
  #--------------------------------------------------------------------------
  def call_shop
    # Clear shop call flag
    $game_temp.shop_calling = false
    # Straighten player position
    $game_player.straighten
    # Switch to shop screen
    $scene = Scene_Shop.new
  end
  #--------------------------------------------------------------------------
  # * Name Input Call
  #--------------------------------------------------------------------------
  def call_name
    # Clear name input call flag
    $game_temp.name_calling = false
    # Straighten player position
    $game_player.straighten
    # Switch to name input screen
    $scene = Scene_Name.new
  end
  #--------------------------------------------------------------------------
  # * Menu Call
  #--------------------------------------------------------------------------
  def call_menu
    # Clear menu call flag
    $game_temp.menu_calling = false
    # If menu beep flag is set
    if $game_temp.menu_beep
      # Play decision SE
      #$game_system.se_play($data_system.decision_se)
      # Clear menu beep flag
      $game_temp.menu_beep = false
    end
    # Straighten player position
    $game_player.straighten
    # Switch to menu screen
    $scene = Menu.new
    #$scene = Scene_Menu.new
  end
  #--------------------------------------------------------------------------
  # * Save Call
  #--------------------------------------------------------------------------
  def call_save
    # Straighten player position
    $game_player.straighten
    # Switch to save screen
    $scene = Scene_Save.new
  end
  #--------------------------------------------------------------------------
  # * Debug Call
  #--------------------------------------------------------------------------
  def call_debug
    # Clear debug call flag
    $game_temp.debug_calling = false
    # Play decision SE
    #$game_system.se_play($data_system.decision_se)
    # Straighten player position
    $game_player.straighten
    # Switch to debug screen
    $scene = Editor.new(true)
  end
  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player
    # Clear player place move call flag
    $game_temp.player_transferring = false
    # If move destination is different than current map
    if $game_map.map_id != $game_temp.player_new_map_id
      # Set up a new map
      $game_map.setup($game_temp.player_new_map_id)
    end
    # Set up player position
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    # Set player direction
    case $game_temp.player_new_direction
    when 2  # down
      $game_player.turn_down
    when 4  # left
      $game_player.turn_left
    when 6  # right
      $game_player.turn_right
    when 8  # up
      $game_player.turn_up
    end
    # Straighten player position
    $game_player.straighten
    # Update map (run parallel process event)
    $game_map.update
    # Remake sprite set
    @spriteset.dispose
    @spriteset = SpritesetMap.new
    # If processing transition
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      Graphics.transition(20)
    end
    # Run automatic change for BGM and BGS set on the map
    $game_map.autoplay
    # Frame reset
    Graphics.frame_reset
    # Update input information
    Input.update
  end
end

Posté par Nuri Yuri le 22 Jan - 00:42 (2015)
Vue que t'utilise la méthode de la redéfinition des méthodes de déplacements tu devrais bumper sans problèmes x)
Ça me rappelle que chez moi c'est plutôt trash la méthode pour bump, faudrait que je fasse plus propre et je te dirais x)

Posté par Zohran le 22 Jan - 00:53 (2015)
Nuri Yuri a écrit:
Vue que t'utilise la méthode de la redéfinition des méthodes de déplacements tu devrais bumper sans problèmes x)

Oui ça devrait bumper, je comprends pas... Si tu vois pas non plus, je crois que je vais coincer là...

J'espère que mon script de bump t'inspireras pour faire le tient Imbécile heureux

Posté par Nuri Yuri le 22 Jan - 11:28 (2015)
http://puu.sh/eRCBX/fa47f16742.png c'était dans mes tests, après sur Gemme j'ai décidé de faire un bump qui ne s'actionnait que si j'avais une accélération donc j'ai déplace ça un peu partout
http://puu.sh/eRCJH/d1acc92b26.png
Donc voilà x)

Je verrais plus tard pour faire ça un peu mieux, le problème de ça c'est qu'il faut pas altérer certaines données comme tu peux le voir, j'ai une condition qui vérifie si je suis entrain de surfer pour éviter de reset mon état d'animation à l'arrêt cela dit c'est pas suffisant.

Au pire, faudrait qu'on travail un peu plus ensemble sur ces points comme ça on fera un truc qui fonctionne bien :p (Vu que nos deux SK sont assez hétérogènes à PSP mais fonctionnent avec les mêmes objectifs ou presque :d)

Posté par Zohran le 22 Jan - 12:56 (2015)
Nuri Yuri a écrit:
http://puu.sh/eRCBX/fa47f16742.png c'était dans mes tests, après sur Gemme j'ai décidé de faire un bump qui ne s'actionnait que si j'avais une accélération donc j'ai déplace ça un peu partout
http://puu.sh/eRCJH/d1acc92b26.png
Donc voilà x)

Je verrais plus tard pour faire ça un peu mieux, le problème de ça c'est qu'il faut pas altérer certaines données comme tu peux le voir, j'ai une condition qui vérifie si je suis entrain de surfer pour éviter de reset mon état d'animation à l'arrêt cela dit c'est pas suffisant.

Au pire, faudrait qu'on travail un peu plus ensemble sur ces points comme ça on fera un truc qui fonctionne bien :p (Vu que nos deux SK sont assez hétérogènes à PSP mais fonctionnent avec les mêmes objectifs ou presque :d)

Qu'on travaille ensemble? Pourquoi pas Imbécile heureux Mais j'ai peur de ne pas aussi bien scripter que toi et que ça t'obliges à repasser derrière moi. Peut-être que je me fais des films mais bon... x)
Tu scriptes mieux que moi quand même xD

Posté par Nuri Yuri le 22 Jan - 13:03 (2015)
Être bon scripteur ou pas c'est pas le problème x)
C'est surtout de trouver les bons points d'attaque et t'as déjà trouvé des choses intéressantes, après le problème c'est que ça fonctionne pas totalement (bug du vélo).
D'ailleurs, question, est-ce que la musique ne recouvrirait pas les bump en vélo '^'
De mémoire certaines musiques font que j'entends pas bien les bumps en fonction du volume des SE (je peux les régler depuis Game.ini ^^).

Posté par Zohran le 22 Jan - 13:17 (2015)
Nuri Yuri a écrit:
Être bon scripteur ou pas c'est pas le problème x)
C'est surtout de trouver les bons points d'attaque et t'as déjà trouvé des choses intéressantes, après le problème c'est que ça fonctionne pas totalement (bug du vélo).
D'ailleurs, question, est-ce que la musique ne recouvrirait pas les bump en vélo '^'
De mémoire certaines musiques font que j'entends pas bien les bumps en fonction du volume des SE (je peux les régler depuis Game.ini ^^).

Je trouve des choses intéressantes moi ? x) Ah bon Bouche extensible
Lorsque le joueur fait du surplace, l'apparence change aussi d'ailleurs, comme dans BW. Mais c'est vrai que ce petit bug de son est étrange...

Sinon, j'ai déjà lancé la map sans musique, mais on n'entend strictement rien, donc c'est bien un bug ^^

EDIT: ça y est, j'ai trouvé d'où vient le bug, apparement, la vitesse que j'ai intégré dans le calcul de time_count empêche de jouer le bump lorsque l'on est en vélo, mais pourquoi, je pige pas....

Posté par Nuri Yuri le 22 Jan - 13:32 (2015)
Désintègre la vitesse du time_count.
Le bump devrait bumper à fréquence régulière quelque soit la vitesse de ton gugusse normalement. (Sinon c'est pas beau à l'écoute ^^)

Posté par Zohran le 22 Jan - 13:39 (2015)
Nuri Yuri a écrit:
Désintègre la vitesse du time_count.
Le bump devrait bumper à fréquence régulière quelque soit la vitesse de ton gugusse normalement. (Sinon c'est pas beau à l'écoute ^^)

Humf, dommage, il me semblait que la fréquence du bump dans les jeux originaux variaient selon la vitesse... Tant pis, on fera sans...

Posté par Nuri Yuri le 22 Jan - 14:17 (2015)
Je crois pas, à tester et confirmer x)

Posté par Zohran le 22 Jan - 15:01 (2015)
Nuri Yuri a écrit:
Je crois pas, à tester et confirmer x)

Ok, du coup j'ai remis avec un time_count fixe. Maintenant, j'ai aussi intégré le saut de talus et surf, et ça donne ça: (Tout fonctionne à merveille! J'ai modifié légèrement la méthode passable? de game_player pour créer un retour false si l'on rencontre le tag de l'eau)
Code:
class SceneMap
 
  attr_accessor:spriteset
 
  def main
    @spriteset = SpritesetMap.new
   
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of sprite set
    @spriteset.dispose
    # Dispose of message window
    #@message_window.dispose
    # If switching to title screen
    #if $scene.is_a?(Scene_Title)
      # Fade out screen
      #Graphics.transition
      #Graphics.freeze
    #end
  end

  def update
    loop do
      $game_map.groups.size.times do |i|
        #if $game_player.terrain_tag == $game_map.groups[i].tag
          $game_map.encounter_step = $game_map.groups[i].encounter_step
        #end
      end
     
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # Update system (timer), screen
      $game_system.update
      $game_screen.update
      # Abort loop if player isn't place moving
      unless $game_temp.player_transferring
        break
      end
      # Run place move
      transfer_player
      # Abort loop if transition processing
      if $game_temp.transition_processing
        break
      end
    end
    # Update sprite set
    @spriteset.update
    # Update message window
    #@message_window.update
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Change to title screen
      $scene = Scene_Title.new
      return
    end
    # If transition processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If showing message window
    if $game_temp.message_window_showing
      return
    end
    # If encounter list isn't empty, and encounter count is 0
    if $game_player.encounter_count == 0 and @groups != []
      # If event is running or encounter is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # Confirm troop
        n = rand($game_map.groups.size)
        @enemy = $game_map.groups[n].random_selected_pokemon
        # If troop is valid
        if $game_map.groups[n].tag == $game_player.terrain_tag
          # Set battle calling flag
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = @enemy
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # If debug mode is ON and F9 key was pressed
    if $DEBUG and Input.press?(Input::F9)
      # Set debug calling flag
      $game_temp.debug_calling = true
    end
    # If player is not moving
    unless $game_player.moving?
      # Run calling of each screen
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
   
    if $game_player.terrain_tag == 3
      $game_player.character_name = $player.character_name+"Surf"
      $player.surfing = true
      $player.use_bicycle = false
    else
      $player.surfing = false
    end
   
    if $game_player.front_terrain_tag == 2 and $game_player.direction != 8 and $game_player.front_away_terrain_tag != 2
      if Input.repeat?(Input::LEFT)
        Audio.se_play(Directory.general_sounds+"Saut")
        $game_player.jump(-2,0)
      end
      if Input.repeat?(Input::RIGHT)
        Audio.se_play(Directory.general_sounds+"Saut")
        $game_player.jump(2,0)
      end
      if Input.repeat?(Input::UP)
        Audio.se_play(Directory.general_sounds+"Saut")
        $game_player.jump(0,-2)
      end
      if Input.repeat?(Input::DOWN)
        Audio.se_play(Directory.general_sounds+"Saut")
        $game_player.jump(0,2)
      end
    end
   
    if $game_map.can_use_bicycle and $player.bicycle and $player.use_bicycle and !$player.surfing
      $game_player.move_speed = 5.2
      if Input.dir4 != 0
        if $game_player.terrain_tag == 1
          $game_player.character_name = $player.character_name+"BicycletteHerbe"
        else
          $game_player.character_name = $player.character_name+"Bicyclette"
        end
      else
        if $game_player.terrain_tag == 1
          $game_player.character_name = $player.character_name+"PauseBicycletteHerbe"
        else
          $game_player.character_name = $player.character_name+"PauseBicyclette"
        end
      end
    elsif $player.shoes and Input.press?(Input::SHIFT) and Input.dir4 != 0 and !$player.surfing
      $game_player.move_speed = 4.8
      if $game_player.terrain_tag == 1
        $game_player.character_name = $player.character_name+"CourseHerbe"
      else
        $game_player.character_name = $player.character_name+"Course"
      end
    else
      $game_player.move_speed = 3.8
      if !$player.surfing
        if $game_player.terrain_tag == 1
          $game_player.character_name = $player.character_name+"Herbe"
        else
          $game_player.character_name = $player.character_name
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Battle Call
  #--------------------------------------------------------------------------
  def call_battle
    # Clear battle calling flag
    $game_temp.battle_calling = false
    # Clear menu calling flag
    $game_temp.menu_calling = false
    $game_temp.menu_beep = false
    # Make encounter count
    $game_player.make_encounter_count
    # Memorize map BGM and stop BGM
    $game_temp.map_bgm = $game_system.playing_bgm
    $game_system.bgm_stop
    # Play battle start SE
    $game_system.se_play($data_system.battle_start_se)
    # Play battle BGM
    $game_system.bgm_play($game_system.battle_bgm)
    # Straighten player position
    $game_player.straighten
    # Switch to battle screen
    @pokemon = Pokemon.new(@enemy)
    @ground1 = $game_map.player_ground_name
    @ground2 = $game_map.enemy_ground_name
    @background = $game_map.background_name
    @sky = $game_map.sky
    @safari = $game_map.safari_mode
    $scene = Battle.new(@pokemon,@ground1,@ground2,@background,@sky,@safari)
  end
  #--------------------------------------------------------------------------
  # * Shop Call
  #--------------------------------------------------------------------------
  def call_shop
    # Clear shop call flag
    $game_temp.shop_calling = false
    # Straighten player position
    $game_player.straighten
    # Switch to shop screen
    $scene = Scene_Shop.new
  end
  #--------------------------------------------------------------------------
  # * Name Input Call
  #--------------------------------------------------------------------------
  def call_name
    # Clear name input call flag
    $game_temp.name_calling = false
    # Straighten player position
    $game_player.straighten
    # Switch to name input screen
    $scene = Scene_Name.new
  end
  #--------------------------------------------------------------------------
  # * Menu Call
  #--------------------------------------------------------------------------
  def call_menu
    # Clear menu call flag
    $game_temp.menu_calling = false
    # If menu beep flag is set
    if $game_temp.menu_beep
      # Play decision SE
      #$game_system.se_play($data_system.decision_se)
      # Clear menu beep flag
      $game_temp.menu_beep = false
    end
    # Straighten player position
    $game_player.straighten
    # Switch to menu screen
    $scene = Menu.new
    #$scene = Scene_Menu.new
  end
  #--------------------------------------------------------------------------
  # * Save Call
  #--------------------------------------------------------------------------
  def call_save
    # Straighten player position
    $game_player.straighten
    # Switch to save screen
    $scene = Scene_Save.new
  end
  #--------------------------------------------------------------------------
  # * Debug Call
  #--------------------------------------------------------------------------
  def call_debug
    # Clear debug call flag
    $game_temp.debug_calling = false
    # Play decision SE
    #$game_system.se_play($data_system.decision_se)
    # Straighten player position
    $game_player.straighten
    # Switch to debug screen
    $scene = Editor.new(true)
  end
  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player
    # Clear player place move call flag
    $game_temp.player_transferring = false
    # If move destination is different than current map
    if $game_map.map_id != $game_temp.player_new_map_id
      # Set up a new map
      $game_map.setup($game_temp.player_new_map_id)
    end
    # Set up player position
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    # Set player direction
    case $game_temp.player_new_direction
    when 2  # down
      $game_player.turn_down
    when 4  # left
      $game_player.turn_left
    when 6  # right
      $game_player.turn_right
    when 8  # up
      $game_player.turn_up
    end
    # Straighten player position
    $game_player.straighten
    # Update map (run parallel process event)
    $game_map.update
    # Remake sprite set
    @spriteset.dispose
    @spriteset = SpritesetMap.new
    # If processing transition
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      Graphics.transition(20)
    end
    # Run automatic change for BGM and BGS set on the map
    $game_map.autoplay
    # Frame reset
    Graphics.frame_reset
    # Update input information
    Input.update
  end
end