Ogłoszenie 

Uwaga! To forum jest w trybie offline.
Wszelką pomoc uzyskasz pod adresem
forum.ultimateam.pl


Administracja Forum


Poprzedni temat «» Następny temat
Celowanie
Autor Wiadomość
Angius 

Nie wkurzać



Preferowany:
RPG Maker VX

Pomógł: 104 razy
Dołączył: 30 Paź 2010
Posty: 1276
Skąd: wROCK
Wysłany: Czw 27 Paź, 2011 19:06
Celowanie
BullsEye

Opis:
Skrypt dodaje minigierkę polegającą na naciśnięciu przycisku w odpowiednim momencie.

Info:
Autor: Shanghai
Tłumaczenie: Angius

Skrypt:
Spoiler:

Kod:
#===============================================================================
#
# Shanghai Simple Script - Minigame Bull's Eye
# Last Date Updated: 2010.05.18
# Level: Normal
#
# This is a minigame script. It's easy to play. Press Z when the cursor is right
# above the bull's eye or within the red region.
#===============================================================================
# Instrukcje
# -----------------------------------------------------------------------------
# Aby zainstalować skrypt otwórz edytor skryptów, a następnie wklej kod
# pod sekcją  Materials, lecz ponad sekcją  Main.
#
# Skrypt wywołaj
#   $game_variables[1] = bulls_eye_game(x, y)
#
# x jest marginesem błędu podanym w procentach, y jest prędkością celownika.
# Działa z BEM.
#===============================================================================

$imported = {} if $imported == nil
$imported["MinigameBullsEye"] = true

module SSS
  # Poniżej znajduje się nazwa pliku z grafikami do skryptu.
  # Umieść go w Graphics\System.
  BULLS_EYE_SHEET = "MiniGameBullseye"
  # Poniżej ustawiasz efekty dźwiękowe.
  BULLS_EYE_SHOOT = RPG::SE.new("Bow1", 80, 100) #Strzał
  BULLS_EYE_CLICK = RPG::SE.new("Cursor", 40, 150) #Kliknięcie
  BULLS_EYE_PERFECT = RPG::SE.new("Chime2", 80, 120) #Doskonale
  BULLS_EYE_ALMOST  = RPG::SE.new("Decision2", 80, 100) #Prawie
  BULLS_EYE_MISSED  = RPG::SE.new("Buzzer2", 80, 100) #Pudło
 
module SPRITESET
  #--------------------------------------------------------------------------
  # * Bulls Eye Game
  #--------------------------------------------------------------------------
  def bulls_eye_game(percent = 15, speed = 10)
    @bulls_eye_percent = percent
    @bulls_eye_speed = speed
    create_bulls_eye_sprites
  end
  #--------------------------------------------------------------------------
  # * Create Bulls Eye Sprites
  #--------------------------------------------------------------------------
  def create_bulls_eye_sprites
    @bulls_eye_sprite = Sprite_Base.new(@viewport3)
    bitmap1 = Bitmap.new(512, 72)
    bitmap2 = Cache.system(SSS::BULLS_EYE_SHEET)
    # Make the Main Body
    rect = Rect.new(0, 0, 512, 24)
    bitmap1.blt(0, 24, bitmap2, rect)
    # Make the Target Safe Zone
    rect = Rect.new(0, 24, 0, 24)
    rect.width = @bulls_eye_percent * 512 / 100
    rect.x = (512 - rect.width) / 2
    bitmap1.blt(rect.x, 24, bitmap2, rect)
    # Make the Target Center
    rect = Rect.new(488, 48, 24, 24)
    bitmap1.blt(244, 24, bitmap2, rect)
    # Make the Instructions
    rect = Rect.new(312, 48, 176, 24)
    bitmap1.blt(168, 48, bitmap2, rect)
    # Apply Sprite
    @bulls_eye_sprite.bitmap = bitmap1
    @bulls_eye_sprite.x = (Graphics.width - 512) / 2
    @bulls_eye_sprite.y = Graphics.height - 200
    # Arrow Sprite
    @arrow_shoot_sprite = Sprite_Base.new(@viewport3)
    @arrow_shoot_sprite.bitmap = Bitmap.new(24, 24)
    rect = Rect.new(0, 48, 24, 24)
    @arrow_shoot_sprite.bitmap.blt(0, 0, bitmap2, rect)
    @arrow_shoot_sprite.ox = 12
    @arrow_shoot_sprite.oy = 24
    @arrow_shoot_sprite.x = @bulls_eye_sprite.x
    @arrow_shoot_sprite.y = @bulls_eye_sprite.y + 24
    # Make Sounds
    @shoot_sound = SSS::BULLS_EYE_SHOOT
    @click_sound = SSS::BULLS_EYE_CLICK
    @bulls_eye_direction = 0
  end
  #--------------------------------------------------------------------------
  # * Dispose Bulls Eye Sprites
  #--------------------------------------------------------------------------
  def dispose_bulls_eye_sprites
    unless @bulls_eye_sprite.nil?
      @bulls_eye_sprite.dispose
      @bulls_eye_sprite = nil
    end
    unless @arrow_shoot_sprite.nil?
      @arrow_shoot_sprite.dispose
      @arrow_shoot_sprite = nil
    end
    unless @results_sprite.nil?
      @results_sprite.dispose
      @results_sprite = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Update Bulls Eye Sprites
  #--------------------------------------------------------------------------
  def update_bulls_eye_sprites
    @bulls_eye_sprite.update
    if @bulls_eye_direction == 0
      m = Graphics.width - @bulls_eye_sprite.x
      @arrow_shoot_sprite.x = [@arrow_shoot_sprite.x + @bulls_eye_speed, m].min
      @bulls_eye_direction = 1 if @arrow_shoot_sprite.x >= m
    else
      m = @bulls_eye_sprite.x
      @arrow_shoot_sprite.x = [@arrow_shoot_sprite.x - @bulls_eye_speed, m].max
      @bulls_eye_direction = 0 if @arrow_shoot_sprite.x <= m
    end
    @click_sound.play if @bulls_eye_speed >= 0
    @arrow_shoot_sprite.update
  end
  #--------------------------------------------------------------------------
  # * Create Bulls Eye Results
  #--------------------------------------------------------------------------
  def create_bulls_eye_results
    @results_sprite = Sprite_Base.new(@viewport3)
    @results_sprite.bitmap = Bitmap.new(96, 24)
    bitmap = Cache.system(SSS::BULLS_EYE_SHEET)
    mx = @bulls_eye_sprite.x
    perfect_location = (mx+244)..(mx+268)
    almost_percent = (@bulls_eye_percent * 512 / 100) / 2
    almost_location1 = 512/2 - almost_percent
    almost_location2 = 512/2 + almost_percent
    if (mx+244..mx+268) === @arrow_shoot_sprite.x
      SSS::BULLS_EYE_PERFECT.play
      @result = 2
      rect = Rect.new(24, 48, 96, 24)
    elsif (mx+almost_location1..mx+almost_location2) === @arrow_shoot_sprite.x
      SSS::BULLS_EYE_ALMOST.play
      @result = 1
      rect = Rect.new(120, 48, 96, 24)
    else
      SSS::BULLS_EYE_MISSED.play
      @result = 0
      rect = Rect.new(216, 48, 96, 24)
    end
    @results_sprite.bitmap.blt(0, 0, bitmap, rect)
    @results_sprite.ox = 48
    @results_sprite.x = Graphics.width / 2
    @results_sprite.y = @bulls_eye_sprite.y - 24
  end
  #--------------------------------------------------------------------------
  # * Stop Bulls Eye Sprites
  #--------------------------------------------------------------------------
  def stop_bulls_eye_sprites
    @bulls_eye_speed = 0
    @shoot_sound.play
    wait = 60
    loop do
      wait -= 1
      $scene.update_basic
      @results_sprite.update unless @results_sprite.nil?
      case wait
      when 40
        create_bulls_eye_results
      when 0
        break
      end
    end
    dispose_bulls_eye_sprites
    return @result
  end
