#include "hsp3util.as" ; emes命令を使用するために必要です #define M_FONT_SIZE 25 ;問題文のフォントサイズ #define BACK_GROUND 10 ;背景用 #define KOKUBAN_MOJI 5 ;黒板に表示する問題文用 #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 ;正解・不正解の大きなフォントを表示している時間 *初期設定 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" 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 *○× } else { if keisiki != "○×" : goto *main } wait 0 redraw 1 repeat onclick gosub *左クリック if next_flag = 0 or hyouji_end_flag !=1 : gosub *問題文表示 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 *黒板描画 font "MS ゴシック" , 14 , 16 pos 0 , 2 color 0 , 0 , 0 textmode 2 color 255 , 255 , 255 emes "問題数:"+ notemax+ "問 " pos 120 , 2 emes "" + keisiki + " " + jyanru //額縁作成 color 128 , 128 , 128 boxf (ginfo_winx-410)/2 , 15 ,(640-410)/2+410 , 225 //グラデーションによる黒板表示 repeat 200 color 100-cnt/2,50-cnt/4,50-cnt/4 line (ginfo_winx-400)/2,200-cnt+20,(ginfo_winx-400)/2+400,200-cnt+20 loop 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' b = 0 hyouji_max_length = 0 gyousuu = 0 dim hyouji_length , 5 repeat getstr hyouji.cnt , hint , b , '/' b=b+strsize hyouji_length.cnt = strlen(hyouji.cnt) if hyouji_max_length31{ hyouji_max_length=30 gyousuu = (hint_size/30)+1 repeat gyousuu hyouji_length.cnt=30 hyouji.cnt = strmid(hint,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 hyouji_end_flag = 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 *背景描画 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 *左クリック stick key,256 ; 左クリックを監視する mx=mousex ; マウスのX座標 my=mousey ; マウスのY座標 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 *正解判定 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