Advertisement
Guest User

mireiyu_novel_class.rb_1

a guest
Dec 22nd, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.38 KB | None | 0 0
  1. #####頻出動作を管理するクラスソースファイル#####
  2.  
  3. ##キャラ立ち絵描写用クラス##
  4. class Class_chara
  5.  def initialize
  6.   @body , @face= [],[]
  7.  
  8.   @body << @sample_body1 = Image.load('sample_pass/body_sample1.png')
  9.   @body << @sample_body2 = Image.load('sample_pass/body_sample2.png')
  10.   @body << @sample_body3 = Image.load('sample_pass/body_sample3.png')
  11.  
  12.   @face << @sample_face1 = Image.load('sample_pass/face_sample1.png')
  13.   @face << @sample_face2 = Image.load('sample_pass/face_sample2.png')
  14.   @face << @sample_face3 = Image.load('sample_pass/face_sample3.png')
  15.  end
  16.  
  17.  def draw(x,y,body,face,calp,centeredx,centeredy)
  18.   body = @body.length + body if body < 0
  19.   face = @face.length + face if face < 0
  20.   calp = 255 if alp > 255
  21.   calp = 0   if alp < 0
  22.   x += @body[body].width / 2 if centeredx == true
  23.   y += @body[body].width / 2 if centeredy == true
  24.  
  25.   Window.draw_ex(x,y,@face[body],:alpha=>calp)
  26.   Window.draw_ex(x,y,@face[face],:alpha=>calp)
  27.  end
  28. end
  29.  
  30. ##背景、オブジェクト画像描写用クラス##
  31. class Class_image
  32.  def initialize
  33.   @background ,  @object = [] , []
  34.  
  35.   @background << @sample_background1 = Image.load('sample_pass/background_sample1.png')
  36.   @background << @sample_background2 = Image.load('sample_pass/background_sample2.png')
  37.   @background << @sample_background3 = Image.load('sample_pass/background_sample3.png')
  38.  
  39.   @object << @sample_object = Image.load('sample_pass/object_sample1.png')
  40.   @object << @sample_object = Image.load('sample_pass/object_sample2.png')
  41.   @object << @sample_object = Image.load('sample_pass/object_sample3.png')
  42.  end
  43.  
  44.  def draw_background(background)
  45.   Window.draw_ex(0,0, @background[background])
  46.  end
  47.  
  48.  def draw_object(x,y,object,falp)
  49.   Window.draw_ex(x,y,@objects[object],:alpha=>falp)}
  50.  end
  51. end
  52.  
  53. ##文章、ボタン描写用クラス##
  54. class Class_sentence
  55.  def initialize
  56.  end
  57.  
  58.  def draw_sentence(x,y,sentence,font_size,font_type,effect,color_ary,edge_color_ary)
  59.   b_bold,b_itaric,b_edge = false,false,false
  60.  
  61.   b_bold   = true if effect.include("b")
  62.   b_itaric = true if effect.include("i")
  63.   b_edge   = true if effect.include("e")
  64.  
  65.   hashs = {color:color_ary,bold:b_bold,itaric:b_itaric,edge:b_edge,edge_color:edge_color_ary}
  66.  
  67.   Window.draw_font(x,y,sentence,Font.new(font_size,font_type),hash=hashs)
  68.  end
  69.  
  70.  def draw_button(x,y,sentence,font_size,font_type)
  71.   button_size = [x..x + font.getWidth(sentence) , y..y + font.size]
  72.  
  73.   if button_size[0].include?($xpoint) && button_size[1].include?($ypoint)
  74.    color_ary , pushed = [255,122,122] , true
  75.    else
  76.    color_ary , pushed = [0,0,0] , false
  77.   end
  78.  
  79.   hashs = {color: [255,255,255] ,edge: true , edge_color: color_ary}
  80.  
  81.   Window.draw_font_ex(x,y, sentence ,Font.new(font_size,font_type), hash=hashs)
  82.  
  83.   if pushed == true
  84.    return true
  85.    else
  86.    return false
  87.   end
  88.  end
  89. end
  90.  
  91. ##サウンド処理クラス##
  92. class Class_sound
  93.  
  94.  def initialize
  95.   @music , @sound = [] , []
  96.  
  97.   @music << @sample_music1 = Ayame.new('sample_pass/music_sample1.png')
  98.   @music << @sample_music2 = Ayame.new('sample_pass/music_sample2.png')
  99.   @music << @sample_music3 = Ayame.new('sample_pass/music_sample3.png')
  100.  
  101.   @sound << @sample_sound1 = Sound.new('sample_pass/sound_sample1.png')
  102.   @sound << @sample_sound2 = Sound.new('sample_pass/sound_sample2.png')
  103.   @sound << @sample_sound3 = Sound.new('sample_pass/sound_sample3.png')
  104.  end
  105.  
  106.  def music_play(music,vol)
  107.   music = @music.length + music if music < 0
  108.  
  109.   @music[music].play(0,0)
  110.   @music[music].set_volume(vol,0)
  111.  end
  112.  
  113.  def music_stop(music)
  114.   music = @music.length + music if music < 0
  115.  
  116.   @music[music].stop(0)
  117.  end
  118.  
  119.  def music_pause(music)
  120.   @music[music].pause
  121.  end
  122.  
  123.  def music_resume(music)
  124.   @music[music].resume
  125.  end
  126.  
  127.  def music_onoff(music,vol)
  128.  
  129.   music = @music.length + music if music < 0
  130.  
  131.   if @music[music].finished?
  132.    @music[music].play(0,0)
  133.    @music[music].set_volume(vol,0)
  134.    else
  135.    @music[music].stop(0)
  136.   end
  137.  end
  138.  
  139.  def music_change(newmusic,vol)
  140.   newmusic = @music.length + newmusic if newmusic < 0]
  141.  
  142.   t = @music.length
  143.   num.times do |t|
  144.  
  145.   unless t == newmusic
  146.    @music[t].stop(0)
  147.    else
  148.    @music[newmusic].play(0,0) if @music[newmusic].finished?
  149.    @music[newmusic].set_volume(vol,0)
  150.   end
  151.  end
  152.  
  153.  def silent
  154.   t = @music.length
  155.   num.times{|t| @music[t].stop(0)}
  156.  end
  157.  
  158.  def sound(sound)
  159.   @sound[sound].play
  160.  end
  161. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement