#include "hsp3util.as" ; emes命令を使用するために必要です #define M_FONT_SIZE 25 ;問題文のフォントサイズ #define S_FONT_SIZE 22 ;選択肢のフォントサイズ #define S_FONT_SIZE_HOSEI 8 ;選択肢に表示されるフォントのY座標補正値 #define BACK_GROUND 10 ;背景用 #define KOKUBAN_MOJI 5 ;黒板に表示する問題文用 #define KOKUBAN 6 ;黒板用 #define GAKUBUTI 7 ;額縁用 #define ID_BUTTON 2 ;○×やタイピングボタンの描画用 #define MARUBATU_SIZE 180 ;○×ボタンのサイズ XもYも180 #define MARU_X_POS 130 ;○ボタンのX座標 #define BATU_X_POS 330 ;×ボタンのX座標 #define MARUBATU_Y_POS 255 ;○×ボタンのY座標 #define GYOU_KANKAKU 28 ;問題文の行の間隔 #define SEIGO_HYOUJI_TIME 120 ;正解・不正解の大きなフォントを表示している時間 #define YONTAKU_X_SIZE 400 ;四択ボタンのXサイズ #define YONTAKU_Y_SIZE 55 ;四択ボタンのYサイズ #define YONTAKU_Y_POS 240 ;四択ボタンのY座標 *初期設定 screen 0 ,640 ,480 ,0 title "クイズマジックアカデミー" cls notesel mondai_file noteload "問題.txt" sdim mondai , notemax repeat notemax noteget mondai.cnt , cnt loop randomize buffer BACK_GROUND , 640 , 480 picload "./image/classroom.jpg" buffer KOKUBAN , 400 , 200 picload "./image/kokuban.bmp" buffer GAKUBUTI, 400 , 200 picload "./image/gakubuti.bmp" kotae = "" your_choice = "" push_sign = 0 next_flag = 0 next_count = 1 *main title "クイズマジックアカデミー " + next_count + "問目" wait 0 redraw 0 gosub *問題読み込み gosub *問題文を仮想画面に描く gosub *背景描画 gosub *黒板描画 if keisiki = "○×" : gosub *○× if keisiki = "四択" : gosub *四択連想 wait 0 redraw 1 repeat onclick gosub *左クリック if bunki_end_flag = 0 & (next_flag = 0 or hyouji_end_flag = 0) : gosub *問題文表示 if bunki_end_flag = 0 & (next_flag = 0 or hyouji_end_flag = 1 & bunki_mode = 1) : gosub *分岐表示 wait 0 if next_flag = 1 : wait SEIGO_HYOUJI_TIME : break loop next_flag = 0 next_count++ push_sign = 0 hyouji_max_length=0 goto *main stop *黒板描画 //黒板の描画 gsel 0 gmode 4 , , , 200 pos (ginfo_winx-400)/2 , 20 color 0 , 255 , 0 ;黄緑色抜き gcopy KOKUBAN , 0 , 0 , 400 , 200 //額縁の描画 gmode 4 , , , 255 pos (ginfo_winx-440)/2 , 0 color 0 , 255 , 0 ;黄緑色抜き gcopy GAKUBUTI , 0 , 0 , 440 , 240 font "MS ゴシック" , 16 , 16 pos 0 , 7 color 0 , 0 , 0 textmode 2 color 255 , 255 , 255 emes "問題数:"+ notemax+ "問" font "MS ゴシック" , 12 , 16 color 0 , 0 , 0 textmode 2 color 255 , 255 , 255 pos 128 , 10 emes "" + keisiki pos 210 , 10 emes "" + jyanru return *問題読み込み a = 0 mondai_tmp = mondai.rnd(notemax) getstr keisiki , mondai_tmp , a , '\t' : a=a+strsize getstr jyanru , mondai_tmp , a , '\t' : a=a+strsize getstr hint , mondai_tmp , a , '\t' : a=a+strsize hint_size = strsize ;重要 getstr kotae , mondai_tmp , a , '\t' hyouji_end_flag = 0 //分岐無し・分岐前が全て表示しきったら1にする bunki_end_flag = 0 //分岐後の表示が終わったら1にする bunki_mode = 0 //分岐モードのフラグ n = 0 //strsize の代入用 //問題文の区切りで分岐後を切り出す getstr bunkimae , hint , n , ',' bunkimae_size = strlen(bunkimae) + 1 n = n + strsize getstr bunkigo , hint , n , '\t' bunki_size = strlen(bunkigo) if bunkimae_size != hint_size : bunki_mode=1 b = 0 hyouji_max_length = 0 gyousuu = 0 dim hyouji_length , 5 //分岐無し・分岐前の文字処理 repeat getstr hyouji.cnt , bunkimae , b , '/' b=b+strsize hyouji_length.cnt = strlen(hyouji.cnt) if hyouji_max_length31{ hyouji_max_length=30 gyousuu = (bunkimae_size/30)+1 repeat gyousuu hyouji_length.cnt=30 hyouji.cnt = strmid(bunkimae,cnt*30,30) loop } return *問題文を仮想画面に描く buffer KOKUBAN_MOJI,400,150 ;400×150の仮想画面5を用意 color 0,0,0 boxf 0,0,400,150 ;黒色で塗りつぶす font "MS ゴシック" , M_FONT_SIZE , 16 textmode 0 ;縁取り無し color 255,255,255 ;フォントの色 //仮想画面に問題文を書き出す dim hyouji_x_pos , 5 ;4行分の位置を確保 gyousuu_count = 0 repeat gyousuu pos 0 , cnt * GYOU_KANKAKU emes hyouji.cnt hyouji_x_pos.cnt = 0 ;黒板に表示する文字の終端側の位置設定 loop return *問題文表示 //仮想画面5の問題文をメイン画面に描く gsel 0 ;メイン画面(screen 0)に描きますよ〜 gmode 4 , , , 255 color 0 , 0 , 0 ; 色抜き repeat if next_flag = 1 : break pos (ginfo_winx - (hyouji_max_length*M_FONT_SIZE/2))/2-4 , gyousuu_count * GYOU_KANKAKU + 40 gcopy KOKUBAN_MOJI , 0 , gyousuu_count*GYOU_KANKAKU , hyouji_x_pos.gyousuu_count , GYOU_KANKAKU hyouji_x_pos.gyousuu_count = hyouji_x_pos.gyousuu_count + 4 ;ここで問題文のなめらか調整(これは4ドット単位のなめらか表示) if hyouji_x_pos.gyousuu_count > (hyouji_length.gyousuu_count)*M_FONT_SIZE/2 + 20 { gyousuu_count = gyousuu_count + 1 if gyousuu_count>gyousuu : gyousuu_count = 0 : hyouji_end_flag = 1 : break } wait 1 ;0 にすると問題文は一気に表示されます loop return *分岐表示 wait 100 //問題文を上にスクロールさせる for i,0,140,5 redraw 0 gsel 0 gmode 4,,,255; pos (ginfo_winx-400)/2 , 20 color 0,255,0 ; 色抜き gcopy BACK_GROUND , (ginfo_winx-400)/2 , 20 , 400 , 140 gmode 4,,,200 gcopy KOKUBAN , 0 , 0 , 400 , 140 gmode 4,,,255 pos (ginfo_winx-440)/2 , 0 gcopy GAKUBUTI , 0 , 0 , 440 ,240 font "MS ゴシック" , 12 , 16 color 0 , 0 , 0 textmode 2 color 255 , 255 , 255 pos 128 , 10 emes "" + keisiki pos 210 , 10 emes "" + jyanru gmode 4,,,255 pos (ginfo_winx - (hyouji_max_length*M_FONT_SIZE/2))/2-4 , 40 color 0,0,0 ; 色抜き gcopy KOKUBAN_MOJI , 0 , i , 400 , 140 wait 2 redraw 1 next b=0 repeat getstr hyouji.cnt , bunkigo , b , '/' b=b+strsize hyouji_length.cnt = strlen(hyouji.cnt) if hyouji_max_length31{ hyouji_length=30 hyouji_max_length=30 gyousuu=(bunki_size/30)+1 color 0,0,0 boxf 0,0,400,150 repeat gyousuu hyouji.cnt = strmid(bunkigo , cnt*30 , 30) color 255,255,255 pos 0,cnt*GYOU_KANKAKU emes hyouji.cnt loop } gosub *問題文を仮想画面に描く gosub *問題文表示 bunki_end_flag = 1 return *背景描画 gsel 0 gmode 4,,,255 pos 0,0 gcopy BACK_GROUND , 0 , 0 , 640 , 480 return *○× buffer ID_BUTTON , 360 , 360 picload "./image/marubatu.bmp" gsel 0 gmode 4 , , , 255 color 0 , 255 , 0 pos MARU_X_POS , MARUBATU_Y_POS gcopy ID_BUTTON , 0 , 0 , MARUBATU_SIZE , MARUBATU_SIZE pos BATU_X_POS , MARUBATU_Y_POS gcopy ID_BUTTON , MARUBATU_SIZE , 0 , MARUBATU_SIZE , MARUBATU_SIZE return *四択連想 sdim sentakusi ,4 , 40 ;選択肢は4つ。全角で20文字まで。 sdim sentakusi_buf , 4 ,40 sentakusi_tmp = "" uso_sentakusi_kazu = 0 ;嘘の選択肢のカウント用(初期値 0) repeat getstr sentakusi.cnt , mondai_tmp , a , '\t' sentakusi_buf.cnt = sentakusi.cnt if strsize = 0 : break a = a + strsize uso_sentakusi_kazu = uso_sentakusi_kazu + 1 ;嘘の選択肢のカウントを1つ増やす loop kotae = sentakusi.0 ;答えは一番最初の選択肢 buffer ID_BUTTON , YONTAKU_X_SIZE , YONTAKU_Y_SIZE*8 picload "./image/4taku_button.bmp" //選択肢の文字を描画 font "MS ゴシック" , S_FONT_SIZE ,16 color 128,128,128 textmode 2 color 0 , 0 , 0 repeat 4 pos 40 , cnt*YONTAKU_Y_SIZE + S_FONT_SIZE_HOSEI emes "" + sentakusi.cnt pos 40 , cnt*YONTAKU_Y_SIZE + YONTAKU_Y_SIZE*4 + 7 + S_FONT_SIZE_HOSEI emes "" + sentakusi.cnt loop gsel 0 gmode 4 , , , 255 color 0 , 255 , 0 pos (ginfo_winx - YONTAKU_X_SIZE)/2 , YONTAKU_Y_POS gcopy ID_BUTTON , 0 , 0 , YONTAKU_X_SIZE , YONTAKU_Y_SIZE*4 return *左クリック stick key,256 ; 左クリックを監視する mx=mousex ; マウスのX座標 my=mousey ; マウスのY座標 if keisiki = "○×" : gosub *○×クリック if keisiki = "四択" : gosub *四択連想クリック return *○×クリック if key&256{ if (push_sign=0)&(mx>MARU_X_POS)&(mx<(MARU_X_POS+MARUBATU_SIZE))&(my>255)&(my<(255+MARUBATU_SIZE)){ your_choice = "○" push_x_pos = 0 push_x_pos_2 = MARU_X_POS gosub *○×選択処理 } if key&256{ if (push_sign=0)&(mx>BATU_X_POS)&(mx<(BATU_X_POS+MARUBATU_SIZE))&(my>255)&(my<(255+MARUBATU_SIZE)){ your_choice = "×" push_x_pos = 180 push_x_pos_2 = BATU_X_POS gosub *○×選択処理 } } //○×以外の位置をクリックしたら、なにもせずに戻る。 return *○×選択処理 push_sign = 1 gsel 0 gmode 4 , , , 255 color 0,255,0 pos push_x_pos_2 , 255 gcopy BACK_GROUND , push_x_pos_2 , 255 , MARUBATU_SIZE , MARUBATU_SIZE pos push_x_pos_2 , 255 gcopy ID_BUTTON , push_x_pos , MARUBATU_SIZE , MARUBATU_SIZE , MARUBATU_SIZE gosub *正解判定 return *四択連想クリック YONTAKU_X_POS = (ginfo_winx-YONTAKU_X_SIZE)/2 repeat 4 if key&256{ if (push_sign=0)&(mx>YONTAKU_X_POS)&(mx<(YONTAKU_X_POS+YONTAKU_X_SIZE))&(my>YONTAKU_Y_POS+(YONTAKU_Y_SIZE*cnt))&(my<(YONTAKU_Y_POS+(YONTAKU_Y_SIZE*cnt)+YONTAKU_Y_SIZE)){ your_choice = sentakusi.cnt value=(cnt+1) gosub *四択連想選択処理 break } } loop return *四択連想選択処理 push_sign = 1 pos YONTAKU_X_POS , YONTAKU_Y_POS+(value-1)*YONTAKU_Y_SIZE gsel 0 gmode 4 , , , 255; color 0 , 255 , 0 ; 黄緑色抜き gcopy BACK_GROUND , YONTAKU_X_POS , YONTAKU_Y_POS+(value-1)*YONTAKU_Y_SIZE , YONTAKU_X_SIZE , YONTAKU_Y_SIZE ;まず選択されたボタンの下の部分の背景を描画 gcopy ID_BUTTON , 0 , (value - 1)*YONTAKU_Y_SIZE + YONTAKU_Y_SIZE*4 , 400 , YONTAKU_Y_SIZE ;押されたボタンを表示 gosub *正解判定 return *正解判定 font "MS ゴシック" , 120 , 16 if your_choice = "" : gosub *不正解 if kotae != your_choice : gosub *不正解 if kotae = your_choice : gosub *正解 kotae = "" your_choice = "" next_flag = 1 return *正解 pos 200,70 color 255 , 255 , 0 textmode 2 color 255 , 0 , 0 emes "正解" return *不正解 pos 140,70 color 255 , 255 , 255 textmode 2 color 0 , 0 , 255 emes "不正解" return