〜 グラフィック 〜
画像フォントを使用

コチラに数値だけを画像にするやり方を紹介しましたが、
今回はいろいろな文字も画像で表示するやり方を紹介します。
ゲーム・ツールにおいて、通常は入っていないフォントでテキストを見てもらうことが醍醐味であるが、
そのフォントをインストールしてない利用者のパソコンだと標準フォントが使用されてしまい、
自分の伝えたいことが半減してしまう…と言った場合にオススメでしょう(いるのか?
尚、ココでは表示できる半角文字コードのみ(コチラの画像フォントを使用)を使用しています。
平仮名やカタカナ、漢字なども使いたい場合は、下記を参考に独自に拡張してみては?
	

gmesinit フォント画像, 作業バッファ, 横幅, 高さ, 間隔
フォント画像英数字が入った画像ファイルを指定する。
作業バッファフォントの読込先作業バッファIDを指定する。
横幅フォント画像一文字分の横幅を指定する。
高さフォント画像一文字分の高さを指定する。
間隔テキストを表示する時の文字間隔を指定する。

gmes テキスト
テキスト予め読み込んだフォントを使用して指定テキストを表示する。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#module
#deffunc gmesinit str, int, int, int, int
	mref file, 32 : mref id, 1 : mref x, 2 : mref y, 3 : mref sp, 4
	mref bmscr, 67
	gid = id : sx = x : sy = y : space = sp
	buffer gid
	picload file
	gsel bmscr.18 // アクティブウィンドウを戻す
	gmode 2, sx, sy
	return

#deffunc gmes str
	mref string, 32
	s = string
	cx = csrx : cx.1 = cx : cy = csry
	strlen len, s
	repeat len
		peek code, s, cnt
		// 改行処理
		if code = 13 {
			peek code, s, cnt + 1
			cx = cx.1 : cy += sy
			continue cnt + (code = 10) + 1
		}
		pos cx, cy : gcopy gid, (code - 33) * sx
	cx += sx + space
	loop
	return
#global

	gmesinit "gfont.bmp", 1, 10, 20, 2
	redraw 0
	pos 20, 20 : gmes "This is a Graphical-Font show.\nCan you read this Message!?"
	pos 20, 80 : gmes "I'm sorry that only the alphabet can be used..."
	redraw 1
	stop

gmesinit フォント画像, 作業バッファ, 横幅, 高さ, 間隔
フォント画像英数字が入った画像ファイルを指定する。
作業バッファフォントの読込先作業バッファIDを指定する。
横幅フォント画像一文字分の横幅を指定する。
高さフォント画像一文字分の高さを指定する。
間隔テキストを表示する時の文字間隔を指定する。

gmes テキスト
テキスト予め読み込んだフォントを使用して指定テキストを表示する。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#module
#deffunc gmesinit str file, int id, int x, int y, int sp, local bmscr
	mref bmscr, 67
	gid = id : sx = x : sy = y : space = sp
	buffer gid
	picload file
	gsel bmscr.18 // アクティブウィンドウを戻す
	gmode 2, sx, sy
	return

#deffunc gmes str string, local code, local cx, local cy
	s = string
	cx = ginfo_cx : cx.1 = cx : cy = ginfo_cy
	repeat strlen(s)
		code = peek(s, cnt)
		// 改行処理
		if code = 13 {
			code = peek(s, cnt + 1)
			cx = cx.1 : cy += sy
			continue cnt + (code = 10) + 1
		}
		pos cx, cy : gcopy gid, (code - 33) * sx
	cx += sx + space
	loop
	return
#global

	gmesinit "gfont.bmp", 1, 10, 20, 2
	redraw 0
	pos 20, 20 : gmes "This is a Graphical-Font show.\nCan you read this Message!?"
	pos 20, 80 : gmes "I'm sorry that only the alphabet can be used..."
	redraw 1