Change color of text in game - corbaque - 11-05-2006
Change color of text in game
corbaque
Nov 5 2006
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
Code: #===================================
# Script by Corbaque
#---------------------------------------------------------------
# 04 / 07 / 2006
#---------------------------------------------------------------
# This script is used to modify the color of the texts
# In the game
#===================================
class Text_color
#-------------------------------------------------------------
# Methode d'appel - Définition des variable
#-------------------------------------------------------------
def initialize
if defined?(@color_proto) then @color_proto = $normal_c else
@color_proto = Color.new(255, 255, 255, 255)
@r = 255
@v = 255
@b = 255
@o = 255
end
@i = 0
@color_pulse = 0
end
def main
#-----------------------------------------------------------
# Methode Maître - Définition des fenêtre,
# Boucle de mise à jour et suppression des
# Fenêtre (lorsque qu'une autre classe est
# Appelée
#-----------------------------------------------------------
@demo = Window_Base.new(0, 0, 640, 480)
@demo.contents = Bitmap.new(608, 442)
@demo.contents.font.name = $fontface
@demo.contents.font.size = 50
@demo.contents.font.bold = true
@selec = Window_Command.new(400,
["Rouge", "Vert", "Bleu", "Opacitée", "Défaut", "Texte =>"])
@selec.x = 120
@selec.y = 200
@jauge = Window_Base.new(0, 0, 280, @selec.height)
@jauge.contents = Bitmap.new(@selec.width, @selec.height)
@jauge.contents.font.name = $fontface
@jauge.contents.font.size = $fontsize
@jauge.x = 220
@jauge.y = 200
@jauge.opacity = @jauge.back_opacity = 0
Graphics.transition
while $scene == self
Graphics.update
Input.update
update
end
Graphics.freeze
@demo.dispose
@jauge.dispose
@selec.dispose
end
#-------------------------------------------------------------
# Methode de mise à jour
#-------------------------------------------------------------
def update
# Mise à jour des fenêtres
@color_proto = Color.new(@r, @v, @b, @o)
@demo.contents.clear
@demo.contents.font.color = @color_proto
@demo.contents.draw_text(250, 4, 200, 96, "Texte")
@demo.update
@jauge.contents.clear
# Ce code monstre est en faite tout simple, chacune de ces lignes
# Servent à tracer un fill (ligne) et sont classés de manière à faire
# Des jauges, ce code est en quatre parties.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Jauge de rouge
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@jauge.contents.fill_rect(4, 8, 240, 1, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 9, 240, 1, Color.new(100, 100, 100, 255))
@jauge.contents.fill_rect(4, 10, 240, 1, Color.new(200, 200, 200, 255))
@jauge.contents.fill_rect(4, 11, 240, 1, Color.new(255, 255, 255, 255))
@jauge.contents.fill_rect(4, 12, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 16, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 17, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 21, 240, 1, Color.new(255, 255, 255, 255))
@jauge.contents.fill_rect(4, 22, 240, 1, Color.new(200, 200, 200, 255))
@jauge.contents.fill_rect(4, 23, 240, 1, Color.new(100, 100, 100, 255))
@jauge.contents.fill_rect(4, 24, 240, 1, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 12, @r * 240 / 255, 2, Color.new(@r, 0, 0, 105))
@jauge.contents.fill_rect(4, 14, @r * 240 / 255, 2, Color.new(@r, 0, 0, 255))
@jauge.contents.fill_rect(4, 16, @r * 240 / 255, 2, Color.new(@r, 0, 0, 255))
@jauge.contents.fill_rect(4, 18, @r * 240 / 255, 2, Color.new(@r, 0, 0, 105))
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Jauge de vert
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@jauge.contents.fill_rect(4, 32 + 8, 240, 1, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 32 + 9, 240, 1, Color.new(100, 100, 100, 255))
@jauge.contents.fill_rect(4, 32 + 10, 240, 1, Color.new(200, 200, 200, 255))
@jauge.contents.fill_rect(4, 32 + 11, 240, 1, Color.new(255, 255, 255, 255))
@jauge.contents.fill_rect(4, 32 + 12, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 32 + 16, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 32 + 17, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 32 + 21, 240, 1, Color.new(255, 255, 255, 255))
@jauge.contents.fill_rect(4, 32 + 22, 240, 1, Color.new(200, 200, 200, 255))
@jauge.contents.fill_rect(4, 32 + 23, 240, 1, Color.new(100, 100, 100, 255))
@jauge.contents.fill_rect(4, 32 + 24, 240, 1, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 32 + 12, @v * 240 / 255, 2, Color.new(0, @v, 0, 105))
@jauge.contents.fill_rect(4, 32 + 14, @v * 240 / 255, 2, Color.new(0, @v, 0, 255))
@jauge.contents.fill_rect(4, 32 + 16, @v * 240 / 255, 2, Color.new(0, @v, 0, 255))
@jauge.contents.fill_rect(4, 32 + 18, @v * 240 / 255, 2, Color.new(0, @v, 0, 105))
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Jauge de bleu
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@jauge.contents.fill_rect(4, 64 + 8, 240, 1, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 64 + 9, 240, 1, Color.new(100, 100, 100, 255))
@jauge.contents.fill_rect(4, 64 + 10, 240, 1, Color.new(200, 200, 200, 255))
@jauge.contents.fill_rect(4, 64 + 11, 240, 1, Color.new(255, 255, 255, 255))
@jauge.contents.fill_rect(4, 64 + 12, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 64 + 16, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 64 + 17, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 64 + 21, 240, 1, Color.new(255, 255, 255, 255))
@jauge.contents.fill_rect(4, 64 + 22, 240, 1, Color.new(200, 200, 200, 255))
@jauge.contents.fill_rect(4, 64 + 23, 240, 1, Color.new(100, 100, 100, 255))
@jauge.contents.fill_rect(4, 64 + 24, 240, 1, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 64 + 12, @b * 240 / 255, 2, Color.new(0, 0, @b, 105))
@jauge.contents.fill_rect(4, 64 + 14, @b * 240 / 255, 2, Color.new(0, 0, @b, 255))
@jauge.contents.fill_rect(4, 64 + 16, @b * 240 / 255, 2, Color.new(0, 0, @b, 255))
@jauge.contents.fill_rect(4, 64 + 18, @b * 240 / 255, 2, Color.new(0, 0, @b, 105))
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Jauge d'opacitée
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@jauge.contents.fill_rect(4, 96 + 8, 240, 1, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 96 + 9, 240, 1, Color.new(100, 100, 100, 255))
@jauge.contents.fill_rect(4, 96 + 10, 240, 1, Color.new(200, 200, 200, 255))
@jauge.contents.fill_rect(4, 96 + 11, 240, 1, Color.new(255, 255, 255, 255))
@jauge.contents.fill_rect(4, 96 + 12, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 96 + 16, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 96 + 17, 240, 4, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 96 + 21, 240, 1, Color.new(255, 255, 255, 255))
@jauge.contents.fill_rect(4, 96 + 22, 240, 1, Color.new(200, 200, 200, 255))
@jauge.contents.fill_rect(4, 96 + 23, 240, 1, Color.new(100, 100, 100, 255))
@jauge.contents.fill_rect(4, 96 + 24, 240, 1, Color.new(0, 0, 0, 255))
@jauge.contents.fill_rect(4, 96 + 12, @o * 240 / 255, 2, Color.new(150, 150, 150, @o))
@jauge.contents.fill_rect(4, 96 + 14, @o * 240 / 255, 2, Color.new(255, 255, 255, @o))
@jauge.contents.fill_rect(4, 96 + 16, @o * 240 / 255, 2, Color.new(255, 255, 255, @o))
@jauge.contents.fill_rect(4, 96 + 18, @o * 240 / 255, 2, Color.new(150, 150, 150, @o))
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Couleur en question
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
case @i
when 0
@jauge.contents.draw_text(4, 128, 100, 96, "Base")
when 1
@jauge.contents.draw_text(4, 128, 200, 96, "Systême")
when 2
@jauge.contents.draw_text(4, 128, 200, 96, "Desactivé")
when 3
@jauge.contents.draw_text(4, 128, 200, 96, "Etat Critique")
when 4
@jauge.contents.draw_text(4, 128, 200, 96, "Mort")
end
@jauge.update
@selec.update
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Celon l'index de la fenêtre,
# Auguementation, diminution et défauts des
# Différents variables, ou conclusion de la
# Classe (Appel du menu par défaut,
# Modifiable
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
case @selec.index
when 0
if Input.repeat?(Input::LEFT)
unless @r < 5
$game_system.se_play($data_system.cursor_se)
@r -= 5
return
end
$game_system.se_play($data_system.buzzer_se)
elsif Input.repeat?(Input::RIGHT)
unless @r > 250
$game_system.se_play($data_system.cursor_se)
@r += 5
return
end
$game_system.se_play($data_system.buzzer_se)
end
when 1
if Input.repeat?(Input::LEFT)
unless @v < 5
$game_system.se_play($data_system.cursor_se)
@v -= 5
return
end
$game_system.se_play($data_system.buzzer_se)
elsif Input.repeat?(Input::RIGHT)
unless @v > 250
$game_system.se_play($data_system.cursor_se)
@v += 5
return
end
$game_system.se_play($data_system.buzzer_se)
end
when 2
if Input.repeat?(Input::LEFT)
unless @b < 5
$game_system.se_play($data_system.cursor_se)
@b -= 5
return
end
$game_system.se_play($data_system.buzzer_se)
elsif Input.repeat?(Input::RIGHT)
unless @b > 250
$game_system.se_play($data_system.cursor_se)
@b += 5
return
end
$game_system.se_play($data_system.buzzer_se)
end
when 3
if Input.repeat?(Input::LEFT)
unless @o < 5
$game_system.se_play($data_system.cursor_se)
@o -= 5
return
end
$game_system.se_play($data_system.buzzer_se)
elsif Input.repeat?(Input::RIGHT)
unless @o > 250
$game_system.se_play($data_system.cursor_se)
@o += 5
return
end
$game_system.se_play($data_system.buzzer_se)
end
when 4
if Input.trigger?(Input::C)
$game_system.se_play($data_system.cursor_se)
@r = 255
@v = 255
@b = 255
@o = 255
end
when 5
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
unless @i == 0
@i -= 1
return
end
@i = 4
elsif Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@i += 1
@i %= 5
end
end
if Input.trigger?(Input::C)
unless @selec.index == 4
case @i
when 0
$normal_c = @color_proto
when 1
$system_c = @color_proto
when 2
$disable_c = @color_proto
when 3
$crisis_c = @color_proto
when 4
$die_c = @color_proto
end
#Replace this line by calls scene which
# you wish, example :
# $scene = Scene_Map.new
$scene = Scene_Menu.new
end
end
if @selec.index == -1
@selec.index = 0
end
@selec.refresh
end
end
#===================================
# Add-on at Window_Base
#===================================
class Window_Base < Window
def normal_color
return $normal_c
end
def disabled_color
return $disable_c
end
def system_color
return $system_c
end
def crisis_color
return $crisis_c
end
def knockout_color
return $die_c
end
end
To make this class functional, after “begin”
in main, put :
Code: $normal_c = Color.new(255, 255, 255, 255)
$disable_c = Color.new(255, 255, 255, 150)
$system_c = Color.new(200, 200, 255, 255)
$crisis_c = Color.new(255, 255, 120, 255)
$die_c = Color.new(255, 20, 0, 255)
For tell this class you have to put :
Code: $scene = Text_color.new
Enjoy !
|