赞 | 7 |
VIP | 866 |
好人卡 | 185 |
积分 | 32 |
经验 | 130059 |
最后登录 | 2024-11-27 |
在线时间 | 3618 小时 |
Lv3.寻梦者 双子人
- 梦石
- 0
- 星屑
- 3190
- 在线时间
- 3618 小时
- 注册时间
- 2009-4-4
- 帖子
- 4154
|
- module RPG
- class Question
- def initialize
- @name = "" #题目名称
- @choose = [] #选项
- @right = 0 #正确选项(0,1,2,3,更多)
- end
- attr_accessor :name
- attr_accessor :choose
- attr_accessor :right
- end
- end
- class Game_Question
- attr_reader :question
- def initialize
- @question = []
-
- @question[0] = RPG::Question.new
- @question[0].name = "一加一等于多少?"
- @question[0].choose[0] = "一"
- @question[0].choose[1] = "二"
- @question[0].choose[2] = "十一"
- @question[0].right = 1
-
- @question[1] = RPG::Question.new
- @question[1].name = "你是猪吗?"
- @question[1].choose[0] = "是"
- @question[1].choose[1] = "不是"
- @question[1].right = 0
-
- @question[2] = RPG::Question.new
- @question[2].name = "天上掉下一张脸,你要不要"
- @question[2].choose[0] = "要"
- @question[2].choose[1] = "不要"
- @question[2].choose[2] = "要一半"
- @question[2].right = 2
-
- @question[3] = RPG::Question.new
- @question[3].name = "下列侵犯生命健康权的是"
- @question[3].choose[0] = "杀人"
- @question[3].choose[1] = "抄袭"
- @question[3].right = 1
- end
- end
- class Scene_Question
- def main
- @question = nil
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果切换画面就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- p "你忘了设置答题结束的场合了"
- end
- def update
- if @question == nil
- @question = rand(Game_Question.new.question.size)
- @command_window = Window_Command.new(192, Game_Question.new.question[@question].choose)
- @command_window.back_opacity = 160
- @command_window.x = 320 - @command_window.width / 2
- @command_window.y = 288
- @window_name = Window_Question_Name.new(@question)
- Graphics.transition
- end
- @command_window.update
- @window_name.update
- if Input.trigger?(Input::C)
- if @command_window.index == Game_Question.new.question[@question].right
- p "你忘了设置正确的场合了"
- else
- p "你忘了设置错误的场合了"
- end
- @question = nil
- @command_window.dispose
- @window_name.dispose
- return
- end
- if Input.trigger?(Input::B)
- $scene = Scene_Map.new
- return
- end
- end
- end
- class Window_Question_Name < Window_Base
- def initialize(id)
- super(0,0,640,480)
- @name = Game_Question.new.question[id].name
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- end
- def refresh
- self.contents.clear
- self.contents.font.color = normal_color
- self.contents.draw_text(0,0,640,32,@name,1)
- end
- end
复制代码 ……
|
|