Advertisement
Guest User

mireiyu_novel_main.rb_A

a guest
Dec 23rd, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.67 KB | None | 0 0
  1. #! ruby -Ku
  2.  
  3. #これを実行でゲームスタート
  4. #起動用に、全クラスを読み込みます。
  5.  
  6. #全般
  7. require "kconv"
  8. require "dxruby"
  9. require_relative "ayame"
  10. require_relative "page"
  11. require_relative "class"
  12.  
  13. ##初期グローバル変数の定義
  14. $sample_param = [100,100,100,1]
  15.  
  16. #モジュールで定義
  17. module Main
  18.  
  19.  class Main_page < Page::Base
  20.   def init
  21.  
  22. #まず全曲がストップされる。
  23.    $g_sound.silent
  24.  
  25. #変数
  26.    @time = 0
  27.    @days = $sample_param[3] #デフォルトでは日付=当日条件番号になる。
  28.    @pages = 0
  29.    @font = Font.new(16,"メイリオ")
  30.  
  31. #クラス定義
  32.    @c_novel = Class_novel.new
  33.  
  34. #条件定義
  35.    days= @days
  36.    @days = @c_novel.ifs(days) #初回条件参照。nilの場合-1を返す
  37.  
  38. ##イベントがない場合の反応
  39.    @Next_page = Exit_page if @days == -1
  40.  
  41.   end
  42.  
  43. #runは使わない!
  44.   def run
  45.   end
  46.  
  47. #たったの3行!renderも短い!!
  48.   def render
  49.    @c_novel.draw
  50.    @c_novel.effects
  51.    @c_novel.sentence
  52.  
  53.    Window.draw_font(5,462, "停止中",@font) if Input.keyDown?(K_SPACE)
  54.   end
  55.  
  56. #実行順番は遵守しなければならない
  57.   def update
  58.  
  59.    days = @days
  60.    @days , need = @c_novel.result(days)
  61.  
  62. ##パラムによる強制イベント条件は100以上で行うこと。
  63.    if @days == -1 #ホームに戻ろうとして・・・
  64. #100~はイベント後常時起こるゲームオーバーイベントを設定したい時。
  65.     if $sample_param[0] <= 0
  66.      @days = 100
  67.      days = @days
  68.      @c_novel.ifs(days)
  69.      elsif $sample_param[1] <= 0
  70.      @days = 101
  71.      days = @days
  72.      @c_novel.ifs(days)
  73.      elsif $sample_param[2] <= 0
  74.      @days = 102
  75.      days = @days
  76.      @c_novel.ifs(days)
  77.     end
  78.    end
  79.  
  80. ##次ページ移動
  81.    if @days == -1
  82.     $sample_param[3] += 1
  83.     @Next_page = Main_page if @days == -1
  84.    end
  85.    @Next_page = Death_end_page if @days == -2 #そのイベントで死亡なら設定。
  86.  
  87. #この後のクラス召喚イベントはホームや死亡ページに行くなら行わない。unless @days < 0を入れる。
  88.  
  89. #時間操作は1行
  90.    @c_novel.time unless @days < 0
  91.  
  92. #再定義
  93.    pages = @pages
  94.    check = [pages,false]
  95.    check = @c_novel.mind(pages) unless @days < 0
  96.    @c_novel.reinit if check[1] == true
  97.    @pages = check[0]
  98.   end
  99.  
  100. #定番
  101.   def exit
  102.    if Input.keyPush?(K_ESCAPE) #ESCキー
  103.     @Next_page = Exit_page
  104.    end
  105.   end
  106.  end
  107.  
  108. #死亡エンド画面
  109.  class Death_end_page < Page::Base
  110.  
  111.   def init
  112.    $g_sound.silent
  113.    $g_sound.music_play(2)
  114.    @why_death = ""
  115.    @font = Font.new(16,"メイリオ")
  116.   end
  117.  
  118.   def run
  119.    if $sample_param[0] <= 0
  120.     @why_death = "過労死"
  121.     elsif $sample_param[1] <= 0
  122.     @why_death = "斬殺"
  123.     elsif $sample_param[2] <= 0
  124.     @why_death = "心臓麻痺"
  125.    end
  126.   end
  127.  
  128.   def render
  129.    Window.draw_font(100,100, @why_death ,@font,hash={color: [255,66,66]})
  130.    Window.draw_font(100,340, "やりなおし" ,@font,hash={color: [255,66,66]})
  131.   end
  132.  
  133.   def update
  134.    if Input.mousePush?(M_LBUTTON)
  135.     @Next_page = Main_page
  136.    end
  137.   end
  138.  
  139.   def exit
  140.   end
  141.  
  142.  end
  143.  
  144. #強制終了時画面。
  145.  
  146.  class Exit_page < Page::Base
  147.  
  148.   def init
  149.   @font = Font.new(16,"メイリオ")
  150.   end
  151.  
  152.   def run
  153.   end
  154.  
  155.   def render
  156.    Window.draw_font(180,300, "終了しました。" ,@font,hash={color: [255,66,66]})
  157.    Window.draw_font(100,340, "ウィンドウを閉じるにはクリックします。。" ,@font,hash={color: [255,66,66]})
  158.   end
  159.  
  160.   def update
  161.    if Input.mousePush?(M_LBUTTON)
  162.     $end = true
  163.    end
  164.   end
  165.  
  166.   def exit
  167.   end
  168.  end
  169.  
  170. #さあ、実行!!
  171.  Page.main_loop Main_page, 60, 1
  172. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement