Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # TITOLI DI CODA
- #===============================================================================
- # Autore: Holy87
- # Versione: 1.0
- #-------------------------------------------------------------------------------
- # Mostrare dei titoli di coda alla fine del gioco non è mai stato così facile.
- #-------------------------------------------------------------------------------
- # Istruzioni:
- # Copiare lo script sotto Materials, prima del Main. Create un file di testo
- # (possibilmente con Notepad++) e piazzateci tutto quello che volete scriverci.
- # Nella configurazione, impostate il nome del file di testo dove c'è scritto
- # Nome_File. Potete cambiare anche font, grandezza, velocità e scorrimento.
- # Per avviare i titoli di coda, basta inserire in un "chiama script"
- # call_ending
- #-------------------------------------------------------------------------------
- # Nota: è anche possibile inserire delle immagini su un rigo scrivendo all'inizio
- # di esso il tag [IMG]nomeimmagine
- # l'immagine deve risiedere nella cartella pictures.
- #-------------------------------------------------------------------------------
- module H87_Ending
- #===============================================================================
- # ** CONFIGURAZIONE **
- #===============================================================================
- #Nome del file che contiene il testo dei titoli di coda
- Nome_File = "crediti.txt"
- #Permettere lo scorrimento veloce con INVIO?
- AllowFast = true
- #Velocità di scorrimento standard
- Speed = 2
- #Spaziatura rigo
- WLH = 24
- #Nome del font:
- Name = "Verdana"
- #Grandezza del font:
- Size = 20
- #Grassetto?
- Bold = false
- #Corsivo?
- Italic = false
- #Ombrato?
- Shadow = false
- #Colore del testo:
- Colore = Color.new(255,255,255)#(Rosso,Verde,Blu) da 0 a 255
- end
- #===============================================================================
- # ** Classe Scene_Ending
- #===============================================================================
- class Scene_Ending < Scene_Base
- include H87_Ending
- def start
- super
- @timecount = 0
- create_menu_background
- carica_testo
- crea_finestra
- end
- #-----------------------------------------------------------------------------
- # * Carica il testo dal file
- #-----------------------------------------------------------------------------
- def carica_testo
- if File.exist? (Nome_File) #apre il file in sola lett.
- array = []
- File.open(Nome_File,"r") do |f|
- f.each_line {|riga| array.push(riga.to_s)}
- @testo = array
- end
- else
- p "File non trovato"
- @testo = "Vuoto"
- end
- end
- #-----------------------------------------------------------------------------
- # * Crea la finestra del testo
- #-----------------------------------------------------------------------------
- def crea_finestra
- @quadrato = Viewport.new(0,0,Graphics.width,Graphics.height)
- @finestra = Ending_Text.new(@testo)
- @finestra.viewport = @quadrato
- @finestra.y = Graphics.height
- end
- #-----------------------------------------------------------------------------
- # * aggiornamento
- #-----------------------------------------------------------------------------
- def update
- super
- aggiorna_finestra(Input.press?(Input::C))
- close if @finestra.ended?
- end
- #-----------------------------------------------------------------------------
- # * aggiornamento del testo
- #-----------------------------------------------------------------------------
- def aggiorna_finestra(accelerato)
- @timecount += 1
- if @timecount >= Speed or accelerato
- @finestra.y -= 1
- @timecount = 0
- end
- end
- #-----------------------------------------------------------------------------
- # * chiusura
- #-----------------------------------------------------------------------------
- def close
- $scene = Scene_Map.new
- end
- #-----------------------------------------------------------------------------
- # * terminate
- #-----------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @finestra.dispose
- end
- end
- #===============================================================================
- # Classe Info_Text
- #===============================================================================
- class Ending_Text
- include H87_Ending
- attr_reader :height
- attr_reader :width
- #-----------------------------------------------------------------------------
- # * inizializzazione
- #-----------------------------------------------------------------------------
- def initialize(testo)
- @tw = WLH
- @testo = testo
- @height = calc_lenght
- @width = Graphics.width
- @spritetext = Sprite.new
- @spritetext.bitmap = create_bitmap
- end
- #-----------------------------------------------------------------------------
- # * restituisce la x
- #-----------------------------------------------------------------------------
- def x
- return @spritetext.x
- end
- #-----------------------------------------------------------------------------
- # * restituisce la y
- #-----------------------------------------------------------------------------
- def y
- return @spritetext.y
- end
- #-----------------------------------------------------------------------------
- # * imposta la x da valore
- #-----------------------------------------------------------------------------
- def x=(value)
- @spritetext.x=value
- end
- #-----------------------------------------------------------------------------
- # * imposta la y da valore
- #-----------------------------------------------------------------------------
- def y=(value)
- @spritetext.y=value
- end
- #-----------------------------------------------------------------------------
- # * imposta il viewport
- #-----------------------------------------------------------------------------
- def viewport=(viewport)
- @spritetext.viewport = viewport
- end
- #-----------------------------------------------------------------------------
- # * imposta l'opacità
- #-----------------------------------------------------------------------------
- def opacity=(opa)
- @spritetext.opacity = opa
- end
- #-----------------------------------------------------------------------------
- # * restituisce l'opacità
- #-----------------------------------------------------------------------------
- def opacity
- return @spritetext.opacity
- end
- #-----------------------------------------------------------------------------
- # * calcola quanto è grande l'immagine
- #-----------------------------------------------------------------------------
- def calc_lenght
- l = 0
- for i in 0..@testo.size-1
- if image?(@testo[i])
- l += img_lenght(@testo[i])
- else
- l += @tw
- end
- end
- return l+8
- end
- #-----------------------------------------------------------------------------
- # * il testo si riferisce ad un'immagine?
- #-----------------------------------------------------------------------------
- def image?(text)
- return true if text[0..4].upcase == "[IMG]"
- end
- #-----------------------------------------------------------------------------
- # * calcola l'altezza dell'immagine del testo
- #-----------------------------------------------------------------------------
- def img_lenght(txt)
- bitmap = Cache.picture(image_from_text(txt).chomp)
- return bitmap.height
- end
- #-----------------------------------------------------------------------------
- # * prende il nome della picture
- #-----------------------------------------------------------------------------
- def image_from_text(txt)
- return txt.gsub("[IMG]","")
- end
- #-----------------------------------------------------------------------------
- # * crea la bitmap principale
- #-----------------------------------------------------------------------------
- def create_bitmap
- bitmap = Bitmap.new(@width,@height)
- bitmap.font.color = Colore
- bitmap.font.name = Name
- bitmap.font.size = Size
- bitmap.font.bold = Bold
- bitmap.font.italic = Italic
- bitmap.font.shadow = Shadow
- l = 4
- @lenght = l #meglio usare una variabile d'istanza...
- for i in 0..@testo.size-1
- fetch_text(@testo[i],bitmap)
- end
- return bitmap
- end
- #-----------------------------------------------------------------------------
- # * crea il testo al rigo designato
- #-----------------------------------------------------------------------------
- def fetch_text(text,bitmap)
- if image?(text) #se è un immagine
- text.chomp!
- bitmap2 = Cache.picture(image_from_text(text))
- x = (@width - bitmap2.width)/2
- rect = Rect.new(0,0,bitmap2.width,bitmap2.height)
- bitmap.blt(x, @lenght, bitmap2, rect)
- @lenght += bitmap2.height
- else #se è del normale testo
- bitmap.draw_text(4,@lenght,self.width-4,@tw,formatted_text(text),1)
- @lenght += @tw
- end
- end
- #-----------------------------------------------------------------------------
- # * dimissione dello sprite
- #-----------------------------------------------------------------------------
- def dispose
- @spritetext.dispose
- end
- #-----------------------------------------------------------------------------
- # * formatta il rigo
- #-----------------------------------------------------------------------------
- def formatted_text(text)
- text.gsub!("\n","") if text.gsub("\n","") != nil
- text.gsub!("[R]","®")
- text.gsub!("[C]","©")
- text.gsub!("[L]","♥")
- text.gsub!("[S]","★")
- text.gsub!("[B]","●")
- return text
- end
- #-----------------------------------------------------------------------------
- # * restituisce true se i titoli di coda sono finiti
- #-----------------------------------------------------------------------------
- def ended?
- return true if self.y <= 0-self.height
- return false
- end
- end #infotext
- #===============================================================================
- # ** Classe Game_Interpreter
- #===============================================================================
- class Game_Interpreter
- def call_credits
- $scene = Scene_Ending.new
- end
- end #game_interpreter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement