Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! ruby -Ku
- #これを実行でゲームスタート
- #起動用に、全クラスを読み込みます。
- #全般
- require "kconv"
- require "dxruby"
- require_relative "ayame"
- require_relative "page"
- require_relative "class"
- ##初期グローバル変数の定義
- $sample_param = [100,100,100,1]
- #モジュールで定義
- module Main
- class Main_page < Page::Base
- def init
- #まず全曲がストップされる。
- $g_sound.silent
- #変数
- @time = 0
- @days = $sample_param[3] #デフォルトでは日付=当日条件番号になる。
- @pages = 0
- @font = Font.new(16,"メイリオ")
- #クラス定義
- @c_novel = Class_novel.new
- #条件定義
- days= @days
- @days = @c_novel.ifs(days) #初回条件参照。nilの場合-1を返す
- ##イベントがない場合の反応
- @Next_page = Exit_page if @days == -1
- end
- #runは使わない!
- def run
- end
- #たったの3行!renderも短い!!
- def render
- @c_novel.draw
- @c_novel.effects
- @c_novel.sentence
- Window.draw_font(5,462, "停止中",@font) if Input.keyDown?(K_SPACE)
- end
- #実行順番は遵守しなければならない
- def update
- days = @days
- @days , need = @c_novel.result(days)
- ##パラムによる強制イベント条件は100以上で行うこと。
- if @days == -1 #ホームに戻ろうとして・・・
- #100~はイベント後常時起こるゲームオーバーイベントを設定したい時。
- if $sample_param[0] <= 0
- @days = 100
- days = @days
- @c_novel.ifs(days)
- elsif $sample_param[1] <= 0
- @days = 101
- days = @days
- @c_novel.ifs(days)
- elsif $sample_param[2] <= 0
- @days = 102
- days = @days
- @c_novel.ifs(days)
- end
- end
- ##次ページ移動
- if @days == -1
- $sample_param[3] += 1
- @Next_page = Main_page if @days == -1
- end
- @Next_page = Death_end_page if @days == -2 #そのイベントで死亡なら設定。
- #この後のクラス召喚イベントはホームや死亡ページに行くなら行わない。unless @days < 0を入れる。
- #時間操作は1行
- @c_novel.time unless @days < 0
- #再定義
- pages = @pages
- check = [pages,false]
- check = @c_novel.mind(pages) unless @days < 0
- @c_novel.reinit if check[1] == true
- @pages = check[0]
- end
- #定番
- def exit
- if Input.keyPush?(K_ESCAPE) #ESCキー
- @Next_page = Exit_page
- end
- end
- end
- #死亡エンド画面
- class Death_end_page < Page::Base
- def init
- $g_sound.silent
- $g_sound.music_play(2)
- @why_death = ""
- @font = Font.new(16,"メイリオ")
- end
- def run
- if $sample_param[0] <= 0
- @why_death = "過労死"
- elsif $sample_param[1] <= 0
- @why_death = "斬殺"
- elsif $sample_param[2] <= 0
- @why_death = "心臓麻痺"
- end
- end
- def render
- Window.draw_font(100,100, @why_death ,@font,hash={color: [255,66,66]})
- Window.draw_font(100,340, "やりなおし" ,@font,hash={color: [255,66,66]})
- end
- def update
- if Input.mousePush?(M_LBUTTON)
- @Next_page = Main_page
- end
- end
- def exit
- end
- end
- #強制終了時画面。
- class Exit_page < Page::Base
- def init
- @font = Font.new(16,"メイリオ")
- end
- def run
- end
- def render
- Window.draw_font(180,300, "終了しました。" ,@font,hash={color: [255,66,66]})
- Window.draw_font(100,340, "ウィンドウを閉じるにはクリックします。。" ,@font,hash={color: [255,66,66]})
- end
- def update
- if Input.mousePush?(M_LBUTTON)
- $end = true
- end
- end
- def exit
- end
- end
- #さあ、実行!!
- Page.main_loop Main_page, 60, 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement