Sujet n°14317
Posté par Zohran le 3 Jan - 16:26 (2015)
Titre : Optimisation de mon script Editeur[résolu]
Bonsoir, voilà, suite à mon avancement assez rapide sur mon éditeur, je souhaiterais vous demandez si vous pourriez le regarder pour me dire si certaines parties peuvent être optimisée, pour éviter les chutes de FPS (il y en a quand je sélectionne l'édition des Pokémon)

Sinon, j'ai une deuxième question, connaitriez vous un script qui gère assez facilement les saisies de texte par clavier (entrée-sortie) ?

SCRIPT:

Code
Code:
class Editor
 
  def main
    Audio.bgm_play(Directory.editor_sounds+"Musique de fond")
   
    @titles = ["Editeur",
               "Editeur d'Objets",
               "Editeur de Pokémon",
               "Editeur d'Attaques",
               "Editeur de Capacités Spéciales",
               "Editeur de Natures",
               "Editeur de Jeu"]
   
    @commands = ["Liste des Objets",
                 "Liste des Pokémon",
                 "Liste des Attaques",
                 "Liste des Capacités Spéciales",
                 "Liste des Natures",
                 "Configurations du Jeu",
                 "Quitter"]
                 
    @infos = ["Créer un nouvel objet ou éditer un objet existant.",
              "Créer un nouveau pokémon ou éditer un pokémon existant.",
              "Créer une nouvelle attaque ou éditer une attaque existante.",
              "Créer une nouvelle capacité spéciale ou éditer une capacité spéciale existante.",
              "Créer une nouvelle nature ou éditer une nature existante.",
              "Configurer les données générales du jeu.",
              "Quitter l'Editeur de données."]
   
    @items_list = []
    $data_items.size.times do |i|
      @items_list.push(ItemData.name(i+1))
    end
             
    @pokemon_list = []
    $data_pokemon.size.times do |i|
      @pokemon_list.push(PokemonData.name(i+1))
    end
   
    @skills_list = []
    $data_skills.size.times do |i|
      @skills_list.push(SkillData.name(i+1))
    end
         
    @abilitys_list = []
    $data_abilitys.size.times do |i|
      @abilitys_list.push(AbilityData.name(i+1))
    end
   
    @natures_list = []
    $data_natures.size.times do |i|
      @natures_list.push(NatureData.name(i))
    end
   
    @settings_list = ["Configurer les données",
                      "Configurer les textes",
                      "Configurer les sons",
                      "Configurer les graphismes"]
   
    @lists = [@items_list,@pokemon_list,@skills_list,@abilitys_list,@natures_list,@settings_list]
   
    @current_title = @titles[0]
    @current_commands_list = @commands
    @current_infos_list = @infos
    @current_command = 0
    @progression_level = 0
             
    @space = 2
    @length = 0
             
    @title_sprite = Sprite.new
    make_bitmap_title_sprite
   
    @commands_sprite = Sprite.new
    make_bitmap_commands_sprite
   
    @info_sprite = Sprite.new
    @info_sprite.bitmap = Bitmap.new(100,Font.default_size)
    remake_bitmap_info_sprite
   
    @cursor = Sprite.new
    @cursor.bitmap = Bitmap.new(Directory.editor+"Curseur")
    @cursor.ox = @cursor.width/2
    @cursor.oy = @cursor.height/2
    @cursor.x = @commands_sprite.x - @cursor.width - 2
    @cursor.y = @commands_sprite.y
   
    update_title
    update_info
    update_commands_list(@current_commands_list)
   
    Graphics.transition

    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end

    Graphics.freeze

    Audio.bgm_stop
    dispose
  end
 
  def update
    update_quit_command
    update_validation_command
    update_current_command
    update_cursor
    update_y_commands_sprite
    update_info
    update_item_icon
    update_item_info
    update_nature_info
    update_skill_info
    update_ability_info
    update_pokemon_info
  end
 
  def make_bitmap_title_sprite
    @title_sprite.bitmap = Bitmap.new(100,Font.default_size)
    @title_length = @title_sprite.bitmap.text_size(@current_title).width
    @title_sprite.bitmap = Bitmap.new(@title_length,Font.default_size)
    @title_sprite.x = Graphics.width/2 - @title_sprite.width/2
    @title_sprite.y = 2
    @title_sprite.z = 5
  end
 
  def update_y_commands_sprite
    if @progression_level != 0
      if @current_command > 10 and Input.trigger?(Input::DOWN)
        @commands_sprite.y -= Font.default_size
      end
      if @current_command > 10 and Input.trigger?(Input::UP)
        @commands_sprite.y += Font.default_size
      end
    end
  end
 
  def make_bitmap_commands_sprite
    @height = @current_commands_list.size * Font.default_size + @space*(@current_commands_list.size-1)
   
    @commands_sprite.bitmap = Bitmap.new(100,@height)
   
    @current_commands_list.size.times do |i|
      if @commands_sprite.bitmap.text_size(@current_commands_list[i]).width > @length
        @length = @commands_sprite.bitmap.text_size(@current_commands_list[i]).width
      end
    end
             
    @commands_sprite.bitmap = Bitmap.new(@length,@height)
    if @progression_level == 1
      @commands_sprite.x = 20
    else
      @commands_sprite.x = Graphics.width/2 - @commands_sprite.width/2
    end
    @commands_sprite.y = @title_sprite.y + @title_sprite.height + 10
  end
 
  def update_title
    @title_sprite.bitmap.clear
    make_bitmap_title_sprite
    @title_sprite.bitmap.draw_text(0,0,@title_length,Font.default_size,@current_title)
  end
 
  def update_info
    if @progression_level < 1
      @info_sprite.bitmap.clear
      remake_bitmap_info_sprite
      @info_sprite.bitmap.draw_text(0,0,@info_length,Font.default_size,@current_infos_list[@current_command])
    end
  end
 
  def remake_bitmap_info_sprite
    @info_length = @info_sprite.bitmap.text_size(@current_infos_list[@current_command]).width
    @info_sprite.bitmap = Bitmap.new(@info_length,Font.default_size)
    @info_sprite.x = Graphics.width/2 - @info_sprite.width/2
    @info_sprite.y = @commands_sprite.y + @commands_sprite.height + 10
    @info_sprite.z = 5
  end
 
  def update_commands_list(list)
    @commands_sprite.bitmap.clear
    list.size.times do |i|
      @commands_sprite.bitmap.draw_text(0,i*Font.default_size+@space,@length,Font.default_size,list[i])
    end
  end
 
  def update_current_command
    if Input.trigger?(Input::UP) and @current_command > 0
      @current_command -= 1
    end
   
    if Input.trigger?(Input::DOWN) and @current_command < @current_commands_list.size-1
      @current_command += 1
    end
  end
 
  def update_validation_command
    if Input.trigger?(Input::C)
      @progression_level += 1
      if @progression_level == 1
        @current_title = @titles[@current_command+1]
        @current_commands_list = @lists[@current_command]
        case @current_title
        when @titles[1]
          make_item_icon
          make_item_info
        when @titles[2]
          make_pokemon_info
        when @titles[3]
          make_skill_info
        when @titles[4]
          make_ability_info
        when @titles[5]
          make_nature_info
        end
      end
      refresh
    end
  end
 
  def update_quit_command
    if Input.trigger?(Input::B)
      @progression_level -=1
      if @progression_level == 0
        @current_title = @titles[0]
        @current_commands_list = @commands
        @item.dispose if @item != nil
        @item_info.dispose if @item_info != nil
        @nature_info.dispose if @nature_info != nil
        @skill_info.dispose if @skill_info != nil
        @ability_info.dispose if @ability_info != nil
        @pokemon_info.dispose if @pokemon_info != nil
      end
      refresh
    end
  end
 
  def refresh
    @current_infos_list = @infos
    @current_command = 0
    update_title
    update_info
    make_bitmap_commands_sprite
    update_commands_list(@current_commands_list)
    refresh_cursor
    @info_sprite.bitmap.clear
  end
 
  def refresh_cursor
    @cursor.y = @commands_sprite.y
  end
 
  def update_cursor
    @cursor.x = @commands_sprite.x - @cursor.width - 2
    if @current_command <= 10
      @cursor.y = @commands_sprite.y + @current_command*Font.default_size + 9
    end
    @cursor.angle -= 3
  end
 
  def make_item_icon
    @item = Sprite.new
    @item.bitmap = Bitmap.new(Directory.items+(@current_command+1).to_s)
    @item.y = @commands_sprite.y
  end
 
  def update_item_icon
    if @progression_level == 1 and @current_title == @titles[1]
      @item.bitmap = Bitmap.new(Directory.items+(@current_command+1).to_s)
      @item.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_item_info
    @item_text_info = ["Type : "+ItemData.type(@current_command+1).to_s,
                       "Prix : "+ItemData.price(@current_command+1).to_s,
                       "Description : "+ItemData.info(@current_command+1)]
                       
    @height_item_info = @item_text_info.size * Font.default_size + @space*(@item_text_info.size-1)
   
    @item_info = Sprite.new
    @item_info.bitmap = Bitmap.new(100,@height_item_info)
   
    @length_item_info = @item_info.bitmap.text_size(@item_text_info[2]).width

    @item_info.bitmap = Bitmap.new(@length_item_info,@height_item_info)
    @item_info.y = @item.y + @item.height + 10
  end
 
  def update_item_info
    if @progression_level == 1 and @current_title == @titles[1]
      @item_info.bitmap.clear
      @item_text_info = ["Type : "+ItemData.type(@current_command+1).to_s,
                         "Prix : "+ItemData.price(@current_command+1).to_s,
                         "Description : "+ItemData.info(@current_command+1)]
                       
      @length_item_info = @item_info.bitmap.text_size(@item_text_info[2]).width
                       
      @item_info.bitmap = Bitmap.new(@length_item_info,@height_item_info)
   
      @item_text_info.size.times do |i|
        @item_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_item_info,Font.default_size,@item_text_info[i])
      end
     
      @item_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_nature_info
    @nature_text_info = ["Bonus d'Attaque : "+NatureData.attack_bonus(@current_command).to_s+"%",
                         "Bonus de Défense : "+NatureData.defense_bonus(@current_command).to_s+"%",
                         "Bonus d'Attaque Spéciale : "+NatureData.special_attack_bonus(@current_command).to_s+"%",
                         "Bonus de Défense Spéciale : "+NatureData.special_defense_bonus(@current_command).to_s+"%",
                         "Bonus de Vitesse : "+NatureData.speed_bonus(@current_command).to_s+"%"]
                       
    @height_nature_info = @nature_text_info.size * Font.default_size + @space*(@nature_text_info.size-1)
   
    @nature_info = Sprite.new
    @nature_info.bitmap = Bitmap.new(100,@height_nature_info)
   
    @length_nature_info = 0
                       
    @nature_text_info.size.times do |i|
      if @nature_info.bitmap.text_size(@nature_text_info[i]).width > @length_nature_info
        @length_nature_info = @nature_info.bitmap.text_size(@nature_text_info[i]).width
      end
    end

    @nature_info.bitmap = Bitmap.new(@length_nature_info,@height_nature_info)
    @nature_info.y = @title_sprite.y + @title_sprite.height + 10
  end
 
  def update_nature_info
    if @progression_level == 1 and @current_title == @titles[5]
      @nature_info.bitmap.clear
      @nature_text_info = ["Bonus d'Attaque : "+NatureData.attack_bonus(@current_command).to_s+"%",
                           "Bonus de Défense : "+NatureData.defense_bonus(@current_command).to_s+"%",
                           "Bonus d'Attaque Spéciale : "+NatureData.special_attack_bonus(@current_command).to_s+"%",
                           "Bonus de Défense Spéciale : "+NatureData.special_defense_bonus(@current_command).to_s+"%",
                           "Bonus de Vitesse : "+NatureData.speed_bonus(@current_command).to_s+"%"]
                       
      @nature_text_info.size.times do |i|
        if @nature_info.bitmap.text_size(@nature_text_info[i]).width > @length_nature_info
          @length_nature_info = @nature_info.bitmap.text_size(@nature_text_info[i]).width
        end
      end
     
      @nature_info.bitmap = Bitmap.new(@length_nature_info,@height_nature_info)
   
      @nature_text_info.size.times do |i|
        @nature_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_nature_info,Font.default_size,@nature_text_info[i])
      end
     
      @nature_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_skill_info
    @skill_text_info = ["Type : "+SkillData.type(@current_command+1).to_s,
                        "Description : "+SkillData.info(@current_command+1),
                        "PP : "+SkillData.pp(@current_command+1).to_s,
                        "PP Maximum : "+SkillData.ppmax(@current_command+1).to_s,
                        "Puissance : "+SkillData.power(@current_command+1).to_s,
                        "Précision : "+SkillData.accuracy(@current_command+1).to_s,
                        "Catégorie : "+SkillData.category(@current_command+1).to_s,]
                       
    @height_skill_info = @skill_text_info.size * Font.default_size + @space*(@skill_text_info.size-1)
   
    @skill_info = Sprite.new
    @skill_info.bitmap = Bitmap.new(100,@height_skill_info)
   
    @length_skill_info = @skill_info.bitmap.text_size(@skill_text_info[1]).width


    @skill_info.bitmap = Bitmap.new(@length_skill_info,@height_skill_info)
    @skill_info.y = @title_sprite.y + @title_sprite.height + 10
  end
 
  def update_skill_info
    if @progression_level == 1 and @current_title == @titles[3]
      @skill_info.bitmap.clear
      @skill_text_info = ["Type : "+SkillData.type(@current_command+1).to_s,
                          "Description : "+SkillData.info(@current_command+1),
                          "PP : "+SkillData.pp(@current_command+1).to_s,
                          "PP Maximum : "+SkillData.ppmax(@current_command+1).to_s,
                          "Puissance : "+SkillData.power(@current_command+1).to_s,
                          "Précision : "+SkillData.accuracy(@current_command+1).to_s,
                          "Catégorie : "+SkillData.category(@current_command+1).to_s,]
                       
      @length_skill_info = @skill_info.bitmap.text_size(@skill_text_info[1]).width
     
      @skill_info.bitmap = Bitmap.new(@length_skill_info,@height_skill_info)
   
      @skill_text_info.size.times do |i|
        @skill_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_skill_info,Font.default_size,@skill_text_info[i])
      end
     
      @skill_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_ability_info
    @ability_text_info = ["Description : "+AbilityData.info(@current_command+1)]
                       
    @height_ability_info = @ability_text_info.size * Font.default_size + @space*(@ability_text_info.size-1)
   
    @ability_info = Sprite.new
    @ability_info.bitmap = Bitmap.new(100,@height_ability_info)
   
    @length_ability_info = @ability_info.bitmap.text_size(@ability_text_info[0]).width

    @ability_info.bitmap = Bitmap.new(@length_ability_info,@height_ability_info)
    @ability_info.y = @title_sprite.y + @title_sprite.height + 10
  end
 
  def update_ability_info
    if @progression_level == 1 and @current_title == @titles[4]
      @ability_info.bitmap.clear
      @ability_text_info = ["Description : "+AbilityData.info(@current_command+1)]
                       
      @length_ability_info = @ability_info.bitmap.text_size(@ability_text_info[0]).width
                       
      @ability_info.bitmap = Bitmap.new(@length_ability_info,@height_ability_info)
   
      @ability_text_info.size.times do |i|
        @ability_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_ability_info,Font.default_size,@ability_text_info[i])
      end
     
      @ability_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_pokemon_info
    @pokemon_text_info = ["Famille : Pokémon "+PokemonData.family(@current_command+1),
                          "Asexué : "+PokemonData.asexual(@current_command+1).to_s,
                          "Pourcentage de mâle : "+PokemonData.male_ratio(@current_command+1).to_s+"%",
                          "Taux de capture : "+PokemonData.catch_ratio(@current_command+1).to_s,
                          "Expérience : "+PokemonData.experience(@current_command+1).to_s,
                          "Type d'expérience : "+PokemonData.experience_type(@current_command+1).to_s,
                          "Types : "+PokemonData.types(@current_command+1).to_s,
                          "Pré-Evolution : "+PokemonData.post_evolution(@current_command+1).to_s,
                          "Liste des évolutions : "+PokemonData.evolutions_list(@current_command+1).to_s,
                          "Liste des types des évolutions : "+PokemonData.evolution_types_list(@current_command+1).to_s,
                          "Valeur des types des évolutions : "+PokemonData.evolution_values_list(@current_command+1).to_s,
                          "Nombre de pas avant éclosion : "+PokemonData.hatch_steps(@current_command+1).to_s+" pas",
                          "Groupes d'Oeuf : "+PokemonData.egg_groups(@current_command+1).to_s,
                          "Nombre de formes : "+PokemonData.forms_number(@current_command+1).to_s,
                          "Taille : "+PokemonData.height(@current_command+1).to_s+" m",
                          "Poids : "+PokemonData.weight(@current_command+1).to_s+" kg",
                          "PV : "+PokemonData.pv(@current_command+1).to_s,
                          "Attaque : "+PokemonData.attack(@current_command+1).to_s,
                          "Défense : "+PokemonData.defense(@current_command+1).to_s,
                          "Attaque Spéciale : "+PokemonData.special_attack(@current_command+1).to_s,
                          "Défense Spéciale : "+PokemonData.special_defense(@current_command+1).to_s,
                          "Vitesse : "+PokemonData.speed(@current_command+1).to_s,
                          "Nombre d'EV donnés en PV : "+PokemonData.ev_pv(@current_command+1).to_s,
                          "Nombre d'EV donnés en Attaque : "+PokemonData.ev_attack(@current_command+1).to_s,
                          "Nombre d'EV donnés en Défense : "+PokemonData.ev_defense(@current_command+1).to_s,
                          "Nombre d'EV donnés en Attaque Spéciale : "+PokemonData.ev_special_attack(@current_command+1).to_s,
                          "Nombre d'EV donnés en Défense Spéciale : "+PokemonData.ev_special_defense(@current_command+1).to_s,
                          "Nombre d'EV donnés en Vitesse : "+PokemonData.ev_speed(@current_command+1).to_s,
                          "Talents : "+PokemonData.talents_list(@current_command+1).to_s,
                          "Description : "+PokemonData.ev_pv(@current_command+1).to_s,
                          "Attaques apprises par niveau : "+PokemonData.level_skills_list(@current_command+1).to_s,
                          "Attaques apprenables : "+PokemonData.learnable_skills_list(@current_command+1).to_s,
                          "Attaques apprenables par reproduction : "+PokemonData.reproduction_skills_list(@current_command+1).to_s,
                          "Attaques apprenables par le Maître des Capacités: "+PokemonData.skill_master_list(@current_command+1).to_s,]
                       
    @height_pokemon_info = @pokemon_text_info.size * Font.default_size + @space*(@pokemon_text_info.size-1)
   
    @pokemon_info = Sprite.new
    @pokemon_info.bitmap = Bitmap.new(100,@height_pokemon_info)
   
    @length_pokemon_info = 0
                       
    @pokemon_text_info.size.times do |i|
      if @pokemon_info.bitmap.text_size(@pokemon_text_info[i]).width > @length_pokemon_info
        @length_pokemon_info = @pokemon_info.bitmap.text_size(@pokemon_text_info[i]).width
      end
    end

    @pokemon_info.bitmap = Bitmap.new(@length_pokemon_info,@height_pokemon_info)
    @pokemon_info.y = @title_sprite.y + @title_sprite.height + 10
  end
 
  def update_pokemon_info
    if @progression_level == 1 and @current_title == @titles[2]
      @pokemon_info.bitmap.clear
      @pokemon_text_info = ["Famille : Pokémon "+PokemonData.family(@current_command+1),
                            "Asexué : "+PokemonData.asexual(@current_command+1).to_s,
                            "Pourcentage de mâle : "+PokemonData.male_ratio(@current_command+1).to_s+"%",
                            "Taux de capture : "+PokemonData.catch_ratio(@current_command+1).to_s,
                            "Expérience : "+PokemonData.experience(@current_command+1).to_s,
                            "Type d'expérience : "+PokemonData.experience_type(@current_command+1).to_s,
                            "Types : "+PokemonData.types(@current_command+1).to_s,
                            "Pré-Evolution : "+PokemonData.post_evolution(@current_command+1).to_s,
                            "Liste des évolutions : "+PokemonData.evolutions_list(@current_command+1).to_s,
                            "Liste des types des évolutions : "+PokemonData.evolution_types_list(@current_command+1).to_s,
                            "Valeur des types des évolutions : "+PokemonData.evolution_values_list(@current_command+1).to_s,
                            "Nombre de pas avant éclosion : "+PokemonData.hatch_steps(@current_command+1).to_s+" pas",
                            "Groupes d'Oeuf : "+PokemonData.egg_groups(@current_command+1).to_s,
                            "Nombre de formes : "+PokemonData.forms_number(@current_command+1).to_s,
                            "Taille : "+PokemonData.height(@current_command+1).to_s+" m",
                            "Poids : "+PokemonData.weight(@current_command+1).to_s+" kg",
                            "PV : "+PokemonData.pv(@current_command+1).to_s,
                            "Attaque : "+PokemonData.attack(@current_command+1).to_s,
                            "Défense : "+PokemonData.defense(@current_command+1).to_s,
                            "Attaque Spéciale : "+PokemonData.special_attack(@current_command+1).to_s,
                            "Défense Spéciale : "+PokemonData.special_defense(@current_command+1).to_s,
                            "Vitesse : "+PokemonData.speed(@current_command+1).to_s,
                            "Nombre d'EV donnés en PV : "+PokemonData.ev_pv(@current_command+1).to_s,
                            "Nombre d'EV donnés en Attaque : "+PokemonData.ev_attack(@current_command+1).to_s,
                            "Nombre d'EV donnés en Défense : "+PokemonData.ev_defense(@current_command+1).to_s,
                            "Nombre d'EV donnés en Attaque Spéciale : "+PokemonData.ev_special_attack(@current_command+1).to_s,
                            "Nombre d'EV donnés en Défense Spéciale : "+PokemonData.ev_special_defense(@current_command+1).to_s,
                            "Nombre d'EV donnés en Vitesse : "+PokemonData.ev_speed(@current_command+1).to_s,
                            "Talents : "+PokemonData.talents_list(@current_command+1).to_s,
                            "Description : "+PokemonData.ev_pv(@current_command+1).to_s,
                            "Attaques apprises par niveau : "+PokemonData.level_skills_list(@current_command+1).to_s,
                            "Attaques apprenables : "+PokemonData.learnable_skills_list(@current_command+1).to_s,
                            "Attaques apprenables par reproduction : "+PokemonData.reproduction_skills_list(@current_command+1).to_s,
                            "Attaques apprenables par le Maître des Capacités: "+PokemonData.skill_master_list(@current_command+1).to_s,]
                       
      @pokemon_text_info.size.times do |i|
        if @pokemon_info.bitmap.text_size(@pokemon_text_info[i]).width > @length_pokemon_info
          @length_pokemon_info = @pokemon_info.bitmap.text_size(@pokemon_text_info[i]).width
        end
      end
     
      @pokemon_info.bitmap = Bitmap.new(@length_pokemon_info,@height_pokemon_info)
   
      @pokemon_text_info.size.times do |i|
        @pokemon_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_pokemon_info,Font.default_size,@pokemon_text_info[i])
      end
     
      @pokemon_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def dispose
    @title_sprite.dispose
    @commands_sprite.dispose
  end
 
end

Posté par Nuri Yuri le 3 Jan - 16:29 (2015)
Les scripts de Zeus je pense.
Sinon un simple GetKeyboadState (Win32API à créer) sert à savoir l'état des 254/255 touches virtuelles du clavier.

Pour les optimisations, il faut pas mettre à jour l'affichage à toute les frames mais à chaque fois qu'il change (je parle des différents draw_text) cela dit la chute de FPS au moment où tu change l'affichage c'est comme la chute de FPS quand tu passe d'une map à l'autre ou d'une interface à une autre : tu peux rien y faire.

Posté par Zohran le 3 Jan - 16:35 (2015)
Nuri Yuri a écrit:
Les scripts de Zeus je pense.
Sinon un simple GetKeyboadState (Win32API à créer) sert à savoir l'état des 254/255 touches virtuelles du clavier.

Pour les optimisations, il faut pas mettre à jour l'affichage à toute les frames mais à chaque fois qu'il change (je parle des différents draw_text) cela dit la chute de FPS au moment où tu change l'affichage c'est comme la chute de FPS quand tu passe d'une map à l'autre ou d'une interface à une autre : tu peux rien y faire.


Zeus, celui sous XP? Il doit être compatible avec VX ACE je suppose..

Pour les draw_text? Ah effectivement je me posais la question, merci.
Par contre, lorsque j'affiche les infos d'un pokémon, la chute de frame est constante, mais c'est peut-être justement du à l'update à chaque frame...

Merci Yuri ! Lord teatime

EDIT:
J'ai encore un problème, j'ai corrigé tous les update de trop de draw_text, ça marche nickel, pas de perte de FPS.
Par contre un soucis apparait, quand je sélectionne une liste et qu'elle s'affiche avec les infos, tant que j'appuie pas sur BAS, les X des infos sont mauvaises, comme si ça avait été mal updaté, mais le texte s'affiche bien, je ne vois pas d'où provient l'erreur...

LE SCRIPT:


Code
Code:
class Editor
 
  def main
    Audio.bgm_play(Directory.editor_sounds+"Musique de fond")
   
    @titles = ["Editeur",
               "Editeur d'Objets",
               "Editeur de Pokémon",
               "Editeur d'Attaques",
               "Editeur de Capacités Spéciales",
               "Editeur de Natures",
               "Editeur de Jeu"]
   
    @commands = ["Liste des Objets",
                 "Liste des Pokémon",
                 "Liste des Attaques",
                 "Liste des Capacités Spéciales",
                 "Liste des Natures",
                 "Paramètres du Jeu",
                 "Quitter"]
                 
    @infos = ["Créer un nouvel objet ou éditer un objet existant.",
              "Créer un nouveau pokémon ou éditer un pokémon existant.",
              "Créer une nouvelle attaque ou éditer une attaque existante.",
              "Créer une nouvelle capacité spéciale ou éditer une capacité spéciale existante.",
              "Créer une nouvelle nature ou éditer une nature existante.",
              "Configurer les données générales du jeu.",
              "Quitter l'Editeur de données."]
   
    @items_list = []
    $data_items.size.times do |i|
      @items_list.push(ItemData.name(i+1))
    end
             
    @pokemon_list = []
    $data_pokemon.size.times do |i|
      @pokemon_list.push(PokemonData.name(i+1))
    end
   
    @skills_list = []
    $data_skills.size.times do |i|
      @skills_list.push(SkillData.name(i+1))
    end
         
    @abilitys_list = []
    $data_abilitys.size.times do |i|
      @abilitys_list.push(AbilityData.name(i+1))
    end
   
    @natures_list = []
    $data_natures.size.times do |i|
      @natures_list.push(NatureData.name(i))
    end
   
    @settings_list = ["Configurer les données",
                      "Configurer les textes",
                      "Configurer les sons",
                      "Configurer les graphismes"]
   
    @lists = [@items_list,@pokemon_list,@skills_list,@abilitys_list,@natures_list,@settings_list]
   
    @current_title = @titles[0]
    @current_commands_list = @commands
    @current_infos_list = @infos
    @current_command = 0
    @progression_level = 0
             
    @space = 2
    @length = 0
             
    @title_sprite = Sprite.new
    make_bitmap_title_sprite
   
    @commands_sprite = Sprite.new
    make_bitmap_commands_sprite
   
    @info_sprite = Sprite.new
    @info_sprite.bitmap = Bitmap.new(100,Font.default_size)
    remake_bitmap_info_sprite
   
    @cursor = Sprite.new
    @cursor.bitmap = Bitmap.new(Directory.editor+"Curseur")
    @cursor.ox = @cursor.width/2
    @cursor.oy = @cursor.height/2
    @cursor.x = @commands_sprite.x - @cursor.width - 2
    @cursor.y = @commands_sprite.y
   
    refresh_title
    refresh_info
    refresh_commands_list(@current_commands_list)
   
    Graphics.transition

    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end

    Graphics.freeze

    Audio.bgm_stop
    dispose
  end
 
  def update
    update_quit_command
    update_validation_command
    update_current_command
    update_cursor
    update_y_commands_sprite
    update_item_icon
  end
 
  def make_bitmap_title_sprite
    @title_sprite.bitmap = Bitmap.new(100,Font.default_size)
    @title_length = @title_sprite.bitmap.text_size(@current_title).width
    @title_sprite.bitmap = Bitmap.new(@title_length,Font.default_size)
    @title_sprite.x = Graphics.width/2 - @title_sprite.width/2
    @title_sprite.y = 2
    @title_sprite.z = 5
  end
 
  def update_y_commands_sprite
    if @progression_level != 0
      if @current_command > 10 and Input.trigger?(Input::DOWN)
        @commands_sprite.y -= Font.default_size
      end
      if @current_command > 10 and Input.trigger?(Input::UP)
        @commands_sprite.y += Font.default_size
      end
    end
  end
 
  def make_bitmap_commands_sprite
    @height = @current_commands_list.size * Font.default_size + @space*(@current_commands_list.size-1)
   
    @commands_sprite.bitmap = Bitmap.new(100,@height)
   
    @current_commands_list.size.times do |i|
      if @commands_sprite.bitmap.text_size(@current_commands_list[i]).width > @length
        @length = @commands_sprite.bitmap.text_size(@current_commands_list[i]).width
      end
    end
             
    @commands_sprite.bitmap = Bitmap.new(@length,@height)
    if @progression_level == 1
      @commands_sprite.x = 20
    else
      @commands_sprite.x = Graphics.width/2 - @commands_sprite.width/2
    end
    @commands_sprite.y = @title_sprite.y + @title_sprite.height + 10
  end
 
  def refresh_title
    @title_sprite.bitmap.clear
    make_bitmap_title_sprite
    @title_sprite.bitmap.draw_text(0,0,@title_length,Font.default_size,@current_title)
  end
 
  def refresh_info
    if @progression_level < 1
      @info_sprite.bitmap.clear
      remake_bitmap_info_sprite
      @info_sprite.bitmap.draw_text(0,0,@info_length,Font.default_size,@current_infos_list[@current_command])
    end
  end
 
  def remake_bitmap_info_sprite
    @info_length = @info_sprite.bitmap.text_size(@current_infos_list[@current_command]).width
    @info_sprite.bitmap = Bitmap.new(@info_length,Font.default_size)
    @info_sprite.x = Graphics.width/2 - @info_sprite.width/2
    @info_sprite.y = @commands_sprite.y + @commands_sprite.height + 10
    @info_sprite.z = 5
  end
 
  def refresh_commands_list(list)
    @commands_sprite.bitmap.clear
    list.size.times do |i|
      @commands_sprite.bitmap.draw_text(0,i*Font.default_size+@space,@length,Font.default_size,list[i])
    end
  end
 
  def update_current_command
    if Input.trigger?(Input::UP) and @current_command > 0
      @current_command -= 1
      refresh_info
      refresh_item_info
      refresh_nature_info
      refresh_skill_info
      refresh_ability_info
      refresh_pokemon_info
    end
   
    if Input.trigger?(Input::DOWN) and @current_command < @current_commands_list.size-1
      @current_command += 1
      refresh_info
      refresh_item_info
      refresh_nature_info
      refresh_skill_info
      refresh_ability_info
      refresh_pokemon_info
    end
  end
 
  def update_validation_command
    if Input.trigger?(Input::C)
      @progression_level += 1
      if @progression_level == 1
        @current_title = @titles[@current_command+1]
        @current_commands_list = @lists[@current_command]
        case @current_title
        when @titles[1]
          make_item_icon
          make_item_info
        when @titles[2]
          make_pokemon_info
        when @titles[3]
          make_skill_info
        when @titles[4]
          make_ability_info
        when @titles[5]
          make_nature_info
        end
      end
      refresh
    end
  end
 
  def update_quit_command
    if Input.trigger?(Input::B)
      @progression_level -=1
      if @progression_level == 0
        @current_title = @titles[0]
        @current_commands_list = @commands
        @item.dispose if @item != nil
        @item_info.dispose if @item_info != nil
        @nature_info.dispose if @nature_info != nil
        @skill_info.dispose if @skill_info != nil
        @ability_info.dispose if @ability_info != nil
        @pokemon_info.dispose if @pokemon_info != nil
      end
      refresh
    end
  end
 
  def refresh
    @current_infos_list = @infos
    @current_command = 0
    refresh_title
    refresh_info
    make_bitmap_commands_sprite
    refresh_commands_list(@current_commands_list)
    refresh_cursor
    @info_sprite.bitmap.clear
  end
 
  def refresh_cursor
    @cursor.y = @commands_sprite.y
  end
 
  def update_cursor
    @cursor.x = @commands_sprite.x - @cursor.width - 2
    if @current_command <= 10
      @cursor.y = @commands_sprite.y + @current_command*Font.default_size + 9
    end
    @cursor.angle -= 3
  end
 
  def make_item_icon
    @item = Sprite.new
    @item.bitmap = Bitmap.new(Directory.items+(@current_command+1).to_s)
    @item.y = @commands_sprite.y
  end
 
  def update_item_icon
    if @progression_level == 1 and @current_title == @titles[1]
      @item.bitmap = Bitmap.new(Directory.items+(@current_command+1).to_s)
      @item.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_item_info
    @item_text_info = ["Type : "+ItemData.type(@current_command+1).to_s,
                       "Prix : "+ItemData.price(@current_command+1).to_s,
                       "Description : "+ItemData.info(@current_command+1)]
                       
    @height_item_info = @item_text_info.size * Font.default_size + @space*(@item_text_info.size-1)
   
    @item_info = Sprite.new
    @item_info.bitmap = Bitmap.new(100,@height_item_info)
   
    @length_item_info = @item_info.bitmap.text_size(@item_text_info[2]).width

    @item_info.bitmap = Bitmap.new(@length_item_info,@height_item_info)
    @item_info.y = @item.y + @item.height + 10
   
    refresh_item_info
  end
 
  def refresh_item_info
    if @progression_level == 1 and @current_title == @titles[1]
      @item_info.bitmap.clear
      @item_text_info = ["Type : "+ItemData.type(@current_command+1).to_s,
                         "Prix : "+ItemData.price(@current_command+1).to_s,
                         "Description : "+ItemData.info(@current_command+1)]
                       
      @length_item_info = @item_info.bitmap.text_size(@item_text_info[2]).width
                       
      @item_info.bitmap = Bitmap.new(@length_item_info,@height_item_info)
   
      @item_text_info.size.times do |i|
        @item_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_item_info,Font.default_size,@item_text_info[i])
      end
     
      @item_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_nature_info
    @nature_text_info = ["Bonus d'Attaque : "+NatureData.attack_bonus(@current_command).to_s+"%",
                         "Bonus de Défense : "+NatureData.defense_bonus(@current_command).to_s+"%",
                         "Bonus d'Attaque Spéciale : "+NatureData.special_attack_bonus(@current_command).to_s+"%",
                         "Bonus de Défense Spéciale : "+NatureData.special_defense_bonus(@current_command).to_s+"%",
                         "Bonus de Vitesse : "+NatureData.speed_bonus(@current_command).to_s+"%"]
                       
    @height_nature_info = @nature_text_info.size * Font.default_size + @space*(@nature_text_info.size-1)
   
    @nature_info = Sprite.new
    @nature_info.bitmap = Bitmap.new(100,@height_nature_info)
   
    @length_nature_info = 0
                       
    @nature_text_info.size.times do |i|
      if @nature_info.bitmap.text_size(@nature_text_info[i]).width > @length_nature_info
        @length_nature_info = @nature_info.bitmap.text_size(@nature_text_info[i]).width
      end
    end

    @nature_info.bitmap = Bitmap.new(@length_nature_info,@height_nature_info)
    @nature_info.y = @title_sprite.y + @title_sprite.height + 10
   
    refresh_nature_info
  end
 
  def refresh_nature_info
    if @progression_level == 1 and @current_title == @titles[5]
      @nature_info.bitmap.clear
      @nature_text_info = ["Bonus d'Attaque : "+NatureData.attack_bonus(@current_command).to_s+"%",
                           "Bonus de Défense : "+NatureData.defense_bonus(@current_command).to_s+"%",
                           "Bonus d'Attaque Spéciale : "+NatureData.special_attack_bonus(@current_command).to_s+"%",
                           "Bonus de Défense Spéciale : "+NatureData.special_defense_bonus(@current_command).to_s+"%",
                           "Bonus de Vitesse : "+NatureData.speed_bonus(@current_command).to_s+"%"]
                       
      @nature_text_info.size.times do |i|
        if @nature_info.bitmap.text_size(@nature_text_info[i]).width > @length_nature_info
          @length_nature_info = @nature_info.bitmap.text_size(@nature_text_info[i]).width
        end
      end
     
      @nature_info.bitmap = Bitmap.new(@length_nature_info,@height_nature_info)
   
      @nature_text_info.size.times do |i|
        @nature_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_nature_info,Font.default_size,@nature_text_info[i])
      end
     
      @nature_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_skill_info
    @skill_text_info = ["Type : "+SkillData.type(@current_command+1).to_s,
                        "Description : "+SkillData.info(@current_command+1),
                        "PP : "+SkillData.pp(@current_command+1).to_s,
                        "PP Maximum : "+SkillData.ppmax(@current_command+1).to_s,
                        "Puissance : "+SkillData.power(@current_command+1).to_s,
                        "Précision : "+SkillData.accuracy(@current_command+1).to_s,
                        "Catégorie : "+SkillData.category(@current_command+1).to_s,]
                       
    @height_skill_info = @skill_text_info.size * Font.default_size + @space*(@skill_text_info.size-1)
   
    @skill_info = Sprite.new
    @skill_info.bitmap = Bitmap.new(100,@height_skill_info)
   
    @length_skill_info = @skill_info.bitmap.text_size(@skill_text_info[1]).width


    @skill_info.bitmap = Bitmap.new(@length_skill_info,@height_skill_info)
    @skill_info.y = @title_sprite.y + @title_sprite.height + 10
   
    refresh_skill_info
  end
 
  def refresh_skill_info
    if @progression_level == 1 and @current_title == @titles[3]
      @skill_info.bitmap.clear
      @skill_text_info = ["Type : "+SkillData.type(@current_command+1).to_s,
                          "Description : "+SkillData.info(@current_command+1),
                          "PP : "+SkillData.pp(@current_command+1).to_s,
                          "PP Maximum : "+SkillData.ppmax(@current_command+1).to_s,
                          "Puissance : "+SkillData.power(@current_command+1).to_s,
                          "Précision : "+SkillData.accuracy(@current_command+1).to_s,
                          "Catégorie : "+SkillData.category(@current_command+1).to_s,]
                       
      @length_skill_info = @skill_info.bitmap.text_size(@skill_text_info[1]).width
     
      @skill_info.bitmap = Bitmap.new(@length_skill_info,@height_skill_info)
   
      @skill_text_info.size.times do |i|
        @skill_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_skill_info,Font.default_size,@skill_text_info[i])
      end
     
      @skill_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_ability_info
    @ability_text_info = ["Description : "+AbilityData.info(@current_command+1)]
                       
    @height_ability_info = @ability_text_info.size * Font.default_size + @space*(@ability_text_info.size-1)
   
    @ability_info = Sprite.new
    @ability_info.bitmap = Bitmap.new(100,@height_ability_info)
   
    @length_ability_info = @ability_info.bitmap.text_size(@ability_text_info[0]).width

    @ability_info.bitmap = Bitmap.new(@length_ability_info,@height_ability_info)
    @ability_info.y = @title_sprite.y + @title_sprite.height + 10
   
    refresh_ability_info
  end
 
  def refresh_ability_info
    if @progression_level == 1 and @current_title == @titles[4]
      @ability_info.bitmap.clear
      @ability_text_info = ["Description : "+AbilityData.info(@current_command+1)]
                       
      @length_ability_info = @ability_info.bitmap.text_size(@ability_text_info[0]).width
                       
      @ability_info.bitmap = Bitmap.new(@length_ability_info,@height_ability_info)
   
      @ability_text_info.size.times do |i|
        @ability_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_ability_info,Font.default_size,@ability_text_info[i])
      end
     
      @ability_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def make_pokemon_info
    @pokemon_text_info = ["Famille : Pokémon "+PokemonData.family(@current_command+1),
                          "Asexué : "+PokemonData.asexual(@current_command+1).to_s,
                          "Pourcentage de mâle : "+PokemonData.male_ratio(@current_command+1).to_s+"%",
                          "Taux de capture : "+PokemonData.catch_ratio(@current_command+1).to_s,
                          "Expérience : "+PokemonData.experience(@current_command+1).to_s,
                          "Type d'expérience : "+PokemonData.experience_type(@current_command+1).to_s,
                          "Types : "+PokemonData.types(@current_command+1).to_s,
                          "Pré-Evolution : "+PokemonData.post_evolution(@current_command+1).to_s,
                          "Liste des évolutions : "+PokemonData.evolutions_list(@current_command+1).to_s,
                          "Liste des types des évolutions : "+PokemonData.evolution_types_list(@current_command+1).to_s,
                          "Valeur des types des évolutions : "+PokemonData.evolution_values_list(@current_command+1).to_s,
                          "Nombre de pas avant éclosion : "+PokemonData.hatch_steps(@current_command+1).to_s+" pas",
                          "Groupes d'Oeuf : "+PokemonData.egg_groups(@current_command+1).to_s,
                          "Nombre de formes : "+PokemonData.forms_number(@current_command+1).to_s,
                          "Taille : "+PokemonData.height(@current_command+1).to_s+" m",
                          "Poids : "+PokemonData.weight(@current_command+1).to_s+" kg",
                          "PV : "+PokemonData.pv(@current_command+1).to_s,
                          "Attaque : "+PokemonData.attack(@current_command+1).to_s,
                          "Défense : "+PokemonData.defense(@current_command+1).to_s,
                          "Attaque Spéciale : "+PokemonData.special_attack(@current_command+1).to_s,
                          "Défense Spéciale : "+PokemonData.special_defense(@current_command+1).to_s,
                          "Vitesse : "+PokemonData.speed(@current_command+1).to_s,
                          "Nombre d'EV donnés en PV : "+PokemonData.ev_pv(@current_command+1).to_s,
                          "Nombre d'EV donnés en Attaque : "+PokemonData.ev_attack(@current_command+1).to_s,
                          "Nombre d'EV donnés en Défense : "+PokemonData.ev_defense(@current_command+1).to_s,
                          "Nombre d'EV donnés en Attaque Spéciale : "+PokemonData.ev_special_attack(@current_command+1).to_s,
                          "Nombre d'EV donnés en Défense Spéciale : "+PokemonData.ev_special_defense(@current_command+1).to_s,
                          "Nombre d'EV donnés en Vitesse : "+PokemonData.ev_speed(@current_command+1).to_s,
                          "Talents : "+PokemonData.talents_list(@current_command+1).to_s,
                          "Description : "+PokemonData.ev_pv(@current_command+1).to_s,
                          "Attaques apprises par niveau : "+PokemonData.level_skills_list(@current_command+1).to_s,
                          "Attaques apprenables : "+PokemonData.learnable_skills_list(@current_command+1).to_s,
                          "Attaques apprenables par reproduction : "+PokemonData.reproduction_skills_list(@current_command+1).to_s,
                          "Attaques apprenables par le Maître des Capacités: "+PokemonData.skill_master_list(@current_command+1).to_s,]
                       
    @height_pokemon_info = @pokemon_text_info.size * Font.default_size + @space*(@pokemon_text_info.size-1)
   
    @pokemon_info = Sprite.new
    @pokemon_info.bitmap = Bitmap.new(100,@height_pokemon_info)
   
    @length_pokemon_info = 0
                       
    @pokemon_text_info.size.times do |i|
      if @pokemon_info.bitmap.text_size(@pokemon_text_info[i]).width > @length_pokemon_info
        @length_pokemon_info = @pokemon_info.bitmap.text_size(@pokemon_text_info[i]).width
      end
    end

    @pokemon_info.bitmap = Bitmap.new(@length_pokemon_info,@height_pokemon_info)
    @pokemon_info.y = @title_sprite.y + @title_sprite.height + 10
   
    refresh_pokemon_info
  end
 
  def refresh_pokemon_info
    if @progression_level == 1 and @current_title == @titles[2]
      @pokemon_info.bitmap.clear
      @pokemon_text_info = ["Famille : Pokémon "+PokemonData.family(@current_command+1),
                            "Asexué : "+PokemonData.asexual(@current_command+1).to_s,
                            "Pourcentage de mâle : "+PokemonData.male_ratio(@current_command+1).to_s+"%",
                            "Taux de capture : "+PokemonData.catch_ratio(@current_command+1).to_s,
                            "Expérience : "+PokemonData.experience(@current_command+1).to_s,
                            "Type d'expérience : "+PokemonData.experience_type(@current_command+1).to_s,
                            "Types : "+PokemonData.types(@current_command+1).to_s,
                            "Pré-Evolution : "+PokemonData.post_evolution(@current_command+1).to_s,
                            "Liste des évolutions : "+PokemonData.evolutions_list(@current_command+1).to_s,
                            "Liste des types des évolutions : "+PokemonData.evolution_types_list(@current_command+1).to_s,
                            "Valeur des types des évolutions : "+PokemonData.evolution_values_list(@current_command+1).to_s,
                            "Nombre de pas avant éclosion : "+PokemonData.hatch_steps(@current_command+1).to_s+" pas",
                            "Groupes d'Oeuf : "+PokemonData.egg_groups(@current_command+1).to_s,
                            "Nombre de formes : "+PokemonData.forms_number(@current_command+1).to_s,
                            "Taille : "+PokemonData.height(@current_command+1).to_s+" m",
                            "Poids : "+PokemonData.weight(@current_command+1).to_s+" kg",
                            "PV : "+PokemonData.pv(@current_command+1).to_s,
                            "Attaque : "+PokemonData.attack(@current_command+1).to_s,
                            "Défense : "+PokemonData.defense(@current_command+1).to_s,
                            "Attaque Spéciale : "+PokemonData.special_attack(@current_command+1).to_s,
                            "Défense Spéciale : "+PokemonData.special_defense(@current_command+1).to_s,
                            "Vitesse : "+PokemonData.speed(@current_command+1).to_s,
                            "Nombre d'EV donnés en PV : "+PokemonData.ev_pv(@current_command+1).to_s,
                            "Nombre d'EV donnés en Attaque : "+PokemonData.ev_attack(@current_command+1).to_s,
                            "Nombre d'EV donnés en Défense : "+PokemonData.ev_defense(@current_command+1).to_s,
                            "Nombre d'EV donnés en Attaque Spéciale : "+PokemonData.ev_special_attack(@current_command+1).to_s,
                            "Nombre d'EV donnés en Défense Spéciale : "+PokemonData.ev_special_defense(@current_command+1).to_s,
                            "Nombre d'EV donnés en Vitesse : "+PokemonData.ev_speed(@current_command+1).to_s,
                            "Talents : "+PokemonData.talents_list(@current_command+1).to_s,
                            "Description : "+PokemonData.ev_pv(@current_command+1).to_s,
                            "Attaques apprises par niveau : "+PokemonData.level_skills_list(@current_command+1).to_s,
                            "Attaques apprenables : "+PokemonData.learnable_skills_list(@current_command+1).to_s,
                            "Attaques apprenables par reproduction : "+PokemonData.reproduction_skills_list(@current_command+1).to_s,
                            "Attaques apprenables par le Maître des Capacités: "+PokemonData.skill_master_list(@current_command+1).to_s,]
                       
      @pokemon_text_info.size.times do |i|
        if @pokemon_info.bitmap.text_size(@pokemon_text_info[i]).width > @length_pokemon_info
          @length_pokemon_info = @pokemon_info.bitmap.text_size(@pokemon_text_info[i]).width
        end
      end
     
      @pokemon_info.bitmap = Bitmap.new(@length_pokemon_info,@height_pokemon_info)
   
      @pokemon_text_info.size.times do |i|
        @pokemon_info.bitmap.draw_text(0,i*Font.default_size+@space,@length_pokemon_info,Font.default_size,@pokemon_text_info[i])
      end
     
      @pokemon_info.x = @commands_sprite.x + @commands_sprite.width + 10
    end
  end
 
  def dispose
    @title_sprite.dispose
    @commands_sprite.dispose
  end
 
end

Posté par Nuri Yuri le 3 Jan - 18:01 (2015)
Force un update complet de ce qui doit être affiché quand tu sélectionnes une liste.

Posté par Zohran le 3 Jan - 18:32 (2015)
Nuri Yuri a écrit:
Force un update complet de ce qui doit être affiché quand tu sélectionnes une liste.

Je comprends pas, dans la méthode make_pokemon_info, je fais appelle à la méthode refresh, donc c'est un update globale, non?

Posté par Nuri Yuri le 3 Jan - 19:07 (2015)
T'es sur que refresh rafraichi absolument tout ce qu'il faut ?

Posté par Zohran le 3 Jan - 19:48 (2015)
Bah il me semble oui... Je revérifie et j'édite mon message.
Sinon, j'ai une question suite au script de Zeus : http://www.rpg-maker.fr/scripts-233-input-ultimate.html
Si par exemple je veux vérifier si la touche "a" est pressée, je fais comment? Je pige pas là, j'ai essayé en faisant if Input.trigger("A") (majuscule ou miniscule), mais aucune réaction, pas de bug, mais aucune détection...

Posté par Pαlвσlѕку le 3 Jan - 20:22 (2015)
Sur le lien j'ai trouvé ça :
Code:
Keyboard.press?(Keys.index("W"))