end
end

#==============================================================================
# ** Game_Interpreter
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Bulls Eye Game
  #--------------------------------------------------------------------------
  def bulls_eye(percent = 15, speed = 10)
    return false unless $scene.is_a?(Scene_Map) or $scene.is_a?(Scene_Battle)
    return $scene.bulls_eye(percent, speed)
  end
end

#==============================================================================
# ** Spriteset_Map
#==============================================================================

class Spriteset_Map
  include SSS::SPRITESET
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  alias dispose_sss_spriteset_map_bulls_eye dispose unless $@
  def dispose
    dispose_sss_spriteset_map_bulls_eye
    dispose_bulls_eye_sprites
  end
end

#==============================================================================
# ** Spriteset_Battle
#==============================================================================

class Spriteset_Battle
  include SSS::SPRITESET
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  alias dispose_sss_spriteset_battle_bulls_eye dispose unless $@
  def dispose
    dispose_sss_spriteset_battle_bulls_eye
    dispose_bulls_eye_sprites
  end
end

#==============================================================================
# ** Scene_Map
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :spriteset
  #--------------------------------------------------------------------------
  # * Bulls Eye Game
  #--------------------------------------------------------------------------
  def bulls_eye(percent = 15, speed = 10)
    @spriteset.bulls_eye_game(percent, speed)
    loop do
      update_basic
      @spriteset.update_bulls_eye_sprites
      break if Input.trigger?(Input::C)
    end
    return @spriteset.stop_bulls_eye_sprites
  end
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :spriteset
  #--------------------------------------------------------------------------
  # * Bulls Eye Game
  #--------------------------------------------------------------------------
  def bulls_eye(percent = 15, speed = 10)
    @spriteset.bulls_eye_game(percent, speed)
    loop do
      update_basic
      @spriteset.update_bulls_eye_sprites
      break if Input.trigger?(Input::C)
    end
    return @spriteset.stop_bulls_eye_sprites
  end
end

#===============================================================================
#
# END OF FILE
#
#===============================================================================



Konfiguracja:
Kod:
# Aby zainstalować skrypt otwórz edytor skryptów, a następnie wklej kod
# pod sekcją  Materials, lecz ponad sekcją  Main.
#
# Skrypt wywołaj
#   $game_variables[1] = bulls_eye_game(x, y)
#
# x jest marginesem błędu podanym w procentach, y jest prędkością celownika.
# Działa z BEM.

Numer przy game_variables to oczywiście numer zmiennej. Wystarczy jedna zmienna na cały skrypt.

Grafiki:
________________________
"Na trolla pewne są tylko dwie pewne metody, jedna samopowtarzalna i druga, wymagająca przeładowania ręcznego."


Ostatnio zmieniony przez Ayene Pią 28 Paź, 2011 10:01, w całości zmieniany 1 raz  
 
 
Vrona 




Preferowany:
RPG Maker VXAce

Pomógł: 26 razy
Dołączył: 25 Wrz 2011
Posty: 236
Skąd: ty się tu wziąłeś?
Wysłany: Czw 27 Paź, 2011 19:10
Cytat:
Kod:
# x jest marginesem błędu podanym w procentach, y jest prędkością celownika.
# Działa z BEM.


O ile to zwiększa daną zmienną?
________________________
Pomogłem daj "Pomógł",BIJAAACZ!



 
 
Angius 

Nie wkurzać



Preferowany:
RPG Maker VX

Pomógł: 104 razy
Dołączył: 30 Paź 2010
Posty: 1276
Skąd: wROCK
Wysłany: Czw 27 Paź, 2011 19:11
O ile się nie mylę, to jest to procentowy wynik - w sam środek to 100, kawałek obok 90, etc.
________________________
"Na trolla pewne są tylko dwie pewne metody, jedna samopowtarzalna i druga, wymagająca przeładowania ręcznego."


 
 
Wyświetl posty z ostatnich:   
Odpowiedz do tematu
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Nie możesz załączać plików na tym forum
Możesz ściągać załączniki na tym forum
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group | Template Klam by Ayene