Masih tentang Quick Basic, yang bisa menjadi masukan untuk teman-teman SMA ataupun kuliah semester awal dan untuk mengasah kemampuan algoritma. Berikut ini adalah contoh rutin untuk meletakkan font ke posisi tertentu. Font didesain dengan program Sprite Editor dan bisa dimanfaatkan dalam program game. Karena font dalam bentuk sprite, maka untuk meletakkan atau menggambar font di layar, dibutuhkan perintah PUT. Langsung saja berikut programnya:

‘************************************

‘ Example ARIAL Font
‘ Designed by:
‘ Yulius Candra Wahyu Kurniawan
‘ Copyright (C) 1999

‘************************************

DECLARE SUB PutFont (col%, row%, text$)
DEFINT A-Z
SCREEN 13
CLS
CONST Path$ = “\DATA\SPRITE\”
‘koleksi angka
OPEN Path$ + “ar_0.shp” FOR INPUT AS #1
DIM SHARED f0(42): FOR i = 0 TO 42: INPUT #1, f0(i): NEXT: CLOSE #1
OPEN Path$ + “ar_1.shp” FOR INPUT AS #1
DIM SHARED f1(38): FOR i = 0 TO 38: INPUT #1, f1(i): NEXT: CLOSE #1
OPEN Path$ + “ar_2.shp” FOR INPUT AS #1
DIM SHARED f2(42): FOR i = 0 TO 42: INPUT #1, f2(i): NEXT: CLOSE #1
OPEN Path$ + “ar_3.shp” FOR INPUT AS #1
DIM SHARED f3(42): FOR i = 0 TO 42: INPUT #1, f3(i): NEXT: CLOSE #1
OPEN Path$ + “ar_4.shp” FOR INPUT AS #1
DIM SHARED f4(42): FOR i = 0 TO 42: INPUT #1, f4(i): NEXT: CLOSE #1
OPEN Path$ + “ar_5.shp” FOR INPUT AS #1
DIM SHARED f5(42): FOR i = 0 TO 42: INPUT #1, f5(i): NEXT: CLOSE #1
OPEN Path$ + “ar_6.shp” FOR INPUT AS #1
DIM SHARED f6(42): FOR i = 0 TO 42: INPUT #1, f6(i): NEXT: CLOSE #1
OPEN Path$ + “ar_7.shp” FOR INPUT AS #1
DIM SHARED f7(42): FOR i = 0 TO 42: INPUT #1, f7(i): NEXT: CLOSE #1
OPEN Path$ + “ar_8.shp” FOR INPUT AS #1
DIM SHARED f8(42): FOR i = 0 TO 42: INPUT #1, f8(i): NEXT: CLOSE #1
OPEN Path$ + “ar_9.shp” FOR INPUT AS #1
DIM SHARED f9(42): FOR i = 0 TO 42: INPUT #1, f9(i): NEXT: CLOSE #1
‘koleksi huruf
OPEN Path$ + “ar_a.shp” FOR INPUT AS #1
DIM SHARED ba(42): FOR i = 0 TO 42: INPUT #1, ba(i): NEXT: CLOSE #1
OPEN Path$ + “ar_b.shp” FOR INPUT AS #1
DIM SHARED bb(42): FOR i = 0 TO 42: INPUT #1, bb(i): NEXT: CLOSE #1
OPEN Path$ + “ar_c.shp” FOR INPUT AS #1
DIM SHARED bc(42): FOR i = 0 TO 42: INPUT #1, bc(i): NEXT: CLOSE #1
OPEN Path$ + “ar_d.shp” FOR INPUT AS #1
DIM SHARED bd(42): FOR i = 0 TO 42: INPUT #1, bd(i): NEXT: CLOSE #1
OPEN Path$ + “ar_e.shp” FOR INPUT AS #1
DIM SHARED be(42): FOR i = 0 TO 42: INPUT #1, be(i): NEXT: CLOSE #1
OPEN Path$ + “ar_f.shp” FOR INPUT AS #1
DIM SHARED bf(42): FOR i = 0 TO 42: INPUT #1, bf(i): NEXT: CLOSE #1
OPEN Path$ + “ar_g.shp” FOR INPUT AS #1
DIM SHARED bg(42): FOR i = 0 TO 42: INPUT #1, bg(i): NEXT: CLOSE #1
OPEN Path$ + “ar_h.shp” FOR INPUT AS #1
DIM SHARED bh(42): FOR i = 0 TO 42: INPUT #1, bh(i): NEXT: CLOSE #1
OPEN Path$ + “ar_i.shp” FOR INPUT AS #1
DIM SHARED bi(38): FOR i = 0 TO 38: INPUT #1, bi(i): NEXT: CLOSE #1
OPEN Path$ + “ar_j.shp” FOR INPUT AS #1
DIM SHARED bj(42): FOR i = 0 TO 42: INPUT #1, bj(i): NEXT: CLOSE #1
OPEN Path$ + “ar_k.shp” FOR INPUT AS #1
DIM SHARED bk(42): FOR i = 0 TO 42: INPUT #1, bk(i): NEXT: CLOSE #1
OPEN Path$ + “ar_l.shp” FOR INPUT AS #1
DIM SHARED bl(38): FOR i = 0 TO 38: INPUT #1, bl(i): NEXT: CLOSE #1
OPEN Path$ + “ar_m.shp” FOR INPUT AS #1
DIM SHARED bm(42): FOR i = 0 TO 42: INPUT #1, bm(i): NEXT: CLOSE #1
OPEN Path$ + “ar_n.shp” FOR INPUT AS #1
DIM SHARED bn(42): FOR i = 0 TO 42: INPUT #1, bn(i): NEXT: CLOSE #1
OPEN Path$ + “ar_o.shp” FOR INPUT AS #1
DIM SHARED bo(42): FOR i = 0 TO 42: INPUT #1, bo(i): NEXT: CLOSE #1
OPEN Path$ + “ar_p.shp” FOR INPUT AS #1
DIM SHARED bp(42): FOR i = 0 TO 42: INPUT #1, bp(i): NEXT: CLOSE #1
OPEN Path$ + “ar_q.shp” FOR INPUT AS #1
DIM SHARED bq(42): FOR i = 0 TO 42: INPUT #1, bq(i): NEXT: CLOSE #1
OPEN Path$ + “ar_r.shp” FOR INPUT AS #1
DIM SHARED br(42): FOR i = 0 TO 42: INPUT #1, br(i): NEXT: CLOSE #1
OPEN Path$ + “ar_s.shp” FOR INPUT AS #1
DIM SHARED bs(42): FOR i = 0 TO 42: INPUT #1, bs(i): NEXT: CLOSE #1
OPEN Path$ + “ar_t.shp” FOR INPUT AS #1
DIM SHARED bt(38): FOR i = 0 TO 38: INPUT #1, bt(i): NEXT: CLOSE #1
OPEN Path$ + “ar_u.shp” FOR INPUT AS #1
DIM SHARED bu(42): FOR i = 0 TO 42: INPUT #1, bu(i): NEXT: CLOSE #1
OPEN Path$ + “ar_v.shp” FOR INPUT AS #1
DIM SHARED bv(42): FOR i = 0 TO 42: INPUT #1, bv(i): NEXT: CLOSE #1
OPEN Path$ + “ar_w.shp” FOR INPUT AS #1
DIM SHARED bw(42): FOR i = 0 TO 42: INPUT #1, bw(i): NEXT: CLOSE #1
OPEN Path$ + “ar_x.shp” FOR INPUT AS #1
DIM SHARED bx(42): FOR i = 0 TO 42: INPUT #1, bx(i): NEXT: CLOSE #1
OPEN Path$ + “ar_y.shp” FOR INPUT AS #1
DIM SHARED by(38): FOR i = 0 TO 38: INPUT #1, by(i): NEXT: CLOSE #1
OPEN Path$ + “ar_z.shp” FOR INPUT AS #1
DIM SHARED bz(42): FOR i = 0 TO 42: INPUT #1, bz(i): NEXT: CLOSE #1