Sinon si c'est la commande habituelle (et j'en doute), c'est : Input.trigger?(Input::A)

Posté par Zohran le 3 Jan - 20:24 (2015)
Pαlвσlѕку a écrit:
Sur le lien j'ai trouvé ça :
Code:
Keyboard.press?(Keys.index("W"))


Sinon si c'est la commande habituelle (et j'en doute), c'est : Input.trigger?(Input::A)

Nan, j'ai test, la commande Keys.index n'existe pas. Ou alors ça ne marche pas sous vx ace...

Posté par Pαlвσlѕку le 3 Jan - 20:30 (2015)
Tu as pensé à récupérer le tableau Keys présent sur le lien ?

Posté par Zohran le 3 Jan - 20:47 (2015)
Pαlвσlѕку a écrit:
Tu as pensé à récupérer le tableau Keys présent sur le lien ?

Oui mais ça ne change rien. Ce qui est logique d'ailleurs, que tu mettes un tableau nommé Keys et en l'appelant de la maniere Keys.index, ou que tu mettes directement ce qui est dans l'index, ça change rien...
Bizarre, à croire que ce script ne fonctionne pas, comme beaucoup de script sur Oniromancie xD

Posté par Tokeur le 4 Jan - 16:10 (2015)
Hum après avoir lu ton problème j'me suis dit que j'allais testé, et après qq remises en forme laborieuses pour scripter, le script marche très bien ._.
Personnellement, je prends le tableau de Keys une lisibilité nettement meilleure, c'est peut être là que tu te trompes, index return l'index de ta valeur, et non la valeur en elle même...
Ex : je vois que "A" est à la 65ème place du tableau, donc mon Keys.index("A") va retourner 65 :d
Sinon, c'est peut-être t'as peut être oublié d'update le tableau d'index justement ? Perso j'ai déclaré un tableau de Keys global et j'ai fait ceci pour tester une condition :
Code:
Keyboard.update([$Keys.index("M")])
Keyboard.press?($Keys.index("M"))

Et ça marche très bien :d

Posté par Zohran le 4 Jan - 17:24 (2015)
Tokeur a écrit:
Hum après avoir lu ton problème j'me suis dit que j'allais testé, et après qq remises en forme laborieuses pour scripter, le script marche très bien ._.
Personnellement, je prends le tableau de Keys une lisibilité nettement meilleure, c'est peut être là que tu te trompes, index return l'index de ta valeur, et non la valeur en elle même...
Ex : je vois que "A" est à la 65ème place du tableau, donc mon Keys.index("A") va retourner 65 :d
Sinon, c'est peut-être t'as peut être oublié d'update le tableau d'index justement ? Perso j'ai déclaré un tableau de Keys global et j'ai fait ceci pour tester une condition :
Code:
Keyboard.update([$Keys.index("M")])
Keyboard.press?($Keys.index("M"))

Et ça marche très bien :d

Effectivement, je m'étais gourré la dessus x) Par contre, ça ne marche toujours pas, peut-être incompatible sous RGSS 3....