Untitled

 avatar
unknown
plain_text
3 months ago
1.8 kB
8
Indexable
/*
		数当てゲーム。
*/

#module

#defcfunc basecolour
	return 0xf0f0f0

; 色々と環境依存で不完全なスクロール。
#deffunc scroll
	; 画面サイズ。
	sizex = ginfo_sx
	sizey = ginfo_sy
	; 現在座標。
	currentx = ginfo_cx
	currenty = ginfo_cy
	if ( currenty < (sizey-16)) : return	; 画面下限に至らなかったら処理しないで戻る。

	gmode 0
	pos 0,0
	gcopy 0 ,0,16,sizex,sizey-16 
	rgbcolor 0xffffff
	boxf 0,sizey-16,sizex-1,sizey-1
	pos 0,sizey-16
	rgbcolor 0
	return

#deffunc prn str string
	mes string
	scroll
	return

#global

	screen 0 ,640,480
*start
	num=1000
	target=rnd(num)
	prn "0から"+str(num-1)+"の範囲の数字を当ててください。"

	repeat
		ans=""
		input ans,64,16 ,8
		objnum = stat
		objsel objnum	; inputオブジェクトにフォーカス。
		do	; 変数に何か入力されるまで待ち。
			await 10
			stick inkeyS,0,1
			if (inkeyS==32) : _break		; enterキーのみ反応。
		until 0
		clrobj objnum	; 入力が済んだと仮定して、inputオブジェクトを削除。
		ans = int(ans)
		pos 0,ginfo_cy-16 : prn str(ans)	; オブジェクトのあったその場所に入力内容を表記。
		wait 100
		if (target < ans) : prn "もっと小さい。"
		if (ans < target) : prn "もっと大きい。"
		if (ans == target) {
			prn "正解!!"
			prn "\n"
			prn "もう一回やりたければ[スペースキー]を、終了したければ[エスケープキー]を押してください。"
			break
		}
	loop

	repeat
		await 64
		stick inkeyS,0,1
		if (inkeyS==16) : goto *start		; spcキーのみ反応。
		if (inkeyS==128) : break		; ESCキーのみ反応。
	loop
	end

Editor is loading...
Leave a Comment