‘koleksi tanda baca
OPEN Path$ + “ar_ttk.shp” FOR INPUT AS #1
DIM SHARED titik(20): FOR i = 0 TO 20: INPUT #1, titik(i): NEXT: CLOSE #1
OPEN Path$ + “ar_seru.shp” FOR INPUT AS #1
DIM SHARED seru(20): FOR i = 0 TO 20: INPUT #1, seru(i): NEXT: CLOSE #1

PutFont 10, 50, “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
PutFont 10, 100, “GOT RUBY RING VALUE 15000 RUPIAH.”
a$ = INPUT$(1)

SCREEN 0
WIDTH 80
CLS
END

SUB PutFont (col, row, text$)
spasi = 0
GOSUB cetak
EXIT SUB

cetak:
FOR xx = 1 TO LEN(text$)
num = ASC(MID$(text$, xx, 1))
IF num > 47 AND num < 58 THEN ON num - 47 GOSUB 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 END IF IF num > 64 AND num < 91 THEN ON num - 64 GOSUB ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx, by, bz END IF IF num = 33 THEN GOSUB seru IF num = 46 THEN GOSUB titik 'IF num = 58 THEN GOSUB ttkdua 'IF num = 59 THEN GOSUB ttkoma 'IF num = 63 THEN GOSUB tanya 'dimension 3 x 8, 7 x 8, 8 x 8 SELECT CASE num 'CASE 33, 34, 39, 40, 41, 44, 46, 58, 59, 105, 106, 108 'col = col + 4 'CASE 49, 116, 122 'col = col + 5 'CASE 56, 67, 73, 74, 98, 99, 101, 102, 104, 111, 115 'col = col + 6 'CASE 48, 50, 51, 52, 53, 54, 55, 57, 63, 76, 83, 97, 100, 103, 107, 112, 113, 114, 118, 121 'col = col + 7 'CASE 66, 70, 79, 80, 71, 110, 117, 120, 84, 85, 86, 89, 90 'col = col + 8 'CASE 65, 68, 69, 72, 75, 78, 81, 82, 88 'col = col + 9 'CASE 119 'col = col + 10 CASE 32, 33, 46 col = col + 3 + spasi CASE 49, 73, 76, 84, 89 col = col + 7 + spasi CASE ELSE col = col + 8 + spasi END SELECT NEXT RETURN 0 : PUT (col, row), f0: RETURN 1 : PUT (col, row), f1: RETURN 2 : PUT (col, row), f2: RETURN 3 : PUT (col, row), f3: RETURN 4 : PUT (col, row), f4: RETURN 5 : PUT (col, row), f5: RETURN 6 : PUT (col, row), f6: RETURN 7 : PUT (col, row), f7: RETURN 8 : PUT (col, row), f8: RETURN 9 : PUT (col, row), f9: RETURN ba: PUT (col, row), ba: RETURN bb: PUT (col, row), bb: RETURN bc: PUT (col, row), bc: RETURN bd: PUT (col, row), bd: RETURN be: PUT (col, row), be: RETURN bf: PUT (col, row), bf: RETURN bg: PUT (col, row), bg: RETURN bh: PUT (col, row), bh: RETURN bi: PUT (col, row), bi: RETURN bj: PUT (col, row), bj: RETURN bk: PUT (col, row), bk: RETURN bl: PUT (col, row), bl: RETURN bm: PUT (col, row), bm: RETURN bn: PUT (col, row), bn: RETURN bo: PUT (col, row), bo: RETURN bp: PUT (col, row), bp: RETURN bq: PUT (col, row), bq: RETURN br: PUT (col, row), br: RETURN bs: PUT (col, row), bs: RETURN bt: PUT (col, row), bt: RETURN bu: PUT (col, row), bu: RETURN bv: PUT (col, row), bv: RETURN bw: PUT (col, row), bw: RETURN bx: PUT (col, row), bx: RETURN by: PUT (col, row), by: RETURN bz: PUT (col, row), bz: RETURN titik: PUT (col, row), titik: RETURN seru: PUT (col, row), seru: RETURN 'tanya: PUT (col, row), tanya: RETURN END SUB