26. テキスト・ゲームループ・シーン

第25章では、クラスをengineライブラリに移し、スプライトを画面に出すのに必要な物を全部揃えました。
Camera2D、PixelCanvas、SpriteBatch、スプライトシート、アニメーションです。
此れでゲームを「描く」事は出来ますが、「動かす」にはまだ足りません。
ゲームにはタイトル・得点・メニューの文字が要ります。
パソコンの描画の速さに関係無く、ゲームの処理を一定のペースで進めるループも要ります。
「今スペースを押した?」に答える入力、タイトル画面・ゲーム本体・一時停止メニューを切り替える仕組み、当たり判定、そしてどのマシンでも同じ結果になる乱数も要ります。

此の章では、其の6つの部品をエンジンに足します。
全部、第25章のSpriteBatchの上に乗るCPU側のコードです。
此の章で新しいOpenGLの関数はありません。
難しいのはタイミングと構造です。
最後にパート5が終わり、パート6の4つのゲームは正に此のエンジンの上に作られます。

26.1 此の章で作る物

プログラムgameは道具箱の小さな見本です。
タイトル画面、遊び場、一時停止メニューがあり、其の間はフェードで切り替わります。

タイトル画面。ピクセルアートの空と雲、草、5枚のコイン、歩く主人公。其の上の半透明の帯に金色の2D GAME TOOLKIT、日英の副題、PRESS SPACEとEsc: quit

動画では、タイトルからフェードで遊び場に入り、コインを1枚拾い、一時停止メニューを開いてタイトルに戻ります:

操作:

  • タイトル:スペース、Enter、又は左クリックで開始、Escで終了
  • 遊び場:矢印キー又はW、A、S、Dで主人公を動かす。Bで当たり判定の箱を表示、Iで補間のオン・オフ、Uで更新の速さを60 Hzと10 Hzで切り替え、P又はEscで一時停止
  • 一時停止メニュー:↑と↓(又はWとS)で選び、スペース、Enter、又は項目のクリックで決定、P又はEscで再開

第25章からの変更:

  • engine/include/engine/font.hh、engine/src/font.cc(新規):Font。BMFontのテキスト形式のビットマップフォントとUTF-8の読み取り
  • engine/include/engine/game_loop.hh、engine/src/game_loop.cc(新規):GameLoop。固定ステップのループ
  • engine/include/engine/input.hh、engine/src/input.cc(新規):Input。更新ステップごとの「押した・押している・離した」と、名前を付けた行動
  • engine/include/engine/scene.hh、engine/src/scene.cc(新規):SceneとSceneManager。フェード付きのシーンのスタック
  • engine/include/engine/collision.hh、engine/src/collision.cc(新規):AABBの重なり、最小移動ベクトル、掃引テスト、moveAndSlide
  • engine/include/engine/rng.hh、engine/src/rng.cc(新規):Rng。種を決められ、範囲への変換がどの環境でも同じ乱数
  • assets/fonts/(新規):フォントのアトラスmono16、pixel12、pixel5。第25章のpixfont.pngはassets/sprites/から此処に移ります(完成したファイルは章のZIPとアセットのZIPのch26/に入っています)
  • assets/sprites/objects_nopad.*:削除(第25章のフィルタリングの比較だけが使っていました)
  • assets/LICENSE.txt:フォントの項目と、フォントのライセンスの表示
  • demo/:第25章のdemo/main.ccの代わりにdemo.hh、main.cc、title_scene.cc、playground_scene.cc、pause_scene.cc
  • engine/CMakeLists.txtとCMakeLists.txt:新しいソースファイル

第25章がエンジンに入れた物は何も変わりません。
新しい6つのソースはエンジンの一覧の最後に入ります:

  src/animation.cc
  # 第26章:ゲームの道具 / chapter 26: the game toolkit
  src/font.cc
  src/input.cc
  src/game_loop.cc
  src/scene.cc
  src/collision.cc
  src/rng.cc)

そしてgameのソースファイルは4つになります:

# この章のデモ / this chapter's demo
add_executable(game
  demo/main.cc
  demo/title_scene.cc
  demo/playground_scene.cc
  demo/pause_scene.cc)
target_link_libraries(game PRIVATE engine)
enable_warnings(game)
set_working_directory(game)

ファイルを足したらCMakeを実行し直して下さい(Visual StudioはCMakeLists.txtが変わると自分で実行します)。

26.2 ビットマップフォント

OpenGLは文字を描けません。
描けるのはテクスチャ付きの三角形なので、昔からのやり方は、全ての文字の絵を1枚のテクスチャ、フォントアトラスに並べ、文字ごとにテクスチャ付きの四角形を1枚描く事です。
四角形の方はもうあります。
第25章のSpriteBatchは、何千枚ものテクスチャ付きの長方形を数回の描画コールで描きます。
足りないのはアトラスと、各文字がアトラスの何処にあり、行の上にどう置くかを書いた説明です。

アトラス

此の章で入れる2枚のアトラスです。
白い文字が見える様に、暗い背景の上に重ねています:

2枚のフォントアトラス。mono16.pngは512 × 512でアンチエイリアスのASCII、ひらがな、カタカナ、記号、漢字。pixel12.pngは512 × 256で同じ文字を1ビットのピクセルで

  • assets/fonts/mono16.png / .fnt:16 px、アンチエイリアス、512 × 512。画面の解像度で描く文字用です。1280 × 720のUIのタイトル、メニュー、HUD。
  • assets/fonts/pixel12.png / .fnt:同じ文字を12 pxで、1ビット(全てのピクセルが完全にオンかオフ)、512 × 256。低解像度のPixelCanvasの中で描く文字用です。アンチエイリアスの縁は、キャンバスを拡大するとぼやけたブロックになってしまいます。TextureFilter::Nearestで読み込みます。
  • assets/fonts/pixel5.fnt:第25章の3 × 5のpixfont.png(大文字、数字、記号、ASCII 32〜95、a〜zは大文字に対応)を同じ形式で説明した物で、小さなHUD用です。日本語はありません。

画像のRGBは白で、文字の覆い具合はアルファに入っています。
Fontは其れを第25章のloadSpriteTextureで読みます。
此の関数はアルファを乗算済みにし(2Dのエンジンでは全てが乗算済みアルファです)、端はクランプします。
文字の色はスプライトの色付けで決まるので、白いアトラス1枚でどんな色の文字も描けます。
全ての文字の周りには1 pxの透明な隙間があり、スプライトシートと同じ決まりです。
GL_LINEARで中途半端な倍率にしても、隣の文字のピクセルを拾いません。

どちらのアトラスも、此のシリーズの全てのアセットと同じく、あたしのPythonのスクリプト(PillowとNumPy)で作りました(スクリプトはダウンロードに含まれません)。
フォントの本当の寸法で各文字を描き、文字を行に詰め(「棚詰め」)、PNGと.fntファイルを書きます。
ラテン文字はDejaVu Sans Mono(下の表の記号のうち×と÷も此方)、日本語はNoto Sans CJK JPのRegularから来ています。
文字の送り幅は整数のピクセルに丸めています。
16 pxでラテン文字は全て10 px(等幅フォントです)、日本語は全て16 pxなので、文字はピクセルの格子に乗ったままです。

どの文字を入れるか:英語と日本語の一部

此のシリーズは日英の2か国語で、ゲームの画面も同じです。
でもフォントアトラスには、ワープロのフォントには無いコストがあります。
文字一つ一つがテクスチャの中の絵なので、どの絵があるかを先に決めなければなりません。
mono16とpixel12はどちらも554文字を持っています:

グループ 文字 数
ASCII 32〜126(空白からチルダ迄) 95
ひらがな ぁ … ゖ、ゝ ゞ 88
カタカナ ァ … ヺ、ー ヽ ヾ 93
記号 、。・「」『』()【】〜…!?:+-×÷=%&#*と全角の空白 26
漢字 ゲームのUIの言葉 252

252の漢字は、ゲームの画面で使う言葉から選びました。
開始 終了 一時停止 再開 得点 最高 残機 体力 勝利 敗北 選択 決定 設定、方角や色、そしてRPGで良く使う物(宝箱 鍵 扉 村 森 城 剣 盾 薬 攻撃 防御 魔法 回復…)です。
16 pxで2 pxの隙間を入れると、1文字がアトラスの約18 × 18 = 324 px²を使うので、512² = 262 144 px²に入るのは約800文字です(16 × 16の文字なら28個 × 28行 = 784文字)。
常用漢字の2 136字だけで1024 × 1024のアトラスが要り、JIS X 0208の漢字6 355字全部なら2048 × 2048(RGBA8で16 MiB)になります。
其れを全てのゲームが読み込みます。
「一時停止」としか言わないゲームでもです。

其の為、ゲームの決まりは次の通りです:

  • 短いUIの文字は2か国語:タイトル、メニューの項目、「一時停止 / PAUSED」や「コイン / coins」の様なラベル。中の文字は全て共有のアトラスにあります。
  • 数字や略語が殆どの詰まったHUDの文字は英語:「FPS 60 steps/frame 1」、「SCORE 01230」。
  • もっと漢字が要るゲーム、例えば第35章のRPGの会話は、自分のフォルダに自分のアトラスを持ちます。標準の文字に其のゲームが使う文字を足して同じ様に作った物で、ゲームは其処から読み込みます。共有のassets/fonts/は此の章の状態の儘です。

アトラスに無い文字は?で描かれ、Fontは其の文字を初めて見た時に警告を出します。
足りない漢字は、誰も開かなかったメニューに隠れたりせず、テストで動かした時のコンソールに出て来ます。
好きな日本語を書きたい時の為に、アセットのZIPのextras/jis-level1-fonts/には、JIS第1水準の漢字2 965字全部と、記号、全角の英数字、かなを足したmono16とpixel12(3 443文字)が入っています。
同じ作り方、同じフォント、同じ寸法で、今の554文字はピクセル単位で同じなので、assets/fonts/の同じ名前のファイルと入れ替えるだけで使えます(アトラスはpixel12が1024 × 1024、mono16が1024 × 2048になります)。

ライセンス

アトラスには2つのフォントから描いた文字の画像が入っているので、フォントのライセンスも一緒に付いて来ます。
フォントのファイル自体は入れていません。

  • DejaVu Sans Mono:Copyright (c) 2003 by Bitstream, Inc.(Bitstream VeraはBitstream, Inc.の商標)。DejaVuの変更はパブリックドメインです。Bitstream Veraのライセンスでは、フォントの使用、複製、変更、配布が出来、販売されるソフトウェアの一部としても構いません。条件は、著作権・商標・許諾の表示を残す事、フォント単体では売らない事、変更した物を「Bitstream」や「Vera」と呼ばない事です。
  • Noto Sans CJK JP:Copyright 2014-2021 Adobe。NotoはGoogle Inc.の商標です。SIL Open Font License 1.1で、商用を含むどんなソフトウェアでも使用、埋め込み、再配布が出来ます。条件は、フォント単体では売らない事、著作権表示とライセンスの本文を含める事、派生物もOFLの儘にする事です。

あたしはアトラスをフォントからの派生物として扱っています。
assets/LICENSE.txtに両方の表示があり、此のアトラスを使ったゲームを配る時は、此のファイルも一緒に配って下さい。
assets/の其の他の物は全て此のチュートリアルの為に作った物で、自由に使えます。

BMFontのテキスト形式

アトラスの説明は、BMFont形式の小さなテキストファイルです。
名前はAngelCodeのWindows用ツールBMFontから来ています。
事実上の標準で、BMFontやlibGDXのHiero(Java、どのOSでも)が書き出し、多くのエンジンが読めます。
なので、其れらのツールで自分のアトラスを作る事も出来ます。
mono16.fntの最初の数行と、A及びgの行です:

info face="DejaVu Sans Mono + Noto Sans CJK JP" size=16 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=2,2
common lineHeight=20 base=15 scaleW=512 scaleH=512 pages=1 packed=0
page id=0 file="mono16.png"
chars count=554
char id=32 x=1 y=1 width=0 height=0 xoffset=0 yoffset=15 xadvance=10 page=0 chnl=15
char id=65 x=387 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
char id=103 x=337 y=17 width=10 height=12 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15

各行はタグとkey=valueの組の並びです。
使うタグは3つです:

  • common:lineHeight(行から次の行までの距離、20 px)とbase(行の上端からベースラインまで、15 px)。
  • page:画像ファイル。.fntからの相対パスです。大きなフォントは複数のページに分かれる事がありますが、あたし達のフォントは1ページで、Fontはページ0だけを使います。
  • char:1文字に1行。idはUnicodeのコードポイント(65 = A、103 = g、12354 = あ)、x y width heightはアトラスの中の長方形、xoffset yoffsetは行の上端のペンの位置から見た其の長方形の置き場所、xadvanceは次の文字の為にペンが進む距離です。

info、chars、kerningの行は無視します。
あたし達のフォントは等幅で、カーニングの組がありません。
図はA、g、あの本物の文字で寸法を示しています:

mono16のA、g、あを12倍にした物を、高さ20ピクセルの点線の行の箱の中に置いた図。ベースラインは15。gは行の上端から6ピクセル下から始まり、尻尾はベースラインより下に出る。行の下では、xadvanceの矢印10、10、16がペンを0から10、20、36へ進める

yoffsetはベースラインからではなく、行の上端から測る事に注意して下さい。
此れはあたし達のy下向きの2Dの世界にぴったりです。
文字のスプライトは(ペンのx + xoffset、行の上端 + yoffset)に置き、大きさはwidth × heightです。
Aはベースラインの上に乗り(3 + 12 = 15)、gはベースラインより3 px下まで届き(6 + 12 = 18)、空白は幅0でペンを進めるだけです。

読み込み

font.hhは文字1つと文字のスタイルを宣言します:

// 一文字の画像と置き方(ピクセル) / one glyph's image and placement (pixels)
struct Glyph {
  Rect pixels;     // アトラスの中の長方形 / rectangle in the atlas
  Vec2 offset;     // 行の左上から画像の左上まで / from the line's top left to the image's top left
  float advance;   // 次の文字までの幅 / distance to the next character
};

enum class TextAlign { Left, Centre, Right };

struct TextStyle {
  Vec4 color = kWhite;
  float scale = 1.0f;                // 1 = アトラスのピクセルのまま / 1 = the atlas's own pixels
  TextAlign align = TextAlign::Left; // 行ごとに:positionが左端・中央・右端 / per line: position is the left edge,
                                     // center or right edge
  float layer = 0.0f;                // SpriteSort::Layer用 / for SpriteSort::Layer
  Vec4 shadow = {0.0f, 0.0f, 0.0f, 0.0f}; // 影の色(アルファ0 = 影なし) / shadow color (alpha 0 = no shadow)
  Vec2 shadowOffset = {1.0f, 1.0f};       // 影のずれ(scale倍される) / shadow offset (multiplied by scale)
  // 文字をワールドの整数座標にそろえる:拡大率1でピクセルにぴったり乗り、ぼけない / snap glyphs to whole world units:
  // at scale 1 they sit exactly on pixels and stay sharp
  bool snap = true;
};

TextStyleは、第25章のSpriteと同じく、指示付き初期化子で使う集成体です:{.color = …, .scale = 2.0f, .align = TextAlign::Centre}。
メンバーは宣言の順に書かなければなりません(.color, .scale, .align, .layer, .shadow, .shadowOffset, .snap)。
C++20は順番が違うと受け付けません。

Font::loadはファイルを1行ずつ読み、小さな補助関数parseFieldsで各行をkey=valueの組に切り分け(引用符付きのfile="…"も扱います)、必要な物だけを取っておきます:

std::optional<Font> Font::load(const std::string &fntPath, TextureFilter filter) {
  std::optional<std::string> text = readTextFile(fntPath);
  if (!text) {
    fprintf(stderr, "%s: 読めない / cannot read (プロジェクトのルートから実行した? / running from the project root?)\n",
            fntPath.c_str());
    return std::nullopt;
  }
  Font font;
  std::string pageFile;
  std::istringstream lines(*text);
  std::string line;
  int lineNumber = 0, glyphs = 0;
  while (std::getline(lines, line)) {
    ++lineNumber;
    if (!line.empty() && line.back() == '\r') line.pop_back();
    std::string tag = line.substr(0, line.find(' '));
    auto f = parseFields(line);
    auto number = [&](const char *key) {
      auto it = f.find(key);
      return it == f.end() ? 0.0f : std::strtof(it->second.c_str(), nullptr);
    };
    if (tag == "common") {
      font.lineGap = number("lineHeight");
      font.baseline = number("base");
      if (number("pages") > 1) fprintf(stderr, "%s: 最初のページだけ使う / only the first page is used\n", fntPath.c_str());
    } else if (tag == "page") {
      if (number("id") == 0) pageFile = f["file"];
    } else if (tag == "char") {
      if (f.find("id") == f.end()) {
        fprintf(stderr, "%s:%d: idのないchar / char without id\n", fntPath.c_str(), lineNumber);
        return std::nullopt;
      }
      char32_t id = static_cast<char32_t>(std::strtoul(f["id"].c_str(), nullptr, 10));
      Glyph g{{number("x"), number("y"), number("width"), number("height")},
              {number("xoffset"), number("yoffset")}, number("xadvance")};
      if (id < 128) {
        font.ascii[id] = g;
        font.hasAscii[id] = true;
      } else {
        font.others[id] = g;
      }
      ++glyphs;
    }
    // info, chars, kerning… は使わない(等幅フォントなのでカーニングなし) / info, chars, kerning... are not used
    // (monospaced fonts need no kerning)
  }
  if (pageFile.empty() || glyphs == 0 || font.lineGap <= 0.0f) {
    fprintf(stderr, "%s: BMFontのテキスト形式ではない? / not a BMFont text file? (page, char, common lineHeight)\n",
            fntPath.c_str());
    return std::nullopt;
  }
  size_t slash = fntPath.find_last_of("/\\");
  std::string folder = slash == std::string::npos ? "" : fntPath.substr(0, slash + 1);
  std::optional<Texture2D> texture = loadSpriteTexture(folder + pageFile, filter);
  if (!texture) return std::nullopt;
  font.image = std::move(*texture);
  return font;
}

ASCIIの文字は128個の普通の配列に入れます。
一番良く使われる文字で、配列の添字は一番速い引き方だからです。
其れ以外はunordered_map<char32_t, Glyph>に入ります。
ページも文字も行の高さも無いファイルはBMFontのテキスト形式ではないので(BMFontはXMLやバイナリの形式も書けます)、loadは何も描かずに黙るのではなく、其の事を伝えます。
ページの画像は.fntの隣で探すので、フォントのフォルダは丸ごと移せます。
例えばゲーム自身のassets/の中へです。

26.3 UTF-8

あたし達の文字列は"一時停止 / PAUSED"の様なUTF-8のstd::stringのリテラルです。
1文字は1〜4バイトなので、文字を探すには、バイトをコードポイントに戻さなければなりません。
第13章ではJSONのパーサーの為にコードポイントをUTF-8で書きました。
読むのは同じ表を逆から読むだけです:

バイト コードポイントのビット数 範囲 例
0xxxxxxx 7 U+0000〜U+007F A = 41
110xxxxx 10xxxxxx 11 U+0080〜U+07FF é = C3 A9
1110xxxx 10xxxxxx 10xxxxxx 16 U+0800〜U+FFFF あ = E3 81 82
11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 21 U+10000〜U+10FFFF 😀 = F0 9F 98 80

先頭のバイトが後に何バイト続くかを示し、続くバイトは全て10のビットで始まります。
第13章の木、E6 9C A8をもう一度取り上げます:

  • 0xE6 = 1110 0110:全部で3バイト。中身は下の4ビット、0x6です。
  • 0x9C = 10 011100:6ビット足して、(0x6 << 6) | 0x1C = 0x19C。
  • 0xA8 = 10 101000:更に6ビット足して、(0x19C << 6) | 0x28 = 0x6728。

U+6728は木です。
読み取りの関数は正に此れをします:

char32_t decodeUtf8(std::string_view s, size_t &i) {
  auto byte = [&](size_t k) { return static_cast<unsigned char>(s[k]); };
  unsigned char b0 = byte(i++);
  if (b0 < 0x80) return b0; // ASCII
  // 先頭バイトの上のビットで長さが決まる:110xxxxx = 2、1110xxxx = 3、11110xxx = 4バイト
  // The leading byte's top bits give the length: 110xxxxx = 2, 1110xxxx = 3, 11110xxx = 4 bytes
  int extra = (b0 & 0xE0) == 0xC0 ? 1 : (b0 & 0xF0) == 0xE0 ? 2 : (b0 & 0xF8) == 0xF0 ? 3 : -1;
  if (extra < 0 || i + static_cast<size_t>(extra) > s.size()) return 0xFFFD;
  char32_t c = b0 & (0x3F >> extra);
  for (int k = 0; k < extra; ++k) {
    unsigned char b = byte(i);
    if ((b & 0xC0) != 0x80) return 0xFFFD; // 続きのバイトは10xxxxxx / continuation bytes are 10xxxxxx
    c = (c << 6) | (b & 0x3F);
    ++i;
  }
  return c;
}

0x3F >> extraは先頭のバイトの中身のマスクです。
2バイトなら5ビット(0x1F)、3バイトなら4ビット(0x0F)、4バイトなら3ビット(0x07)です。
文字を始められないバイト、文字列の終わりで切れた並び、10で始まる続きのバイトが無い場合は、全てU+FFFD(Unicodeの置換文字)になり、ループは次のバイトから続けます。
壊れた文字列でも、終わりより先を読む事はありません。
冗長な形、サロゲート、U+10FFFFより大きい値は弾きません(フォントに無いので?で描かれるだけです)。
文字列は自分達のソースファイルから来るので、検証器である必要は無いからです。

26.4 文字を描く

1文字 = スプライト1枚

drawはペンを持って文字列を辿ります。
xは行の左端から始まり、文字ごとにスプライトを1枚作り、ペンをxadvanceだけ進めます。
改行はyをlineHeightだけ下げ、xを戻します:

void Font::draw(SpriteBatch &batch, std::string_view s, Vec2 position, const TextStyle &style) const {
  // 影は同じ文字をずらして先に描く(同じlayerの中で先 = 奥) / the shadow is the same text drawn first, offset (first
  // within the same layer = behind)
  if (style.shadow.w > 0.0f) {
    TextStyle shadowStyle = style;
    shadowStyle.shadow.w = 0.0f;
    shadowStyle.color = style.shadow;
    draw(batch, s, position + style.shadowOffset * style.scale, shadowStyle);
  }
  auto lineStart = [&](size_t i) {
    float w = lineWidth(s, i) * style.scale;
    float x = style.align == TextAlign::Left ? position.x : style.align == TextAlign::Centre ? position.x - 0.5f * w
                                                                                                : position.x - w;
    return style.snap ? std::round(x) : x;
  };
  float y = style.snap ? std::round(position.y) : position.y;
  float x = lineStart(0);
  size_t i = 0;
  while (i < s.size()) {
    char32_t c = decodeUtf8(s, i);
    if (c == U'\n') {
      y += lineGap * style.scale;
      x = lineStart(i);
      continue;
    }
    const Glyph &g = glyphOrFallback(c);
    if (g.pixels.w > 0.0f && g.pixels.h > 0.0f) {
      float w = static_cast<float>(image.width()), h = static_cast<float>(image.height());
      batch.draw({.texture = &image,
                  .position = {x + g.offset.x * style.scale, y + g.offset.y * style.scale},
                  .size = g.pixels.size() * style.scale,
                  .uv = {g.pixels.x / w, g.pixels.y / h, g.pixels.w / w, g.pixels.h / h},
                  .color = style.color,
                  .layer = style.layer});
    }
    x += g.advance * style.scale;
  }
}

文字は呼び出し側のSpriteBatchのbeginとendの間で描くので、他の物と一緒にまとめて描かれます。
HUDの1行全体が描画コール1回で、既定のSpriteSort::Noneでは送った順番が保たれるので、文字の前に描いた長方形は文字の後ろになります。
位置は1行目の左上(y下向き)で、UIの配置には此れが便利です。
他の物とベースラインを揃えたい時は、base()がベースラインの位置を教えてくれます。

スタイルの項目:

  • scaleは全てを掛けます:オフセット、大きさ、送り幅、行の高さ。タイトルはmono16を4倍と2倍で使っています。整数倍なら文字はピクセルの格子に揃った儘で、GL_LINEARのお陰で拡大した縁はカクカクではなく滑らかになります。
  • alignは行ごとです。Leftは行の左端を、Centreは真ん中を、Rightは右端をposition.xに合わせます。lineStartが行ごとに幅を測るので、2行の中央揃えの文字は、其々の行が自分で中央に揃います。
  • shadowはアルファが0より大きければ、同じ文字を先に影の色で、shadowOffset × scaleだけずらして描きます。同じレイヤーで先に描く = 奥に描く、です。
  • snapは各行の始まり(と1行目のy)を整数に丸めます。Camera2D::screenで倍率1なら1単位が画面の1ピクセルなので、幅が奇数の中央揃えの行が半ピクセルの所に来てぼやける事がありません。
  • layerは全てのスプライトに渡され、SpriteSort::Layerで使われます。

無い文字

?はglyphOrFallbackから来ます:

const Glyph &Font::glyphOrFallback(char32_t c) const {
  if (const Glyph *g = glyph(c)) return *g;
  if (warned.insert(c).second) fprintf(stderr, "フォントにない文字 / character not in the font: U+%04X\n", static_cast<unsigned>(c));
  // 代わりに「?」(それもなければ空白の幅) / a "?" instead (or the width of a space if even that is missing)
  if (const Glyph *q = glyph(U'?')) return *q;
  static const Glyph empty{{0, 0, 0, 0}, {0, 0}, 0};
  return empty;
}

warnedがmutableなのは、描画はconstの操作なのに、どのコードポイントで文句を言ったかは覚えておく為です。
デモを作っている時、此れがタイトルの最初の版の文字列にあった「―」(U+2015、ホリゾンタルバー)を見つけてくれました。
画面では?になっていて、見落とし易い所でした。

大きさを測る

measureは描く前に文字列の大きさを教えてくれます。
一番長い行の幅と、行数 × lineHeightで、どちらにも倍率が掛かります。
空の文字列は幅0、高さ1行です:

float Font::lineWidth(std::string_view s, size_t i) const {
  float width = 0.0f;
  while (i < s.size()) {
    char32_t c = decodeUtf8(s, i);
    if (c == U'\n') break;
    width += glyphOrFallback(c).advance;
  }
  return width;
}

Vec2 Font::measure(std::string_view s, float scale) const {
  float widest = 0.0f;
  int lines = 1;
  size_t i = 0;
  widest = lineWidth(s, 0);
  while (i < s.size()) {
    if (decodeUtf8(s, i) == U'\n') {
      ++lines;
      widest = std::max(widest, lineWidth(s, i));
    }
  }
  return Vec2{widest, lineGap * static_cast<float>(lines)} * scale;
}

mono16でmeasure("Hello")は5 × 10 = 50 × 20、pixel12では5 × 7 = 35 × 16です。
会話の箱の大きさを決めたり、ボタンのラベルを中央に置いたり、得点を手で右揃えしたりする時に使います。

デモでは

タイトルのUIのパスで殆どが分かります:

void TitleScene::drawUi(float /*alpha*/) {
  SpriteBatch &b = d.batch;
  b.begin(d.screen.matrix());
  // 文字の後ろに半透明の帯:明るい空の上でも読める / a translucent band behind the text: readable over the bright sky
  b.drawRect({0.0f, 110.0f, 1280.0f, 330.0f}, hexColor(0x1b172699));
  const Vec4 shadow = hexColor(0x1b1726ff);
  d.ui.draw(b, "2D GAME TOOLKIT", {640.0f, 140.0f},
            {.color = hexColor(0xf2c14eff), .scale = 4.0f, .align = TextAlign::Centre, .shadow = shadow});
  d.ui.draw(b, "2Dゲームの道具箱(第26章) / Chapter 26", {640.0f, 240.0f},
            {.color = hexColor(0xfff4d6ff), .scale = 2.0f, .align = TextAlign::Centre, .shadow = shadow});
  // 点滅:時間で透明度を変える / blinking: the opacity follows the time
  float blink = 0.55f + 0.45f * std::cos(4.0f * time);
  d.ui.draw(b, "PRESS SPACE  /  スペースキーで開始", {640.0f, 330.0f},
            {.color = {1.0f, 1.0f, 1.0f, blink}, .scale = 2.0f, .align = TextAlign::Centre, .shadow = shadow});
  d.ui.draw(b, "Esc: quit / 終了", {640.0f, 395.0f},
            {.color = hexColor(0xc8cce0ff), .scale = 1.0f, .align = TextAlign::Centre, .shadow = shadow});
  b.end();
}

"2D GAME TOOLKIT"は15文字で、4倍で15 × 10 × 4 = 600 px、x = 640を中心にしています。
点滅する行は色のアルファだけを0.55+0.45cos4tで0.1から1の間で変えています。
デモが描く3種類の文字を切り抜いた物です:

デモの文字の切り抜き。mono16の4倍と2倍のタイトルの日本語と英語、mono16の倍率1で1ピクセルの影付きのHUDの行を2倍に拡大した物、そして320 × 180のキャンバスの中で主人公の隣に出たpixel12の+1

「+1」は320 × 180のキャンバスに描いたpixel12なので、キャンバスの4倍の拡大で各ピクセルが4 × 4のブロックになり、周りのスプライトと同じ見た目になります。
アンチエイリアスのフォントをキャンバスに描くと、縁の灰色のピクセルが灰色のブロックになります。
其の為、ピクセルフォントは1ビットです。

26.5 固定ステップのゲームループ

何故固定ステップなのか

第2章から、あたし達のループは毎フレームの時間を測り、速さ × デルタタイムで物を動かして来ました。
カメラなら其れで良いのですが、ゲームの処理では2つの理由で問題になります。

1つ目は決定性です。
ジャンプを考えます。
主人公はv0=300 px/sで地面を離れ、重力はg=900 px/s²で、遊び場の紙吹雪と同じく毎回の更新でy += v * dt; v -= g * dt;をします。
本当の最高点はv02/2g=50 pxですが、計算上の最高点はΔtで変わります。
v0/(gΔt)が整数n(頂上までの更新の回数)の時、n回の更新の後の高さは

h=Δt∑k=0n−1(v0−kgΔt)=v022g+v0Δt2

1秒あたりの更新 Δt 最高点
144 1/144 s 51.04 px
60 1/60 s 52.50 px
30 1/30 s 55.00 px

デルタタイムで更新すると、30 Hzのノートパソコンのプレイヤーは54 pxの段差を越えられるのに、60 Hzのモニターのプレイヤーは届きません。
リプレイや、入力だけを送るネットワークゲームも同じ様に壊れます。
同じ入力が、別のマシンでは別のゲームになるのです。
1/60秒の固定ステップなら、ジャンプはどこでも52.50 pxです。

2つ目は安定性です。
多くの積分の方法は、ステップが十分に小さい時だけ安定です。
角振動数ω=20 rad/sのばねを、普通の「先に速度、次に位置」(半陰的オイラー法)で積分すると、ωΔt<2の間、つまりステップが0.1秒より短い間は安定です。
1/60秒ならωΔt=1/3で問題ありません。
でも0.25秒のフレームが1回(ウィンドウのドラッグ、ディスクの待ち、ブレークポイント)あるとωΔt=5になり、ばねの振幅は1ステップごとに約23倍になります。
3ステップで1から−24、551、−12 649です。
固定ステップなら、物理は調整していない長さのステップを決して見ません。

従って、ゲームの処理は固定の長さの更新で動き、描画は画面が許す限り何度でも行います。
此れについての古典的な解説はGlenn Fiedlerの「Fix Your Timestep!」で、あたし達のGameLoopも其れに従っています。

貯金(accumulator)

毎フレーム、過ぎた時間を貯金(accumulator)に足します。
そして貯金が1ステップ以上ある限り、更新を1回実行して1ステップ分を引きます。
残り(1ステップ未満)は次のフレームを待ちます:

100ミリ秒の時間軸。上に25、10、35、8、22 msの5つのフレーム。下に16.7 msごとの固定の更新。矢印はフレームが更新を1、1、2、0、2回実行し、アルファが0.50、0.10、0.20、0.68、0.00になる事を示す

最初のフレームは25 msです。
更新1回(16.67 ms)で、8.33 msが残ります。
2つ目は10 msを足して合計18.33 ms。
更新1回で、1.67 msが残ります。
3つ目は35 msを足して36.67 ms。
更新2回で、3.33 msが残ります。
4つ目は8 msしか足さず、合計11.33 ms。
更新はありません。
5つ目は22 msを足して丁度33.33 ms。
更新2回で、何も残りません。
100 msで6回の更新で、フレームの区切りがどうであっても100 / 16.67と同じです。

残りをステップの割合で表した物をアルファと呼びます。
最初のフレームの後なら8.33 / 16.67 = 0.50です。
最後の更新から次の更新までの間で、実時間が何処まで進んだかを表し、此の後すぐに描画で使います。

ループの設定と統計:

struct GameLoopSettings {
  double step = 1.0 / 60.0; // 更新1回の時間(秒) / seconds per update
  // 1フレームで追いつく更新の上限。超えた分の時間は捨てる(遅いPCで「死のスパイラル」にならないように)
  // The most updates run in one frame to catch up; time beyond that is dropped (no "spiral of death" on slow PCs)
  int maxSteps = 5;
  // これより長いフレーム(デバッガーで止めた等)は、この長さだったことにする / longer frames (e.g. stopped in a
  // debugger) count as this long
  double maxFrame = 0.25;
  // フレームの時間がステップの整数倍にこれだけ近ければ、ちょうどにする(60 Hzの画面で16.4〜16.9 msを16.67 msに)。
  // 揺れで更新が0回・2回と交互になるのを防ぐ。貯金がステップにこれだけ足りないときも更新する(maxStepsで
  // 捨てるときも1ステップと数える)
  // Snap a frame's duration to a whole number of steps when it is this close (16.4-16.9 ms become 16.67 ms on a
  // 60 Hz screen); stops jitter from alternating 0 and 2 updates. An accumulator this close to a step also updates
  // (and counts as a whole step when time is dropped at maxSteps)
  double snapTolerance = 0.0002;
};

struct GameLoopStats {
  int steps = 0;           // 前のフレームの更新の回数 / updates in the last frame
  long long totalSteps = 0; // 始めてからの更新の回数 / updates since the start
  float alpha = 0.0f;      // 前のフレームの補間の割合 / the last frame's interpolation factor
  float fps = 0.0f;        // 1秒あたりのフレーム数(0.5秒ごとに計算) / frames per second (computed every 0.5 s)
  double droppedSeconds = 0.0; // maxSteps・maxFrameで捨てた時間の合計 / total time dropped by maxSteps / maxFrame
};

そして1フレーム分の計算:

int GameLoop::advance(double frameSeconds) {
  if (frameSeconds > config.maxFrame) {
    info.droppedSeconds += frameSeconds - config.maxFrame;
    frameSeconds = config.maxFrame;
  }
  if (frameSeconds < 0.0) frameSeconds = 0.0;
  // ステップの整数倍に近ければそろえる / snap to a whole number of steps when close
  double multiple = std::round(frameSeconds / config.step);
  if (multiple >= 1.0 && std::fabs(frameSeconds - multiple * config.step) < config.snapTolerance)
    frameSeconds = multiple * config.step;

  accumulator += frameSeconds;
  int steps = 0;
  // 貯金がステップにほんの少し足りないだけ(浮動小数点の誤差:0.0333…×3 = 0.0999…)なら更新する。
  // 残りがわずかに負になっても、alpha()は0に切り詰める
  // Also update when the accumulator is only a hair short of a step (floating-point error: 0.0333... × 3 =
  // 0.0999...). If what is left goes slightly negative, alpha() clamps it to 0
  while (accumulator > config.step - config.snapTolerance && steps < config.maxSteps) {
    accumulator -= config.step;
    ++steps;
  }
  // 上限に達しても丸ごとのステップが残っていれば捨てる(追いつけない分)。上と同じ許容差で数えるので、
  // ほんの少し足りないだけの分も1ステップとして捨てる / whole steps still left at the limit are dropped (they cannot
  // be caught up), counted with the same tolerance as above: one that is only a hair short is dropped too
  if (steps == config.maxSteps && accumulator > config.step - config.snapTolerance) {
    double whole = std::floor((accumulator + config.snapTolerance) / config.step);
    info.droppedSeconds += whole * config.step;
    accumulator -= whole * config.step;
  }
  info.steps = steps;
  info.totalSteps += steps;
  info.alpha = alpha();
  return steps;
}

死のスパイラル

maxStepsが無いと、ループには罠があります。
遅いパソコンで、更新1回にCPUの時間が20 msかかるとします。
其の更新が表す16.67 msより長いのです。
更新1回のフレームは20 ms以上かかったので、次のフレームは更新を2回しなければならず、其れには40 msかかり、其の次は3回…
フレームごとに前より多くの更新が必要になり、ゲームは固まります。
死のスパイラルです。

maxSteps(5)がスパイラルを断ち切ります。
1フレームの更新は最大5回で、其れを超えた時間は捨てます(droppedSecondsに数えます)。
するとゲームは止まるのではなく、実時間より遅く動きます。
1/60秒のステップ5回は1/12秒なので、ゲームは毎秒12フレーム迄は実時間を保ちます。
毎秒10フレーム(0.1秒のフレーム)では1フレームに更新5回で、実時間の5/6の速さになります。

maxFrame(0.25秒)は1回だけの長いフレームを扱います。
ブレークポイント、Windowsでのウィンドウのドラッグ(ループを止めます)、ノートパソコンのスリープからの復帰などです。
此れが無いと、10秒のブレークポイントから戻った時に600回の更新をしようとします。
此れがあれば、1フレームは最大0.25秒と数えられ、5回の更新をして、残りは捨てられます。
1秒の引っかかりなら、maxFrameで0.75秒を捨て、5回の更新(0.0833秒)をして、残りの0.1667秒を捨て、合計0.917秒を捨てます。

そろえる:1フレーム遅れて来た更新

ループの最初の版にはsnapToleranceがありませんでした。
テストでは、簡単に再現出来る形でおかしくなりました。
snapTolerance = 0にして、advanceに同じフレームの時間を与えれば見られます。

テスト環境は決まった長さのフレームで動きます。
動画の為にはSHIM_DT=0.0333333333で、小数10桁で書いた30 fpsのフレームです。
1/60秒のステップ2回は0.0333333333333…なので、各フレームはステップ2回より3.3 × 10⁻¹¹秒短いのです。
許容が無いと、最初のフレームは2回ではなく1回の更新をし、其れからはフレームごとに2回の更新をしますが、いつも丸1ステップ遅れていて、アルファは0.00であるべき所が1.00になります。
10 Hzの更新だと更に目に見えます。
其のフレーム3つの合計は0.0999999999秒で、0.1秒のステップより少ないので、全ての更新が1フレーム遅れて来ます(フレームごとの更新の回数が0 0 1 0 0 1ではなく0 0 0 1 0 0 1になります)。

本物の画面には逆向きの同じ問題があります。
垂直同期をした60 Hzのモニターのフレームは16.6、16.7、16.6、16.8 msの様になり、決して丁度16.666…にはなりません。
フレームの時間が其の4つの値を繰り返すと、そろえないループは最初のフレームで0 1 1 2 0 1 1 2 0 2 0 2 …回の更新をしました。
正しい答えは毎フレーム1回の更新です。
更新2回のフレームの後に更新の無いフレームが来ると、平均は合っていても、カクつきとして見えます。

其の為advanceは、0.2 msの許容を3つの所で使います:

  • フレームの時間がステップの整数倍から0.2 ms以内なら、丁度其の長さとして数えます(16.47〜16.87 msは16.67 msになります)。
  • 貯金がステップにほんの少しだけ足りない(step − snapToleranceより多い)なら、其れでも更新します。貯金は少しだけ0より下になる事があるので、alpha()は0〜1に切り詰めます。
  • maxStepsに達した時、まだ残っている丸ごとのステップを捨てますが、同じ数え方をします。ほんの少しだけ足りないステップも捨てるのです。さもないと其れは貯金にアルファ1.00として残り、次のフレームで余分な更新になります(10 Hz、maxSteps = 2、0.25秒のフレームで、アルファが0.50、0.00ではなく0.50、1.00、0.50、1.00となっていました)。

最初の2つがあれば、テストでは1/30秒のフレームごとに丁度2回の更新、10 Hzでは0 0 1 0 0 1、揺れのある60 Hzの並びではフレームごとに1回の更新になります。
代わりに、速さがほんの少し変わります。
フレームがいつも16.5 ms(60.6 Hz)の画面では16.67 msにそろえられ、ゲームは実時間より1 %速く動きます(最大で0.2 / 16.67 = 1.2 %)。
其れに気付く人は居ませんが、其れが取り除くカクつきには誰でも気付きます。

補間

60 Hzの更新と60 Hzの画面なら、毎フレームが更新1回で、アルファは約0です。
でも144 Hzのモニターではフレームが6.94 msごとに来て、更新は0、0、1、0、1、0、0、1…回です。
最後の更新の状態を描くと、主人公は1〜2フレーム止まってから飛びます。
解決策は、前の更新の状態と今の状態の2つの状態を持ち、其の間をアルファで描く事です:

𝐩drawn=lerp(𝐩prev,𝐩cur,α)=𝐩prev+α(𝐩cur−𝐩prev)

線型代数シリーズの第2章の線型補間です。
代わりに遅延が生まれます。
見えているのは、一番新しい状態より最大1ステップ前です。
グラフは、毎秒90 pxで動く主人公を、10 Hzの更新(更新1回で9 px)と30 fpsのフレームで描いた物です:

時間に対する位置のグラフ。理想の動きは点線の斜めの線。補間なしでは、描く位置は3フレームごとに9ピクセル飛ぶ階段になる。補間ありでは、理想の線を更新1回分、100 ms遅れて追う点の直線になる

遊び場では、Uで更新を10 Hzにして違いを見られ、Iで補間を切れます。
動画は10 Hzで両方を見せています。
上が補間あり(滑らかで、HUDのアルファは0.00、0.33、0.67)、下が補間なし(3フレームに1回飛びます)です:

ゲームのコードでの型はこうです。
動く物は全て前の位置を持ち、各更新の最初に今の位置をコピーし、drawで補間します。
PlaygroundScene::updateとdrawから:

  // 主人公:行動の軸(左右・上下)で動き、壁と木箱に沿って滑る / the hero: moves by the action axes and slides along
  // walls and crates
  playerPrev = player.position();
  Vec2 move = {in.axis("left", "right"), in.axis("up", "down")};
  if (move.x != 0.0f) facingLeft = move.x < 0.0f;
  moveAndSlide(player, normalize(move) * (kSpeed * dt), solids);
  heroAnim.play(move.x != 0.0f || move.y != 0.0f ? &d.walk : &d.idle);
  heroAnim.update(dt);

void PlaygroundScene::draw(float alpha) {
  // 補間:前のステップと今のステップの間のalphaの所に描く。Iで切ると、更新の瞬間の位置に飛び飛びに描く
  // Interpolation: draw at alpha between the previous and the current step. With I off, things jump to each update's
  // position
  float a = d.interpolate ? alpha : 1.0f;
  Vec2 p = lerp(playerPrev, player.position(), a);
  float sawX = sawPrevX + (saw.x - sawPrevX) * a;

もう一つのやり方の外挿は、今の状態より先(current + velocity × alpha × step)を描き、遅延がありません。
でも推測なので、主人公が壁で止まると、次の更新で直る迄、壁の中に描かれます。
殆どのゲームは補間を使います。

此処にはもう一つ落とし穴がありました。
一時停止メニューを開いている間、遊び場は更新されませんが(更新されるのは一番上のシーンだけです)、メニューの下に描かれ続け、アルファは毎フレーム変わり続けます。
其の為、止まった主人公は前の位置と今の位置の間に、フレームごとに違うアルファで描かれ続けました。
更新1回分の距離だけ前後に震えたのです。
60 Hzの画面で60 Hzの更新なら見えませんが、10 Hzでは9 pxです。
直すのはPlaygroundScene::pause()で、上に何かが載った時にシーンマネージャーが呼びます:

// 一時停止のシーンが上に載った:更新が止まるので、前の位置 = 今の位置にしておく(でないと補間で震える)
// The pause scene went on top: updates stop, so make the previous position = the current one (otherwise the
// interpolation would make things shake)
void PlaygroundScene::pause() {
  playerPrev = player.position();
  sawPrevX = saw.x;
}

前 = 今なら、補間はどのアルファでも同じ位置になります。
補間をして、一時停止され得るゲームのシーンには全て此の数行が要ります。

run()

最後にループ本体です:

void GameLoop::run(Window &window, Input &input, const std::function<void(float dt)> &update,
                   const std::function<void(float alpha)> &draw) {
  double last = window.time();
  double fpsStart = last;
  int fpsFrames = 0;
  while (!window.shouldClose()) {
    window.pollEvents(); // ここでInputのコールバックが呼ばれる / Input's callbacks run here
    double now = window.time();
    int steps = advance(now - last);
    last = now;
    for (int i = 0; i < steps; ++i) {
      update(static_cast<float>(config.step));
      input.endStep(); // 「押した」は1ステップだけ / "pressed" lasts one step
    }
    draw(alpha());
    window.swapBuffers();

    ++fpsFrames;
    if (now - fpsStart >= 0.5) {
      info.fps = static_cast<float>(fpsFrames / (now - fpsStart));
      fpsStart = now;
      fpsFrames = 0;
    }
  }
}

先ずpollEventsで、此のフレームの入力を更新に間に合わせます。
次に更新、其の次に今のアルファで1回描き、表示します。
一番最初のフレームは殆ど時間を測らず、更新をしないので、drawはまだ更新していない状態でも描けなければなりません(あたし達のデモは最初の位置を描きます)。
更新ごとのinput.endStep()は次の節の話題です。

runは更新と描画をstd::functionで受け取るので、mainはラムダを渡せます。
advanceは公開されているので、自分のループを持つプログラム(又はテスト)は、ウィンドウ無しで計算だけを使えます。
fpsの値は0.5秒の間で測った物で、表示の為だけの物です。

26.6 更新ステップごとの入力

第2章ではGLFWのコールバックでキーを扱いました。
キーが下がった瞬間に何かが起きました。
ゲームの処理は逆に、更新の中で尋ねたいのです。
左の矢印は押している?
前の更新からスペースを押した?
離した?
「押している」は状態で、「押した」と「離した」は変化の瞬間(エッジ)です。
エッジは固定ステップでは厄介です。

すぐ思いつくのは、描画の後、フレームごとに1回エッジを消す方法です。
此れは両方向に壊れます:

3つのフレーム。Aは更新2回、Bは0回、Cは1回。フレームごとに消すと、Aの前の押下はAの2回の更新の両方でtrueになり主人公は2回跳び、Bの前の押下はどの更新にも見られない儘Bの終わりで消える。更新ごとに消すと、Aの前の押下はAの最初の更新だけでtrueになり、Bの前の押下は残ってCで見られる

更新2回のフレームは押下を2回見て(2段ジャンプ)、更新の無いフレームは失います。
上手く行く決まりは、pressed()とreleased()は丁度1回の更新ステップの間だけtrue、です。
イベントはエッジを覚えておくだけです。
GameLoop::runが更新ごとにinput.endStep()を呼び、其れだけがエッジを消します。
更新の無いフレームは次の更新の為にエッジを残し、1フレームの間に押して離しても、pressedとreleasedが1回ずつ出ます。

void Input::apply(State &s, int action) {
  if (action == GLFW_PRESS) {
    s.down = true;
    s.pressed = true;
  } else if (action == GLFW_RELEASE) {
    s.down = false;
    s.released = true;
  }
  // GLFW_REPEAT(押しっぱなしの自動連打)は無視 / GLFW_REPEAT (auto-repeat while held) is ignored
}

void Input::attach(Window &w) {
  window = &w;
  w.onKey = [this](int key, int action, int /*mods*/) {
    if (valid(key)) apply(keys[static_cast<size_t>(key)], action);
  };
  w.onMouseButton = [this](int button, int action, int /*mods*/) {
    if (validButton(button)) apply(buttons[static_cast<size_t>(button)], action);
  };
  w.onScroll = [this](double /*dx*/, double dy) { scrollSum += static_cast<float>(dy); };
}

void Input::endStep() {
  for (State &s : keys) s.pressed = s.released = false;
  for (State &s : buttons) s.pressed = s.released = false;
  scrollSum = 0.0f;
}

InputはウィンドウのonKey、onMouseButton、onScrollのコールバックを引き受け、ラムダはthisを捕まえます。
其の為、Inputはコピーも移動も出来ません。
移動したInputは、ウィンドウに古いオブジェクトを呼ばせてしまいます。
GLFW_REPEAT(押しっぱなしのキーの自動連打のイベント)は無視します。
「押している」はずっとtrueだからです。
カーソルとリサイズのコールバックには触らないので、window.mouseDelta()とリサイズは今迄通り動きます。

注意する事が2つあります:

  • input.attach(window)の後に自分でwindow.onKeyを設定しないで下さい。Inputにキーが届かなくなります。
  • window.mouseDelta()は更新ごとではなくフレームごと(pollEventsごと)です。マウスで見回す処理は固定の更新ではなく、プログラムのフレームの部分に置きます。でないと更新2回のフレームで同じ移動量が2回使われます。

行動(アクション)

ゲームのコードが至る所でGLFW_KEY_LEFTやGLFW_KEY_Aを尋ねるべきではありません。
尋ねるのは行動で、どのキーやボタンが其の行動になるかはmainが1回だけ決めます:

  // 入力:ウィンドウのコールバックを引き受け、行動に名前を付ける(キーを変えたくなったらここだけ直す)
  // Input: takes over the window's callbacks; actions get names (to change the keys, edit only this)
  Input input;
  input.attach(window);
  input.bind("left", {InputBinding::key(GLFW_KEY_LEFT), InputBinding::key(GLFW_KEY_A)});
  input.bind("right", {InputBinding::key(GLFW_KEY_RIGHT), InputBinding::key(GLFW_KEY_D)});
  input.bind("up", {InputBinding::key(GLFW_KEY_UP), InputBinding::key(GLFW_KEY_W)});
  input.bind("down", {InputBinding::key(GLFW_KEY_DOWN), InputBinding::key(GLFW_KEY_S)});
  input.bind("confirm", {InputBinding::key(GLFW_KEY_SPACE), InputBinding::key(GLFW_KEY_ENTER)});

actionHeldはどれかの割り当てを押していればtrue、actionPressedは此のステップでどれかが押されたらtrue、actionReleasedはどれかを離して、もう何も押していない時にtrueです(Aと←を一緒に押していてAを離しても、「left」を離した事にはなりません)。
axisは2つの行動を−1、0、+1にします。
遊び場は此れで移動を読みます:

// 離した:どれかを離して、もう何も押していない(AとLEFTの両方を押していたら、両方離したとき)
// Released: one binding was released and none is held any more (with both A and LEFT held: when both are up)
bool Input::actionReleased(std::string_view name) const {
  bool any = false;
  if (const Action *a = find(name))
    for (const InputBinding &b : a->bindings) any = any || state(b).released;
  return any && !actionHeld(name);
}

float Input::axis(std::string_view negative, std::string_view positive) const {
  return (actionHeld(positive) ? 1.0f : 0.0f) - (actionHeld(negative) ? 1.0f : 0.0f);
}

遊び場はベクトル(axis("left", "right"), axis("up", "down"))を正規化するので、斜めが1.41倍速くなりません。
キーを変えたり、後でゲームパッドのボタンを足したりしても、変わるのはbindの行だけです。
知らない行動の名前は単にfalseで、探し方は線型探索です。
ゲームの行動は数個で、短い文字列を数個比べる方がハッシュを計算するより安いからです。

26.7 シーン

ゲームは1つの画面ではありません。
タイトル、ゲーム本体、一時停止メニュー、ゲームオーバー、ハイスコア。
全部をmode変数を持つ1つのクラスに入れると、モードが2つなら動きますが、5つになると絡まります。
代わりに、各画面を自分のクラスであるシーンにし、シーンのスタックがどれを動かすかを決めます。

Sceneクラス

class Scene {
public:
  virtual ~Scene() = default;

  virtual void enter() {}  // スタックに載った / was put on the stack
  virtual void exit() {}   // スタックから外される直前 / is about to be removed from the stack
  virtual void pause() {}  // 上に別のシーンが載った / another scene was pushed on top
  virtual void resume() {} // 上のシーンが外れて、また一番上になった / the scene above was popped; on top again
  // 固定ステップの更新(一番上のシーンだけ) / the fixed-step update (top scene only)
  virtual void update(float dt) = 0;
  // 描画:世界(キャンバスなど)とUI(画面の解像度の文字など)の2回。下から上の順に呼ばれる
  // Drawing in two passes: the world (into a canvas, say) and the UI (text at screen resolution, say). Called bottom
  // to top
  virtual void draw(float alpha) = 0;
  virtual void drawUi(float /*alpha*/) {}
  // trueなら下のシーンも描かれる(一時停止のメニューなど、上に重ねるシーン) / true: the scenes below are drawn too
  // (overlays such as a pause menu)
  virtual bool isOverlay() const { return false; }

protected:
  // このシーンを持つマネージャー:scenes().push(…)などで切り替えを頼む / the manager that owns this scene: ask it for
  // changes with scenes().push(...) etc.
  SceneManager &scenes() const { return *owner; }

private:
  friend class SceneManager;
  SceneManager *owner = nullptr;
};

書かなければならないのはupdateとdrawだけで、他のフックは必要な時だけです:

  • enter()はシーンがスタックに載った時、exit()は外される直前に呼ばれます。コンストラクターと違い、enter()は切り替えが本当に起きた時(フェードアウトの後)に呼ばれます。遊び場はコインを其処で置きます。
  • pause()は上に別のシーンが載った時、resume()は其のシーンが外れた時に呼ばれます。
  • update(dt)は一番上のシーンだけが、固定ステップで呼ばれます。
  • draw(alpha)は世界のパス、drawUi(alpha)はUIのパスです(2つのパスは後で)。
  • isOverlay()は、下にある物の一部だけを覆うシーンならtrueを返します。

エンジンはゲームのシーンが何を必要とするか知らないので、Sceneに「コンテキスト」の型はありません。
各ゲームは自分の共有データをシーンのコンストラクターに渡します。
デモにはstruct Demoがあり、ウィンドウ、入力、ループ、バッチ、フォント、スプライトシート、アニメーションのクリップへの参照と、自分の2つのカメラ、UIのビューポート、Rngを持ち、全てのシーンがDemo &を持ちます。

スタックと、切り替えを予約する理由

デモがスタックにする事と、各切り替えで呼ばれるフックです:

左から右へ4つのスタックの状態。Title。0.8秒のフェード付きのreplaceの後のPlaygroundで、Title.exitとPlayground.enterが呼ばれる。pushの後のPlaygroundと其の上のPauseで、Playground.pauseとPause.enterが呼ばれる。replaceAllの後のTitleで、Pause.exit、Playground.exit、Title.enterが呼ばれる。3つ目から2つ目へ戻る点線の矢印がpopで、Pause.exitとPlayground.resumeが呼ばれる

push、pop、replace(一番上を入れ替える)、replaceAll(全部外してから載せる)はスタックを変えません。
頼みを予約するだけで、SceneManager::updateが一番上のシーンの更新から戻った後に実行します:

void SceneManager::update(float dt) {
  if (phase == Phase::Out) {
    // フェードアウト中:誰も更新しない。半分の時間で切り替えてフェードインへ / fading out: no updates. Switch at half
    // time and fade in
    phaseTime += dt;
    if (phaseTime >= 0.5f * current.duration) {
      apply(pending.front());
      pending.erase(pending.begin());
      phase = Phase::In;
      phaseTime = 0.0f;
    }
    return;
  }
  if (phase == Phase::In) {
    phaseTime += dt;
    if (phaseTime >= 0.5f * current.duration) phase = Phase::None;
  }
  if (Scene *s = top()) s->update(dt);
  // 頼まれた切り替え:フェードなしなら今すぐ全部、フェード付きならフェードアウトを始める
  // Requested changes: without a fade apply them now, with a fade start fading out
  while (!pending.empty() && phase == Phase::None) {
    if (pending.front().transition.duration > 0.0f) {
      current = pending.front().transition;
      phase = Phase::Out;
      phaseTime = 0.0f;
      break;
    }
    apply(pending.front());
    pending.erase(pending.begin());
  }
}

理由はタイトル自身の更新にあります:

void TitleScene::update(float dt) {
  time += dt;
  heroAnim.update(dt);
  coinAnim.update(dt);
  heroPrevX = heroX;
  heroX += 40.0f * dt;
  if (heroX > 336.0f) heroPrevX = heroX = -16.0f; // 右から出たら左へ戻す(補間しない) / wrap around (no interpolation)

  // 始める:遊び場と入れ替え、0.8秒のフェード(暗くなって0.4秒で入れ替わり、0.4秒で明るくなる)
  // Start: replace with the playground, with a 0.8 s fade (0.4 s to black, switch, 0.4 s back)
  if (d.input.actionPressed("confirm") || d.input.mousePressed(GLFW_MOUSE_BUTTON_LEFT))
    scenes().replace(std::make_unique<PlaygroundScene>(d), {.duration = 0.8f});
  // スタックが空になればmainが終わらせる / main quits once the stack is empty
  if (d.input.pressed(GLFW_KEY_ESCAPE)) scenes().pop();
}

もしreplaceがタイトルをすぐに消したら、TitleScene::updateがまだ動いている間にTitleSceneのオブジェクトが削除されます。
直ぐ次の行は、消えたオブジェクトのメンバーを通してd.inputを読みます。
此れは未定義動作で、デバッグビルドでは動いてもリリースビルドで落ちる、という事が十分あり得ます。
予約にすれば、シーンが自分の更新の途中で消える事はありません。
予約はフェードの場所にもなります。
頼みは画面が暗くなる迄待ちます。

applyが本当の切り替えをし、決まった順番でフックを呼びます:

void SceneManager::apply(Request &r) {
  auto removeTop = [&] {
    stack.back()->exit();
    stack.pop_back();
  };
  if (r.op == Op::Pop || r.op == Op::Replace) {
    if (!stack.empty()) removeTop();
    if (r.op == Op::Pop && !stack.empty()) stack.back()->resume();
  }
  if (r.op == Op::ReplaceAll)
    while (!stack.empty()) removeTop();
  if (r.scene) {
    if (r.op == Op::Push && !stack.empty()) stack.back()->pause();
    r.scene->owner = this;
    stack.push_back(std::move(r.scene));
    stack.back()->enter();
  }
}

  • push:古い一番上のpause()、次に新しいシーンのenter()
  • pop:一番上のexit()、次に下のシーンのresume()
  • replace:古い一番上のexit()、次に新しいシーンのenter()
  • replaceAll:上から順に全てのシーンのexit()、次に新しいシーンのenter()

スタックも予約も空になったら、ゲームはおしまいです。
デモの更新のラムダは其の時にウィンドウを閉じるので、タイトルでEsc(唯一のシーンのpop())を押すと終了します。

フェード

// 切り替えの演出:duration秒かけてcolorに塗りつぶし(フェードアウト)、切り替えて、元に戻す(フェードイン)。
// duration = 0なら一瞬で切り替える
// A transition: fade to `color` over half of `duration` (fade out), switch, and fade back (fade in).
// duration = 0 switches at once
struct Transition {
  float duration = 0.0f;
  Vec4 color = {0.0f, 0.0f, 0.0f, 1.0f};
};

長さ0.8秒のTransitionは、0.4秒かけて画面を暗くし、切り替え、0.4秒かけて明るくします:

0.8秒の切り替えのfadeAmountの時間のグラフ。頼んだ時に0、0.4秒で直線的に1まで上がり、其処でexitとenterが呼ばれ、0.8秒で0に戻る。フェードアウトの間はどのシーンも更新されず、フェードインの間は新しい一番上のシーンが更新される

フェードアウトの間は誰も更新されないので、古いシーンが更に入力に反応したり、別の切り替えを頼んだりする事はありません。
フェードインの間は、新しい一番上のシーンがもう動いています。
フェードの量は其々の半分で直線です:

float SceneManager::fadeAmount() const {
  if (phase == Phase::None || current.duration <= 0.0f) return 0.0f;
  float t = std::clamp(phaseTime / (0.5f * current.duration), 0.0f, 1.0f);
  return phase == Phase::Out ? t : 1.0f - t;
}

drawFadeは、全部を描いた後で、UI全体をフェードの色 × 其の量で覆います。
フェードの段階は更新のdtで進むので、フェードはゲームの時間で0.8秒かかり、他の処理と同じく決定的です。

出て行くシーンはフェードアウトの間更新されませんが、毎フレーム描かれ続け、ループのアルファも変わり続けます。
其のアルファで描くと、一時停止した遊び場と全く同じ様に震えます。
最後の更新で動いた物が、前の位置と今の位置の間を行ったり来たりするのです。
其処で画面が暗くなる間、マネージャーは全てのシーンをalpha = 1、つまり止まった今の状態で描きます:

float SceneManager::drawAlpha(float alpha) const {
  // フェードアウト中は誰も更新されない:止まった今の状態(alpha = 1)を描く。前と今の間の補間を続けると、
  // alphaが変わるたびに動いていたものが前後に揺れる / during a fade out nobody is updated: draw the frozen current
  // state (alpha = 1). Interpolating on between previous and current would make moving things shuffle back and forth
  // as alpha changes
  return phase == Phase::Out ? 1.0f : alpha;
}

タイトルの主人公は60 Hzでは更新1回で0.67 pxしか動かないので見えませんが、10 Hzでは最大4 pxになります(課題5)。

重ねるシーンと2つの描画パス

一時停止メニューは重ねるシーンです。
画面を暗くしてパネルを描き、遊び場は其の下に見えていなければなりません。
drawとdrawUiは、見える一番下のシーンから上へとスタックを辿ります:

size_t SceneManager::firstVisible() const {
  size_t i = stack.size() - 1;
  while (i > 0 && stack[i]->isOverlay()) --i;
  return i;
}

void SceneManager::draw(float alpha) {
  if (stack.empty()) return;
  for (size_t i = firstVisible(); i < stack.size(); ++i) stack[i]->draw(drawAlpha(alpha));
}

firstVisibleは一番上から始め、上のシーンが重ねるシーンである限り下へ降ります。
最初の重ねないシーンが其れより下を全部隠します。
スタックにPlaygroundとPauseがあれば両方が描かれ、先にPlaygroundです。
更新されるのはPauseだけです。

何故2つのパスなのでしょうか?
世界は320 × 180のPixelCanvasの中のピクセルアートで、表示の時に4倍に拡大されます。
文字やメニューは1280 × 720の解像度其の儘で描くべきで、でないとmono16が4 × 4のブロックになります。
其の為、デモの毎フレームは3つの部分に分かれます:

  loop.run(
      window, input,
      [&](float dt) {
        scenes.update(dt);
        if (scenes.empty()) window.close(); // 最後のシーンが外れたら終わり / quit when the last scene is gone
      },
      [&](float alpha) {
        // 1. 世界:320×180のキャンバスに描き、整数倍で画面へ / 1. the world: into the 320 × 180 canvas, then scaled by
        //    a whole number onto the screen
        canvas.begin(hexColor(0x1b1726ff));
        scenes.draw(alpha);
        canvas.present(window.width(), window.height());
        // 2. UI:1280×720の仮想画面をウィンドウに合わせる(ここでは1倍) / 2. the UI: the 1280 × 720 virtual screen
        //    fitted to the window (1× here)
        demo.uiViewport = letterbox(window.width(), window.height(), demo.screen.viewSize, false);
        demo.uiViewport.apply();
        scenes.drawUi(alpha);
        // 3. フェード(全部の上に) / 3. the fade (on top of everything)
        scenes.drawFade(*batch, demo.screen.matrix(), demo.screen.viewSize);
        // 60フレームごとに1行(frame = 描いたフレームの数、このフレームを含む) / a line every 60 frames (frame = the
        // number of frames drawn, this one included)
        if (++frame % 60 == 30)
          printf("frame %d: %zu scene(s), steps %d, alpha %.2f, fps %.1f\n", frame, scenes.size(),
                 loop.stats().steps, static_cast<double>(loop.stats().alpha), static_cast<double>(loop.stats().fps));
      });

  1. 世界:canvas.begin、見える全てのシーンのdraw(alpha)をキャンバスに、canvas.present。
  2. UI:レターボックスのビューポート(1280 × 720では倍率1、整数には丸めないので、他のウィンドウの大きさでもUIが一杯に広がります)の中のCamera2D::screen(1280 × 720)で、見える全てのシーンのdrawUi(alpha)。
  3. フェード、両方の上に。

UIのビューポートはdemo.uiViewportに取っておきます。
一時停止メニューがマウスの位置をUIの座標に直すのに使うからです。

26.8 AABBの当たり判定

ゲームは2つの物が触れた事を知る必要があります。
弾とエイリアン、主人公と壁、剣とスライム。
殆どの2Dゲームでは軸に平行な箱(AABB)で十分です。
辺が軸に平行な長方形で、正に第25章のRect(x, y = 左上、w, h、y下向き)です。
当たり判定の箱は普通、絵と同じではありません。
遊び場の主人公は16 × 16のスプライトですが、箱は足元の10 × 8なので、隙間を通り抜けられ、木箱のすぐ下に立つと頭が木箱に重なって、木箱の手前に立っている様に見えます。
Bで箱が見えます:

当たり判定の箱の輪郭を描いた遊び場。壁と木箱は青、主人公の足元の小さな箱は緑、丸のこは赤、コインは黄色

重なり

bool overlaps(const Rect &a, const Rect &b) {
  return a.left() < b.right() && b.left() < a.right() && a.top() < b.bottom() && b.top() < a.bottom();
}

bool contains(const Rect &r, Vec2 p) { return p.x >= r.left() && p.x < r.right() && p.y >= r.top() && p.y < r.bottom(); }

2つの箱は、両方の軸で重なっている時に重なります。
比較は厳密なので、接しているだけの箱は重なりません。
此れは後のmoveAndSlideで大事です。
moveAndSlideは主人公を壁に丁度接する所に置くので、接する事を重なりと数えると、次の更新で主人公がまた壁の「中」にいると判定され、壁に沿って滑れなくなります。
containsは左と上の辺を含み、右と下の辺を含まないので、2つのタイルの境目の点は丁度片方だけに属します。

最小移動ベクトル

2つの箱が重なっていたら、普通知りたいのは、一番小さな動きで離す方法です。
最小移動ベクトル(MTV)です。
箱は4つの方向へ相手から抜け出せ、MTVは其の中で一番短い物です:

0, 0、10 × 8の箱aと8, 3、12 × 12の箱bが2 × 5の範囲で重なる。aのMTVは−2, 0で、aはbに接するだけになる。他の出口、右20、上5、下15はもっと長い

std::optional<Vec2> penetration(const Rect &a, const Rect &b) {
  if (!overlaps(a, b)) return std::nullopt;
  // 左右・上下それぞれ、どちらへ押し出すと近いか / for each axis, which way out is shorter
  float pushLeft = b.left() - a.right(), pushRight = b.right() - a.left(); // < 0 と > 0
  float pushUp = b.top() - a.bottom(), pushDown = b.bottom() - a.top();
  float dx = -pushLeft < pushRight ? pushLeft : pushRight;
  float dy = -pushUp < pushDown ? pushUp : pushDown;
  // 浅い方の軸だけで押し出す / push out along the shallower axis only
  if (std::fabs(dx) < std::fabs(dy)) return Vec2{dx, 0.0f};
  return Vec2{0.0f, dy};
}

a = {0, 0, 10, 8}とb = {8, 3, 12, 12}では:

  • 左:pushLeft = 8 − 10 = −2、右:pushRight = 20 − 0 = 20、なのでdx = −2
  • 上:pushUp = 3 − 8 = −5、下:pushDown = 15 − 0 = 15、なのでdy = −5
  • |−2| < |−5|なので、MTVは(−2, 0)

遊び場の丸のこはMTVを使います。
主人公に重なったら、主人公をMTVと更に6 px押し出します。
moveAndSlideを通すので、押されて壁の中に入る事はありません:

  // 丸のこ:左右に往復。主人公に当たったらMTVで押し出す(ただし押し出した先が壁なら戻す)
  // The saw: goes back and forth. When it hits the hero, the hero is pushed out by the MTV (undone if that would put
  // the hero inside a wall)
  sawPrevX = saw.x;
  saw.x += sawDir * 70.0f * dt;
  if (saw.right() > 19.0f * kTile || saw.left() < kTile) sawDir = -sawDir;
  if (std::optional<Vec2> push = penetration(player, saw)) {
    Vec2 knock = *push + normalize(*push) * 6.0f; // 少し余分に弾く / bounce a little further
    moveAndSlide(player, knock, solids);
    if (hurt <= 0.0f) ++hits;
    hurt = 0.5f;
  }
  hurt = std::max(0.0f, hurt - dt);

MTVには弱点があります。
箱が今どこにあるかしか見ないのです。
速い箱が薄い箱を半分以上通り過ぎていたら、一番短い出口は向こう側で、MTVは其れを向こうへ押し出してしまいます。

掃引テスト

掃引テストは、もっと良い質問に答えます。
箱movingがΔだけ動く間にtargetに当たるか、当たるなら何時か、です。
コツはtargetをmovingの大きさだけ太らせる事です(ミンコフスキー和:target.x − moving.w、target.y − moving.h、target.w + moving.w、target.h + moving.h)。
すると「動く箱が相手に触れる」は「動く箱の左上の角が太らせた箱の中にある」になり、箱のテストがレイのテストになります。
角は𝐩から𝐩+Δへ動きます。

0, 0、4 × 4の動く箱が16, 8だけ動いて12, 2、6 × 10のtargetに向かう。動く箱の大きさだけ太らせたtargetは8, −2、10 × 14。左上の角の通り道はt = 0.5、8, 4で太らせた箱に入り、其処で動く箱はtargetの左の面に法線−1, 0で接する。判定が無ければ、箱はt = 1でtargetの中で止まる

軸ごとに、レイは太らせた箱のスラブ(其の軸での2つの辺の間)の中に、入る時間から出る時間までいます。
t=(side−p)/dです。
レイが箱の中にあるのは両方のスラブの中にある時なので、入るのは遅い方の入る時間、出るのは早い方の出る時間です(スラブ法):

  • x:t=(8−0)/16=0.5からt=(18−0)/16=1.125まで
  • y:t=(−2−0)/8=−0.25からt=(12−0)/8=1.5まで
  • 入るmax(0.5,−0.25)=0.5、出るmin(1.125,1.5)=1.125。入る < 出るで、0≤0.5≤1なので、移動の半分で当たります

最後に入った軸が当たった面です。
此処ではxで右へ動いているので、法線は(−1, 0)、targetの左の面です。
入る時間は出る時間より厳密に前でなければなりません。
等しい時、角は太らせた箱の角をかすめるだけです(動く箱が相手の横を斜めに通り、1点で触れる)。
overlapsと同じく、接するだけでは当たりではありません。

std::optional<SweepHit> sweep(const Rect &moving, Vec2 delta, const Rect &target) {
  if (overlaps(moving, target)) return SweepHit{0.0f, {0.0f, 0.0f}};
  // targetをmovingの大きさだけ太らせると(ミンコフスキー和)、movingの左上の点が動く線分と箱の交差になる
  // Growing target by moving's size (a Minkowski sum) turns this into a ray (moving's top-left point) against a box
  Rect grown = {target.x - moving.w, target.y - moving.h, target.w + moving.w, target.h + moving.h};
  constexpr float kInf = std::numeric_limits<float>::infinity();
  float enter = -kInf, leave = kInf;
  Vec2 normal;
  // スラブ法:軸ごとに入る時間と出る時間 / the slab method: entry and exit time per axis
  for (int axis = 0; axis < 2; ++axis) {
    float p = axis == 0 ? moving.x : moving.y, d = axis == 0 ? delta.x : delta.y;
    float lo = axis == 0 ? grown.left() : grown.top(), hi = axis == 0 ? grown.right() : grown.bottom();
    if (d == 0.0f) {
      if (p <= lo || p >= hi) return std::nullopt; // この軸で一度も重ならない / never overlaps on this axis
      continue;
    }
    float t0 = (lo - p) / d, t1 = (hi - p) / d;
    if (t0 > t1) std::swap(t0, t1);
    if (t0 > enter) {
      enter = t0;
      normal = axis == 0 ? Vec2{d > 0.0f ? -1.0f : 1.0f, 0.0f} : Vec2{0.0f, d > 0.0f ? -1.0f : 1.0f};
    }
    leave = std::min(leave, t1);
  }
  // enter == leaveは角をかすめるだけ(接するが重ならない):overlapsと同じく当たりではない
  // enter == leave only grazes a corner (touching, never overlapping): like overlaps, not a hit
  if (enter >= leave || enter < 0.0f || enter > 1.0f) return std::nullopt;
  return SweepHit{enter, normal};
}

ある軸の移動が0なら入る時間がありません。
其の場合、角はずっと其のスラブの厳密に内側に居なければ当たりません。
「厳密に」は此処でも、接している面に沿って滑るのは当たりではない、という意味です。
最初から重なっている箱は時間0、法線0を返します。
掃引テストは抜け出し方を教えられません(其れはMTVの仕事です)。

moveAndSlide

歩くキャラクターには、何かがとても速くない限り十分な、もっと簡単な道具がエンジンにあります。
軸を1つずつ動かし、其の軸で押し戻すのです。

3つの図。最初:x 10から14の壁の左にある2, 2、4 × 4の箱が6, 6動こうとしていて、其の儘では壁の中で止まる。1:xに6動かすと壁に重なるので、x = 6に戻してhitRightを立てる。2:yに6動かすと何も無いので、箱は6, 8で止まる。壁に沿って下へ滑った

MoveResult moveAndSlide(Rect &box, Vec2 delta, std::span<const Rect> solids) {
  MoveResult result;
  // x:動いてから、重なった固い箱の手前に戻す / x: move, then back out of every solid it now overlaps
  box.x += delta.x;
  for (const Rect &s : solids) {
    if (!overlaps(box, s)) continue;
    if (delta.x > 0.0f) {
      box.x = s.left() - box.w;
      result.hitRight = true;
    } else if (delta.x < 0.0f) {
      box.x = s.right();
      result.hitLeft = true;
    }
    result.hitX = true;
  }
  // y:同じように(y下向き:正 = 下へ、下で当たる = 地面に立った) / y: the same (y down: positive = downwards; hitting
  // below = standing on the ground)
  box.y += delta.y;
  for (const Rect &s : solids) {
    if (!overlaps(box, s)) continue;
    if (delta.y > 0.0f) {
      box.y = s.top() - box.h;
      result.hitBottom = true;
    } else if (delta.y < 0.0f) {
      box.y = s.bottom();
      result.hitTop = true;
    }
    result.hitY = true;
  }
  return result;
}

軸を別々に扱うので、壁への斜めの移動は壁に沿った部分が残ります。
箱が滑るのです。
線型代数シリーズの第4章の壁に沿って滑る射影𝐯−(𝐯⋅𝐧^)𝐧^の軸に平行な場合で、壁の法線は(±1, 0)か(0, ±1)、射影は成分を1つ0にするだけです。
結果はどの辺が触れたかを教えます。
y下向きの世界でhitBottomは「何かの上に着地した」で、格闘ゲームはジャンプが終わったかを知るのに此れを使います。

moveAndSlideは各軸の移動の終わりの位置しか調べないので、すり抜ける事があります。
1回の更新で自分の幅 + 壁の厚さより遠くへ動く箱は、丸ごと向こう側に出てしまう事があるのです。
遊び場の主人公は更新1回で1.5 px(60 Hzで毎秒90 px)、10 Hzで9 px動きますが、木箱を抜けるには10 + 16 = 26 px要るので安全です。
弾は安全ではありません。
弾にはsweepを使うか、長い移動を何回かの短い移動に分けます。

26.9 乱数

ゲームは至る所で乱数を使います。
コインが何処に出るか、どのエイリアンが撃つか、紙吹雪がどう飛ぶか。
でも再現出来る必要があります。
同じ種なら同じゲームになるべきです。
リプレイの為、バグの報告の為(「種1234で落ちる」)、そして此のチュートリアルの為です。
スクリーンショットと動画は台本通りに動かして作るので、毎回同じに見えなければなりません。

C++の<random>に部品はありますが、一つ落とし穴があります。
規格はエンジンを厳密に決めています。
32ビットのメルセンヌ・ツイスターstd::mt19937は、どのコンパイラでも同じ数を出し、規格は既定のコンストラクターで作ったstd::mt19937の10 000番目の数が4 123 659 995である事まで書いています。
分布(std::uniform_int_distribution、std::uniform_real_distribution、std::normal_distribution等)は、結果が従うべき分布だけが決まっていて、其れを作るアルゴリズムは決まっていません。
GCCのlibstdc++、Clangのlibc++(FreeBSDの既定)、MicrosoftのSTLは其々自分のアルゴリズムを使うので、同じエンジンに同じ種でも、Windows、Linux、FreeBSDで違う数が出る事があります。
std::shuffleにも同じ問題があります。
其の為Rngは、ビットにはstd::mt19937を包んで使い、範囲への変換は自分でします:

// std::mt19937の出す数は規格で決まっている(どのコンパイラでも同じ)。でもstd::uniform_int_distributionなどの
// 分布は実装ごとに違う:同じ種でもMSVCとGCCで別の結果になる。リプレイやテストのために、範囲への変換は自分で書く
// The numbers std::mt19937 produces are fixed by the standard (identical with every compiler), but distributions
// such as std::uniform_int_distribution differ per implementation: the same seed gives different results with MSVC
// and GCC. For replays and tests we write the mapping to ranges ourselves
class Rng {
public:
  explicit Rng(std::uint32_t seed = 1) : engine(seed) {}
  void seed(std::uint32_t s) { engine.seed(s); }

  std::uint32_t next() { return static_cast<std::uint32_t>(engine()); } // 32ビット / 32 bits
  // [0, 1):上の24ビットだけ使う(floatの仮数に収まる) / [0, 1): uses the top 24 bits (they fit a float's mantissa)
  float unit() { return static_cast<float>(next() >> 8) * (1.0f / 16777216.0f); }
  // [lo, hi)。丸めでhiちょうどになることがある(例:range(100, 101)でunit()が1に近いとき)ので、そのときはhiの一つ手前の
  // float / [lo, hi). Rounding can land exactly on hi (e.g. range(100, 101) with unit() close to 1): then it returns
  // the float just below hi
  float range(float lo, float hi) {
    float r = lo + (hi - lo) * unit();
    return r >= hi && hi > lo ? std::nextafter(hi, lo) : r;
  }
  // [lo, hi](両端を含む)。棄却法で偏りなし / [lo, hi] (both included). Unbiased, by rejection
  int range(int lo, int hi);
  // 確率pでtrue / true with probability p
  bool chance(float p) { return unit() < p; }
  // 長さ1のランダムな向き / a random direction of length 1
  Vec2 direction();

  // 配列から一つ選ぶ(空でないこと) / picks one element (the span must not be empty)
  template <typename T>
  const T &pick(std::span<const T> items) {
    return items[static_cast<size_t>(range(0, static_cast<int>(items.size()) - 1))];
  }

  std::mt19937 &raw() { return engine; } // std::shuffleなどに / for std::shuffle and friends

private:
  std::mt19937 engine;
};

unit()は上の24ビットを取って224で割ります。
floatの仮数は24ビットなので、どの結果も正確で、一番大きいのは1−2−24、決して1にはなりません。
其れでもfloatの範囲は丸めでhiになる事があります。
range(100, 101)では、100+(1−2−24)は他のどのfloatより101に近いので(100の辺りのfloatの間隔は2−17です)、101が2−18の確率、約26万回に1回出ていました。
其の時はhiの一つ手前のfloat(std::nextafter)を返し、[lo,hi)の約束を守ります。
面白いのは整数の範囲です:

int Rng::range(int lo, int hi) {
  if (hi < lo) std::swap(lo, hi);
  // 幅n。2^32をnで割った余りの分だけ大きい数を捨てると、どの値も同じ確率になる(% nだけだと小さい値が少し多い)
  // Width n. Throwing away the top (2^32 mod n) values makes every result equally likely (plain % n slightly favors
  // small values)
  std::uint64_t n = static_cast<std::uint64_t>(static_cast<std::int64_t>(hi) - lo) + 1;
  std::uint64_t limit = (std::uint64_t{1} << 32) - ((std::uint64_t{1} << 32) % n);
  std::uint64_t x;
  do x = next();
  while (x >= limit);
  return static_cast<int>(static_cast<std::int64_t>(lo) + static_cast<std::int64_t>(x % n));
}

next() % nだけだと、232がnの倍数でない時は偏ります。
n=6なら影響はほんの僅か(232 mod 6=4なので、43億の値のうち4つが小さい結果を贔屓します)ですが、n=3⋅230ならnより上の1 073 741 824個の値が結果の下の3分の1に折り返され、其処が残りの2倍出易くなります。
limit(入る中で一番大きいnの倍数)以上の値を全て捨てれば、全ての結果が同じ確率になります。
n=6なら捨てるのは4 294 967 296回に4回で、一番悪い場合でも捨てるのは半分未満です。

range(0, 5)は整数版、range(0.0f, 5.0f)はfloat版を呼び、range(0, 5.0f)はどちらも合わないのでコンパイル出来ない事に注意して下さい。
其れで良いのです。
どちらを使うかをはっきり書く事になります。
direction()はstd::cosとstd::sinを使い、其の最後のビットはCライブラリによって違う事があります。
紙吹雪なら問題ありませんが、プラットフォームを跨いでビット単位で同じリプレイが要るなら、浮動小数点の数学関数をゲームの状態に入れないで下さい(コンパイラを跨いだ浮動小数点の決定性は其れだけで一つの話題です)。
シェーダーの中の乱数は別の道具で、数の並びではなくピクセルの位置のハッシュです。
其方はGLSLシリーズで扱っています。

デモは1つのRngを26で初期化している(struct Demoの中)ので、コインは毎回同じタイルに出ます:

// 空いているタイルの真ん中にコインを置く(乱数、種26なので毎回同じ並び) / puts a coin in the middle of a free tile
// (random, seed 26: the same sequence on every run)
void PlaygroundScene::placeCoin(Coin &coin) {
  for (int tries = 0; tries < 100; ++tries) {
    int col = d.rng.range(1, 18), row = d.rng.range(1, 9);
    Rect cell = {kTile * static_cast<float>(col), kTile * static_cast<float>(row), kTile, kTile};
    if (blocked(cell)) continue;
    coin = {cell.centre(), d.rng.unit()};
    return;
  }
}

26.10 デモ

6つの部品が揃えば、3つのシーンは短く書けます。

遊び場

遊び場。レンガの壁と石の床の部屋に木箱、コイン、丸のこ。拾ったばかりのコインの隣に主人公、紙吹雪と+1。上のバーにFPS 60、steps/frame 1、alpha 0.00、update 60 Hz、interpolation on、右にcoins 1とhits 0

部屋は文字列の配列(#が壁、Cが木箱)から作る20 × 11タイルで、コンストラクターで固いRectの一覧1つにします。
主人公は其の一覧に対してmoveAndSlideで毎秒90 px動きます。
丸のこは9行目を毎秒70 pxで往復し、MTVで主人公を押しのけ、当たった回数を数えて0.5秒赤く点滅させます。
5枚のコインは空いているランダムなタイルにあります。
1枚拾う(箱の重なり)と1点増え、ランダムな向き、毎秒30〜90 pxの速さ、0.3〜0.7秒の寿命で重力で落ちる16個の紙吹雪と、上へ浮かぶpixel12の「+1」を出し、コインを別の空いたタイルへ移します:

  // コイン:重なったら拾う。紙吹雪(乱数の向きと速さ)と「+1」を出し、別の場所に置き直す
  // Coins: collected on overlap. Confetti (random directions and speeds) and a "+1", then the coin moves elsewhere
  for (Coin &c : coins) {
    Rect box = Rect::fromCentre(c.position, {10.0f, 10.0f});
    if (!overlaps(player, box)) continue;
    ++collected;
    for (int i = 0; i < 16; ++i) {
      Vec4 color = d.rng.chance(0.5f) ? hexColor(0xf2c14eff) : hexColor(0xffec96ff);
      particles.push_back({c.position, d.rng.direction() * d.rng.range(30.0f, 90.0f), d.rng.range(0.3f, 0.7f), color});
    }
    popups.push_back({c.position - Vec2{0.0f, 8.0f}, 0.8f});
    placeCoin(c);
  }

上のHUDはループの統計を表示します。
毎秒のフレーム数、前のフレームの更新の回数、アルファ、更新の速さ、補間がオンかどうかです。
固定ステップの働きを見るのに一番良い方法です。
Uで10 Hzにすると、60 Hzの画面ではフレームごとの更新が1、0、0、0、0、0となり、アルファは0.00、0.17 … 0.83と上がります。

一時停止メニュー

一時停止の重ねるシーン。背景には暗くなった遊び場と止まった紙吹雪、金色の縁の暗いパネルに一時停止 / PAUSEDと、再開 / Resumeとタイトルへ / Back to titleの2つの項目。2つ目が金色で強調されている

PauseSceneは世界を全く描かない重ねるシーンです。
0.25秒かけて自分で暗くなり(マネージャーのフェードではなく、自分の演出です)、drawUiでパネルを描きます:

void PauseScene::update(float dt) {
  time += dt;
  Input &in = d.input;
  // マウス:ウィンドウの座標 → UIの座標(レターボックスの位置と倍率) / the mouse: window → UI coordinates (the
  // letterbox's offset and scale)
  Vec2 mouse = d.screen.toWorld(d.uiViewport.toView(in.mousePosition()));
  bool choose = false;
  for (int i = 0; i < 2; ++i)
    if (contains(itemRect(i), mouse) && in.mousePressed(GLFW_MOUSE_BUTTON_LEFT)) {
      selected = i;
      choose = true;
    }
  if (!choose) {
    if (in.actionPressed("up")) selected = std::max(0, selected - 1);
    if (in.actionPressed("down")) selected = std::min(1, selected + 1);
    if (in.pressed(GLFW_KEY_ESCAPE) || in.pressed(GLFW_KEY_P)) {
      scenes().pop(); // すぐに戻る(フェードなし) / back at once (no fade)
      return;
    }
    choose = in.actionPressed("confirm");
  }
  if (!choose) return;
  if (selected == 0) scenes().pop();
  // 全部外してタイトルだけに。フェード付き / clear everything and leave only the title, with a fade
  else scenes().replaceAll(std::make_unique<TitleScene>(d), {.duration = 0.8f});
}

マウスは2段階でウィンドウのピクセルからUIの座標になります。
Viewport::toViewがレターボックスのずれと倍率を取り除き、Camera2D::toWorldがビューの点をUIの世界にします(Camera2D::screenでは同じ物です)。
「再開」はフェード無しのpop()、「タイトルへ」はフェード付きのreplaceAllで、一時停止メニューを出て、遊び場を出て、新しいタイトルに入ります。
此の順番です。

動かす

第25章と同じく、プロジェクトのルートからビルドして実行します:

cmake -S . -B build
cmake --build build -j8
./build/game

Windowsではソリューションを開き、gameをスタートアッププロジェクトにした儘F5を押します(作業ディレクトリは既にプロジェクトのルートです)。
デモは60フレームごとに1行と、遊び場が再開した時に1行を出します。
ゲームを始め、100フレーム目辺りで一時停止し、130フレーム目で再開するとこうなります:

frame 30: 1 scene(s), steps 1, alpha 0.00, fps 0.0
frame 90: 1 scene(s), steps 1, alpha 0.00, fps 60.0
playground: resumed
frame 150: 1 scene(s), steps 1, alpha 0.00, fps 60.0
frame 210: 1 scene(s), steps 1, alpha 0.00, fps 60.0

最初のfpsが0.0なのは、0.5秒の間で測るのに、最初の0.5秒がまだ終わっていないからです。
本物の画面では数はモニターによります。
144 Hzのモニターなら約144 fpsで、更新は0と1を行き来し、アルファは毎フレーム変わります。
「character not in the font」の行は1つも出てはいけません。

26.11 プラットフォームごとの注意

  • Windows(Visual Studio): MSVCは、/utf-8を与えられない限り、BOMの無いソースファイルをシステムのコードページで読み、文字列のリテラルを其のコードページに変換します。あたし達のソースはBOM無しのUTF-8で、日本語の文字列はUTF-8のバイトの儘Font::drawに届かなければなりません。第1章から、あたし達のCMakeLists.txtはenable_warningsで/W4の隣に/utf-8を渡しているので、其の儘で動きます。自分でプロジェクトを作る場合は、其処にも足して下さい。
  • Windows: ウィンドウをドラッグしたりリサイズしたりすると、ループはpollEventsの中で止まります。手を離すと、次のフレームは長くなります。maxFrameがある理由の一つで、ゲームは其の時間を早送りせずに飛ばします。
  • FreeBSD: 既定のコンパイラと標準ライブラリはClangとlibc++なので、同じ種でもstd::uniform_int_distributionはLinuxのGCCのlibstdc++と違う数を出します。Rngは3つのプラットフォームで同じ数を出します。
  • Linux、FreeBSD、Windows: アトラスは出来上がったPNGと.fntなので、フォントをインストールしなくても、どのプラットフォームでも同じ様に動きます。BMFontやHieroで自分のアトラスを作る時、DejaVuとNotoのフォントは、Debianでは/usr/share/fonts/truetype/dejavu/と/usr/share/fonts/opentype/noto/に、FreeBSDのportsでは/usr/local/share/fonts/の下に入ります。Windowsにはどちらのフォントも無いので、其々のプロジェクトからダウンロードして下さい。
  • 全て: GLFWのキーコードは、USキーボードでの位置でキーに名前を付けています。フランスのAZERTYキーボードでは、W、A、S、DはZ、Q、S、Dと書かれたキーです。手の下では同じ場所なので移動には其れが正しいのですが、画面の説明には実際の配列の文字を出すべきです(glfwGetKeyName)。名前を付けた行動なら、変えるのは1か所です。

26.12 本物のエンジンではどうしているか

  • 文字: 殆どのエンジンは、TrueTypeやOpenTypeのフォントから実行時にFreeTypeやstb_truetypeで文字を描き、文字のキャッシュのテクスチャに初めて使う時に足していきます。なので決まった一部の漢字ではなく、どの漢字でも使えます(課題7)。どの大きさでもくっきりしていなければならない文字には符号付き距離場のアトラス(SDFや多チャンネルのMSDF、msdfgenの様なツールで作ります)を使い、シェーダーが距離をくっきりした縁にします。複雑な文字体系の言語には、文字列を合字やカーニング付きで並べた文字にするHarfBuzzの様なシェーピングエンジンが要ります。等幅の英語と日本語なら、あたし達の文字ごとの送り幅で十分です。
  • ゲームループ: Unityは物理をFixedUpdate(既定で0.02秒ごと)で、描画をUpdateで動かし、剛体には補間のオプションがあります。Godotには_processの隣に_physics_process(既定で毎秒60回)があり、最近の版は物理のオブジェクトを補間出来ます。Unrealはフレームの時間で動き、物理を細かいステップに分けられます。構造は此の章と同じです。
  • 入力: どこでもアクションマップです。UnityのInput System、GodotのInputMap、UnrealのEnhanced Inputは、キー、ボタン、スティックを名前の付いた行動に割り当て、プレイヤーが割り当てを変えられます。
  • シーン: Godotのシーンツリー、追加読み込みの出来るUnityのシーンマネージャー、そしてRobert Nystromの『Game Programming Patterns』にある「プッシュダウン・オートマトン」(状態のスタック)。エンジンはフェードの間に次のシーンを裏で読み込みもしますが、あたし達の小さなデモには要りません。
  • 当たり判定: 先ずブロードフェーズ(一様な格子、スイープ・アンド・プルーン、バウンディングボリューム階層)が触れているかもしれない組を見つけ、何千もの物の全ての組を調べずに済ませます。其の後ナローフェーズがあたし達の様なテストをします。Box2Dの様な物理ライブラリは速い物体の為に連続的な当たり判定(衝突時刻)を足します。あたし達の掃引テストの一般的な形です。
  • 乱数: 多くのエンジンは、PCGやxoshiroの様な小さくて速い生成器と自分の変換を使います(GodotのRandomNumberGeneratorはPCG32)。あたし達のRngと同じく、どの環境でも同じ結果にする為です。

26.13 パート5の振り返りと、此の先

パート5は2章で、2つ合わせて描画のクラスの集まりを小さなゲームエンジンにしました:

  • 第25章:engineライブラリとプロジェクトの構成、レターボックス付きのCamera2D、PixelCanvas、並べ替えと2つの送り方を持つSpriteBatch、スプライトシート、アニメーション、ピクセルアートの決まり。
  • 此の章:UTF-8と日本語の付いたビットマップフォント、補間付きの固定ステップのループ、行動付きの更新ステップごとの入力、フェードと重ねるシーンを持つシーンのスタック、AABBの当たり判定、どの環境でも同じRng。

パート6では、其の全てを使って4つのゲームを作ります。
各ゲームは自分のフォルダgames/<名前>/にある自分の実行ファイルで、自分のCMakeLists.txt、ソース、シェーダー、生成したアートを持ち、engineをリンクします。
トップのCMakeLists.txtはもう其れらを探しています:

# ゲーム(第27章から):games/<名前>/CMakeLists.txt があれば加える。各ゲームは自分の実行ファイル
# The games (from chapter 27): added when games/<name>/CMakeLists.txt exists. Each game is its own executable
foreach(name invaders fighter rpg tps)
  if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/games/${name}/CMakeLists.txt")
    add_subdirectory(games/${name})
  endif()
endforeach()

なので、ゲームのフォルダは出来た瞬間にビルドに現れ、ゲームの章は自分のフォルダの外を何も変えません。
エンジンの変更も、共有のassets/の変更もありません。
LinuxとFreeBSDでは、ゲームはプロジェクトのルートから./build/games/invaders/invadersの様に動かします。
Visual Studioではスタートアッププロジェクトが1つ増えるだけです。

  • スペースインベーダー、第27〜29章:プレイヤーの宇宙船、インスタンシングで描くエイリアンの隊列と其の行進。次に弾、AABBの当たり判定、削れていくトーチカ、爆発。そして得点、残機、HUDの文字、タイトルとゲームオーバーのシーン、面、仕上げ。
  • 2D格闘ゲーム、第30〜32章:2Dの物理と2人のプレイヤーの入力を持つ格闘家の状態機械。攻撃判定と食らい判定の付いた攻撃、ヒット硬直、体力ゲージ。視差の付いたスクロールするステージ、AIの相手、ラウンド。
  • トップダウンRPG、第33〜35章:タイルマップ、固いタイルに対する移動と当たり判定、追いかけるカメラ。扉とフェードで繋がる複数のマップ。NPC、会話の箱(自分のフォントアトラス付き)、アイテム、小さなクエスト。
  • TPS、第36〜39章:パート4のPBRのレンダラー、影、ポストプロセスで3Dに戻り、キャラクターと周りを回るカメラ。3Dの当たり判定、重力、壁に沿って滑る事。レイキャストの射撃と敵。そして最後にHUD、ゲームの流れ、SlangとVulkanのシリーズへ向かう次のステップ。

26.14 まとめ

  • ビットマップフォント: フォントアトラスは全ての文字の絵を持ち、BMFontのテキストファイル(common lineHeight base、page file、char id x y width height xoffset yoffset xadvance)が其々の場所と置き方を示します。FontはSpriteBatchで1文字にスプライトを1枚描き、TextStyleで色、倍率、行ごとの揃え、レイヤー、影、ピクセルへのスナップを決め、measureで配置を決めます。
  • 入れたフォント: mono16(16 pxのアンチエイリアス、512²)とpixel12(12 pxの1ビット、512 × 256)は其々554文字で、DejaVu Sans MonoのASCIIと、Noto Sans CJK JPのかな、記号、ゲームのUIの252の漢字です。pixel5は3 × 5です。短いUIの文字は2か国語、詰まったHUDは英語。もっと漢字が要るゲームは自分のフォルダに自分のアトラスを作ります。アトラスにはBitstream VeraとSIL OFL 1.1の表示が付いています。
  • UTF-8: 先頭のバイトが長さを示し(0xxxxxxx、110xxxxx、1110xxxx、11110xxx)、続きのバイトは10xxxxxx。壊れた入力はU+FFFDになります。無い文字は?で描かれ、1回だけ報告されます。
  • 固定ステップ: フレームの時間を貯金に足し、続く限り丁度stepの更新を実行し、残りをステップの割合にした物がアルファです。ゲームは決定的になり、物理は安定します。maxSteps(5)が死のスパイラルを防ぎ、maxFrame(0.25秒)が長いフレームを抑え、snapTolerance(0.2 ms)がステップの整数倍に近いフレームの時間をそろえ、丸めの誤差を吸収します。此れで1/30秒のフレームで1フレーム遅れていた更新が直りました。
  • 補間: lerp(previous, current, alpha)で描きます。どの画面の速さでも滑らかで、最大1ステップ遅れます。一時停止したシーンはpause()で前 = 今にしないと震えます。
  • 入力: pressedとreleasedはコールバックで覚え、更新ごとのendStep()で消すので、丁度1回の更新でtrueです。名前を付けた行動とaxisで、キーの選択は1か所にまとまります。マウスの移動量はフレームごとです。
  • シーン: Sceneのスタック。push、pop、replace、replaceAllは予約され、更新の後に実行されるので、シーンが自分の更新の途中で消える事はありません。フックは決まった順番で呼ばれ、フェードは半分の時間で切り替わり、フェードアウトの間はシーンをalpha 1で止めて描き、重ねるシーンは下のシーンも描かせます。drawはキャンバスへの世界のパス、drawUiは画面の解像度のUIのパスです。
  • 当たり判定: 厳密なAABBの重なり、浅い方の軸のMTV、ミンコフスキー和で太らせた箱とスラブ法の掃引テスト、壁に沿って滑るmoveAndSlide(x、次にy)。すり抜けに注意。
  • Rng: std::mt19937はどこでも同じですが、std::uniform_*_distributionは違います。Rngはビットから範囲への変換を自分でし、整数は棄却法で偏りを無くします。種は必ず自分で決めます。

26.15 課題

  1. ★ スペースとKに割り当てた「jump」の行動を足し(input.bind("jump", …))、PlaygroundScene::updateでactionPressed("jump")がtrueの時に1行出して下さい。1フレームより短く押しても、1回押すごとに丁度1行出て、押しっぱなしでは1回しか出ないはずです。
  2. ★ ループを.maxSteps = 1で作り、毎フレームが約0.1秒かかる様にして下さい(描画のラムダの最後でstd::this_thread::sleep_forで100 ms眠るか、テスト環境でSHIM_DT=0.1で動かします)。HUDはフレームごとに更新1回を表示し、主人公はフレームごとに約1.5 px、毎秒90 pxではなく約15 pxで動くはずです。ゲームは実時間の6分の1で動きます。既定のmaxSteps = 5なら、フレームごとに更新5回、毎秒約75 px(実時間の5/6)になるはずです。
  3. ★ タイトルのdrawUiで、"PAUSED\nPress P"をmono16、倍率2、TextAlign::Centreで(640, 500)に描き、其の後ろにmeasure("PAUSED\nPress P", 2.0f)の大きさの長方形を、左端を640から幅の半分を引いた所にして描いて下さい。長方形は140 × 80(長い方の行が7文字 × 10 px × 2、2行 × 20 px × 2)になり、各行は其々中央に揃い、「PAUSED」(120 px)は箱の両側から10 px内側になるはずです。
  4. ★★ PauseScene::isOverlay()がfalseを返す様にして下さい。遊び場と其のHUDのバーはメニューの後ろで消え、キャンバスの暗いクリアの色、暗くする幕、パネルだけが残るはずです。其れ以外は何も変わりません。一時停止の間、遊び場はどの道更新されていなかったからです。
  5. ★★ drawAlphaが防いでいる震えを見える様にして下さい。alphaを其の儘返す様にし、遊び場を始め、U(10 Hz)を押し、一時停止して「タイトルへ」を選び、タイトルでスペースを押します。0.4秒のフェードアウトの間、主人公は最大4 px(毎秒40 px × 0.1秒)前後に揺れるはずです。タイトルは更新されないのに、アルファは回り続けるからです。次に、ゲームの側で直して下さい。TitleScene::updateで、切り替えを頼む時にheroPrevX = heroXにします。元のdrawAlphaの時と同じ様に、画面が暗くなる間、主人公は止まって立っているはずです。
  6. ★★ すり抜け:kSpeedを毎秒400 pxにし、Uで10 Hzにして、8行目の1つだけの木箱に左から、色々な距離から何度か歩いて行って下さい。主人公は時々木箱を真っ直ぐ通り抜け(更新1回で40 pxは、必要な10 + 16 = 26 pxより多いです)、時には外の壁さえ抜けて出て行くはずです。次に、主人公のxの部分を全ての固い箱に対するsweepで動かし(一番早い当たりを使い、delta × timeだけ動かします)、其の後でyの部分をmoveAndSlideに任せて下さい。主人公は必ず木箱の面で止まる様になるはずです。
  7. ★★★ 実行時に文字を描く:stb_image.hの隣にstb_truetype.hを足し、Noto Sans CJK JPのフォントファイル(又は日本語のTTFなら何でも)を読み込み、Fontに、無い文字をstbtt_MakeCodepointBitmapで512 × 512のテクスチャの次の空いた場所に描き(glTextureSubImage2Dで送ります)、マップに足すモードを付けて下さい。「竜が雪山に現れた」の様に一部に含まれない漢字の文字列が、?も「character not in the font」の警告も無く描けるはずで、送るのは新しい文字を初めて使うフレームだけのはずです。

DIFFをダウンロード

プロジェクトをダウンロード(ZIP)

ファイル: a/CMakeLists.txt | b/CMakeLists.txt

前新
@@ -44,7 +44,11 @@ endfunction()
44 add_subdirectory(engine) 44 add_subdirectory(engine)
45   45  
46 # この章のデモ / this chapter's demo 46 # この章のデモ / this chapter's demo
47 add_executable(game demo/main.cc) 47 add_executable(game
    48 demo/main.cc
    49 demo/title_scene.cc
    50 demo/playground_scene.cc
    51 demo/pause_scene.cc)
48 target_link_libraries(game PRIVATE engine) 52 target_link_libraries(game PRIVATE engine)
49 enable_warnings(game) 53 enable_warnings(game)
50 set_working_directory(game) 54 set_working_directory(game)

ファイル: a/assets/LICENSE.txt | b/assets/LICENSE.txt

前新
@@ -20,5 +20,173 @@ models/barrel.glb 樽(PBRのテクスチャ付き) / a barrel wit
20 textures/leaves.png 葉(アルファ付き) / leaves with alpha (chapter 23) 20 textures/leaves.png 葉(アルファ付き) / leaves with alpha (chapter 23)
21 sprites/hero.png ピクセルアートの主人公(16×16、7コマ) / pixel-art hero (16×16, 7 frames) (chapter 25) 21 sprites/hero.png ピクセルアートの主人公(16×16、7コマ) / pixel-art hero (16×16, 7 frames) (chapter 25)
22 sprites/objects.png/.atlas タイル・コイン・宝石・スライムなど / tiles, coins, gems, slime... (chapter 25) 22 sprites/objects.png/.atlas タイル・コイン・宝石・スライムなど / tiles, coins, gems, slime... (chapter 25)
23 sprites/objects_nopad.* 隙間なしのタイル(にじみの例) / tiles without gaps (the bleeding example) (chapter 25) 23 fonts/pixfont.png, pixel5.fnt 3×5のピクセルフォント / a 3×5 pixel font (chapters 25-26)
24 sprites/pixfont.png 3×5のピクセルフォント / a 3×5 pixel font (chapter 25) 24 fonts/mono16.png/.fnt ビットマップフォント16 px(アンチエイリアス) / bitmap font, 16 px, antialiased (chapter 26)
    25 fonts/pixel12.png/.fnt ビットマップフォント12 px(1ビット、ピクセルアート用) / bitmap font, 12 px, 1-bit, for pixel art (chapter 26)
    26  
    27 フォントの画像(fonts/mono16.png、fonts/pixel12.png)について / About the font images (fonts/mono16.png, fonts/pixel12.png):
    28 これらは次の2つのフォントから文字を画像にしたもの(フォントのファイル自体は含まない) / they contain glyph images
    29 rasterized from the two fonts below (the font files themselves are not included):
    30 * ASCIIの文字と×・÷ / the ASCII characters and × ÷: DejaVu Sans Mono 2.37 (https://dejavu-fonts.github.io/),
    31 under the Bitstream Vera Fonts license (full notice 1 below).
    32 * 日本語の文字(かな・カナ・記号・漢字の一部) / the Japanese characters (kana, punctuation and a kanji subset):
    33 Noto Sans CJK JP Regular (https://github.com/notofonts/noto-cjk), under the SIL Open Font License,
    34 Version 1.1 (full text 2 below).
    35 これらの画像を配るときは、このファイルも一緒に配ること / ship this file together with these images.
    36  
    37  
    38 ==============================================================================
    39 1. DejaVu Sans Mono: Bitstream Vera Fonts license
    40 ==============================================================================
    41  
    42 Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
    43  
    44 Bitstream Vera Fonts Copyright
    45 ------------------------------
    46  
    47 Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
    48 a trademark of Bitstream, Inc.
    49  
    50 Permission is hereby granted, free of charge, to any person obtaining a copy
    51 of the fonts accompanying this license ("Fonts") and associated
    52 documentation files (the "Font Software"), to reproduce and distribute the
    53 Font Software, including without limitation the rights to use, copy, merge,
    54 publish, distribute, and/or sell copies of the Font Software, and to permit
    55 persons to whom the Font Software is furnished to do so, subject to the
    56 following conditions:
    57  
    58 The above copyright and trademark notices and this permission notice shall
    59 be included in all copies of one or more of the Font Software typefaces.
    60  
    61 The Font Software may be modified, altered, or added to, and in particular
    62 the designs of glyphs or characters in the Fonts may be modified and
    63 additional glyphs or characters may be added to the Fonts, only if the fonts
    64 are renamed to names not containing either the words "Bitstream" or the word
    65 "Vera".
    66  
    67 This License becomes null and void to the extent applicable to Fonts or Font
    68 Software that has been modified and is distributed under the "Bitstream
    69 Vera" names.
    70  
    71 The Font Software may be sold as part of a larger software package but no
    72 copy of one or more of the Font Software typefaces may be sold by itself.
    73  
    74 THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    75 OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
    76 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
    77 TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
    78 FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
    79 ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
    80 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
    81 THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
    82 FONT SOFTWARE.
    83  
    84 Except as contained in this notice, the names of Gnome, the Gnome
    85 Foundation, and Bitstream Inc., shall not be used in advertising or
    86 otherwise to promote the sale, use or other dealings in this Font Software
    87 without prior written authorization from the Gnome Foundation or Bitstream
    88 Inc., respectively. For further information, contact: fonts at gnome dot
    89 org.
    90  
    91  
    92 ==============================================================================
    93 2. Noto Sans CJK JP: SIL Open Font License, Version 1.1
    94 ==============================================================================
    95  
    96 Copyright © 2014-2021 Adobe (http://www.adobe.com/).
    97 Noto is a trademark of Google Inc.
    98  
    99 This Font Software is licensed under the SIL Open Font License, Version 1.1.
    100 This license is copied below, and is also available with a FAQ at:
    101 https://openfontlicense.org
    102  
    103 -----------------------------------------------------------
    104 SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
    105 -----------------------------------------------------------
    106  
    107 PREAMBLE
    108  
    109 The goals of the Open Font License (OFL) are to stimulate worldwide
    110 development of collaborative font projects, to support the font
    111 creation efforts of academic and linguistic communities, and to provide
    112 a free and open framework in which fonts may be shared and improved in
    113 partnership with others.
    114  
    115 The OFL allows the licensed fonts to be used, studied, modified and
    116 redistributed freely as long as they are not sold by themselves. The
    117 fonts, including any derivative works, can be bundled, embedded,
    118 redistributed and/or sold with any software provided that any reserved
    119 names are not used by derivative works. The fonts and derivatives,
    120 however, cannot be released under any other type of license. The
    121 requirement for fonts to remain under this license does not apply to
    122 any document created using the fonts or their derivatives.
    123  
    124 DEFINITIONS
    125  
    126 "Font Software" refers to the set of files released by the Copyright
    127 Holder(s) under this license and clearly marked as such. This may
    128 include source files, build scripts and documentation.
    129  
    130 "Reserved Font Name" refers to any names specified as such after the
    131 copyright statement(s).
    132  
    133 "Original Version" refers to the collection of Font Software components
    134 as distributed by the Copyright Holder(s).
    135  
    136 "Modified Version" refers to any derivative made by adding to,
    137 deleting, or substituting -- in part or in whole -- any of the
    138 components of the Original Version, by changing formats or by porting
    139 the Font Software to a new environment.
    140  
    141 "Author" refers to any designer, engineer, programmer, technical writer
    142 or other person who contributed to the Font Software.
    143  
    144 PERMISSION & CONDITIONS
    145  
    146 Permission is hereby granted, free of charge, to any person obtaining a
    147 copy of the Font Software, to use, study, copy, merge, embed, modify,
    148 redistribute, and sell modified and unmodified copies of the Font
    149 Software, subject to the following conditions:
    150  
    151 1) Neither the Font Software nor any of its individual components, in
    152 Original or Modified Versions, may be sold by itself.
    153  
    154 2) Original or Modified Versions of the Font Software may be bundled,
    155 redistributed and/or sold with any software, provided that each copy
    156 contains the above copyright notice and this license. These can be
    157 included either as stand-alone text files, human-readable headers or
    158 in the appropriate machine-readable metadata fields within text or
    159 binary files as long as those fields can be easily viewed by the user.
    160  
    161 3) No Modified Version of the Font Software may use the Reserved Font
    162 Name(s) unless explicit written permission is granted by the
    163 corresponding Copyright Holder. This restriction only applies to the
    164 primary font name as presented to the users.
    165  
    166 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
    167 Software shall not be used to promote, endorse or advertise any
    168 Modified Version, except to acknowledge the contribution(s) of the
    169 Copyright Holder(s) and the Author(s) or with their explicit written
    170 permission.
    171  
    172 5) The Font Software, modified or unmodified, in part or in whole, must
    173 be distributed entirely under this license, and must not be distributed
    174 under any other license. The requirement for fonts to remain under this
    175 license does not apply to any document created using the Font Software.
    176  
    177 TERMINATION
    178  
    179 This license becomes null and void if any of the above conditions are
    180 not met.
    181  
    182 DISCLAIMER
    183  
    184 THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    185 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
    186 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
    187 OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
    188 COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    189 INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
    190 DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    191 FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
    192 OTHER DEALINGS IN THE FONT SOFTWARE.

ファイル: /dev/null | b/assets/fonts/mono16.fnt

前新
@@ -0,0 +1,558 @@
    1 info face="DejaVu Sans Mono + Noto Sans CJK JP" size=16 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=2,2
    2 common lineHeight=20 base=15 scaleW=512 scaleH=512 pages=1 packed=0
    3 page id=0 file="mono16.png"
    4 chars count=554
    5 char id=32 x=1 y=1 width=0 height=0 xoffset=0 yoffset=15 xadvance=10 page=0 chnl=15
    6 char id=33 x=3 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    7 char id=34 x=15 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    8 char id=35 x=27 y=1 width=10 height=11 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=15
    9 char id=36 x=39 y=1 width=10 height=14 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    10 char id=37 x=51 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    11 char id=38 x=63 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    12 char id=39 x=75 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    13 char id=40 x=87 y=1 width=10 height=14 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    14 char id=41 x=99 y=1 width=10 height=14 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    15 char id=42 x=111 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    16 char id=43 x=123 y=1 width=10 height=8 xoffset=0 yoffset=7 xadvance=10 page=0 chnl=15
    17 char id=44 x=135 y=1 width=10 height=5 xoffset=0 yoffset=13 xadvance=10 page=0 chnl=15
    18 char id=45 x=147 y=1 width=10 height=5 xoffset=0 yoffset=10 xadvance=10 page=0 chnl=15
    19 char id=46 x=159 y=1 width=10 height=2 xoffset=0 yoffset=13 xadvance=10 page=0 chnl=15
    20 char id=47 x=171 y=1 width=10 height=13 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    21 char id=48 x=183 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    22 char id=49 x=195 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    23 char id=50 x=207 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    24 char id=51 x=219 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    25 char id=52 x=231 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    26 char id=53 x=243 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    27 char id=54 x=255 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    28 char id=55 x=267 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    29 char id=56 x=279 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    30 char id=57 x=291 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    31 char id=58 x=303 y=1 width=10 height=8 xoffset=0 yoffset=7 xadvance=10 page=0 chnl=15
    32 char id=59 x=315 y=1 width=10 height=11 xoffset=0 yoffset=7 xadvance=10 page=0 chnl=15
    33 char id=60 x=327 y=1 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    34 char id=61 x=339 y=1 width=10 height=7 xoffset=0 yoffset=8 xadvance=10 page=0 chnl=15
    35 char id=62 x=351 y=1 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    36 char id=63 x=363 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    37 char id=64 x=375 y=1 width=10 height=14 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=15
    38 char id=65 x=387 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    39 char id=66 x=399 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    40 char id=67 x=411 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    41 char id=68 x=423 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    42 char id=69 x=435 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    43 char id=70 x=447 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    44 char id=71 x=459 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    45 char id=72 x=471 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    46 char id=73 x=483 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    47 char id=74 x=495 y=1 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    48 char id=75 x=1 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    49 char id=76 x=13 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    50 char id=77 x=25 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    51 char id=78 x=37 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    52 char id=79 x=49 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    53 char id=80 x=61 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    54 char id=81 x=73 y=17 width=10 height=14 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    55 char id=82 x=85 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    56 char id=83 x=97 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    57 char id=84 x=109 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    58 char id=85 x=121 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    59 char id=86 x=133 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    60 char id=87 x=145 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    61 char id=88 x=157 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    62 char id=89 x=169 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    63 char id=90 x=181 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    64 char id=91 x=193 y=17 width=10 height=14 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    65 char id=92 x=205 y=17 width=10 height=13 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    66 char id=93 x=217 y=17 width=10 height=14 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    67 char id=94 x=229 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    68 char id=95 x=241 y=17 width=10 height=4 xoffset=0 yoffset=15 xadvance=10 page=0 chnl=15
    69 char id=96 x=253 y=17 width=10 height=13 xoffset=0 yoffset=2 xadvance=10 page=0 chnl=15
    70 char id=97 x=265 y=17 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    71 char id=98 x=277 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    72 char id=99 x=289 y=17 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    73 char id=100 x=301 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    74 char id=101 x=313 y=17 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    75 char id=102 x=325 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    76 char id=103 x=337 y=17 width=10 height=12 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    77 char id=104 x=349 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    78 char id=105 x=361 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    79 char id=106 x=373 y=17 width=10 height=15 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    80 char id=107 x=385 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    81 char id=108 x=397 y=17 width=10 height=12 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    82 char id=109 x=409 y=17 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    83 char id=110 x=421 y=17 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    84 char id=111 x=433 y=17 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    85 char id=112 x=445 y=17 width=10 height=12 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    86 char id=113 x=457 y=17 width=10 height=12 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    87 char id=114 x=469 y=17 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    88 char id=115 x=481 y=17 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    89 char id=116 x=493 y=17 width=10 height=11 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=15
    90 char id=117 x=1 y=34 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    91 char id=118 x=13 y=34 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    92 char id=119 x=25 y=34 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    93 char id=120 x=37 y=34 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    94 char id=121 x=49 y=34 width=10 height=12 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    95 char id=122 x=61 y=34 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    96 char id=123 x=73 y=34 width=10 height=15 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    97 char id=124 x=85 y=34 width=10 height=16 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    98 char id=125 x=97 y=34 width=10 height=15 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=15
    99 char id=126 x=109 y=34 width=10 height=6 xoffset=0 yoffset=9 xadvance=10 page=0 chnl=15
    100 char id=12353 x=121 y=34 width=16 height=12 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    101 char id=12354 x=139 y=34 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    102 char id=12355 x=157 y=34 width=16 height=11 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    103 char id=12356 x=175 y=34 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    104 char id=12357 x=193 y=34 width=16 height=13 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    105 char id=12358 x=211 y=34 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    106 char id=12359 x=229 y=34 width=16 height=13 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    107 char id=12360 x=247 y=34 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    108 char id=12361 x=265 y=34 width=16 height=13 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    109 char id=12362 x=283 y=34 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    110 char id=12363 x=301 y=34 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    111 char id=12364 x=319 y=34 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    112 char id=12365 x=337 y=34 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    113 char id=12366 x=355 y=34 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    114 char id=12367 x=373 y=34 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    115 char id=12368 x=391 y=34 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    116 char id=12369 x=409 y=34 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    117 char id=12370 x=427 y=34 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    118 char id=12371 x=445 y=34 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    119 char id=12372 x=463 y=34 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    120 char id=12373 x=481 y=34 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    121 char id=12374 x=1 y=52 width=16 height=17 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15
    122 char id=12375 x=19 y=52 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    123 char id=12376 x=37 y=52 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    124 char id=12377 x=55 y=52 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    125 char id=12378 x=73 y=52 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    126 char id=12379 x=91 y=52 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    127 char id=12380 x=109 y=52 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    128 char id=12381 x=127 y=52 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    129 char id=12382 x=145 y=52 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    130 char id=12383 x=163 y=52 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    131 char id=12384 x=181 y=52 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    132 char id=12385 x=199 y=52 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    133 char id=12386 x=217 y=52 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    134 char id=12387 x=235 y=52 width=16 height=10 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    135 char id=12388 x=253 y=52 width=16 height=12 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    136 char id=12389 x=271 y=52 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    137 char id=12390 x=289 y=52 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    138 char id=12391 x=307 y=52 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    139 char id=12392 x=325 y=52 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    140 char id=12393 x=343 y=52 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    141 char id=12394 x=361 y=52 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    142 char id=12395 x=379 y=52 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    143 char id=12396 x=397 y=52 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    144 char id=12397 x=415 y=52 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    145 char id=12398 x=433 y=52 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    146 char id=12399 x=451 y=52 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    147 char id=12400 x=469 y=52 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    148 char id=12401 x=487 y=52 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    149 char id=12402 x=1 y=71 width=16 height=14 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    150 char id=12403 x=19 y=71 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    151 char id=12404 x=37 y=71 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    152 char id=12405 x=55 y=71 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    153 char id=12406 x=73 y=71 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    154 char id=12407 x=91 y=71 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    155 char id=12408 x=109 y=71 width=16 height=11 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    156 char id=12409 x=127 y=71 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    157 char id=12410 x=145 y=71 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    158 char id=12411 x=163 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    159 char id=12412 x=181 y=71 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    160 char id=12413 x=199 y=71 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    161 char id=12414 x=217 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    162 char id=12415 x=235 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    163 char id=12416 x=253 y=71 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    164 char id=12417 x=271 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    165 char id=12418 x=289 y=71 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    166 char id=12419 x=307 y=71 width=16 height=13 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    167 char id=12420 x=325 y=71 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    168 char id=12421 x=343 y=71 width=16 height=13 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    169 char id=12422 x=361 y=71 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    170 char id=12423 x=379 y=71 width=16 height=13 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    171 char id=12424 x=397 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    172 char id=12425 x=415 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    173 char id=12426 x=433 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    174 char id=12427 x=451 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    175 char id=12428 x=469 y=71 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    176 char id=12429 x=487 y=71 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    177 char id=12430 x=1 y=89 width=16 height=13 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    178 char id=12431 x=19 y=89 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    179 char id=12432 x=37 y=89 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    180 char id=12433 x=55 y=89 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    181 char id=12434 x=73 y=89 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    182 char id=12435 x=91 y=89 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    183 char id=12436 x=109 y=89 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    184 char id=12437 x=127 y=89 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    185 char id=12438 x=145 y=89 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    186 char id=12445 x=163 y=89 width=16 height=11 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    187 char id=12446 x=181 y=89 width=16 height=12 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    188 char id=12449 x=199 y=89 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    189 char id=12450 x=217 y=89 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    190 char id=12451 x=235 y=89 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    191 char id=12452 x=253 y=89 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    192 char id=12453 x=271 y=89 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    193 char id=12454 x=289 y=89 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    194 char id=12455 x=307 y=89 width=16 height=10 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    195 char id=12456 x=325 y=89 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    196 char id=12457 x=343 y=89 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    197 char id=12458 x=361 y=89 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    198 char id=12459 x=379 y=89 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    199 char id=12460 x=397 y=89 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    200 char id=12461 x=415 y=89 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    201 char id=12462 x=433 y=89 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    202 char id=12463 x=451 y=89 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    203 char id=12464 x=469 y=89 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    204 char id=12465 x=487 y=89 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    205 char id=12466 x=1 y=107 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    206 char id=12467 x=19 y=107 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    207 char id=12468 x=37 y=107 width=16 height=17 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15
    208 char id=12469 x=55 y=107 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    209 char id=12470 x=73 y=107 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    210 char id=12471 x=91 y=107 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    211 char id=12472 x=109 y=107 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    212 char id=12473 x=127 y=107 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    213 char id=12474 x=145 y=107 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    214 char id=12475 x=163 y=107 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    215 char id=12476 x=181 y=107 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    216 char id=12477 x=199 y=107 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    217 char id=12478 x=217 y=107 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    218 char id=12479 x=235 y=107 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    219 char id=12480 x=253 y=107 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    220 char id=12481 x=271 y=107 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    221 char id=12482 x=289 y=107 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    222 char id=12483 x=307 y=107 width=16 height=11 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    223 char id=12484 x=325 y=107 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    224 char id=12485 x=343 y=107 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    225 char id=12486 x=361 y=107 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    226 char id=12487 x=379 y=107 width=16 height=17 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15
    227 char id=12488 x=397 y=107 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    228 char id=12489 x=415 y=107 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    229 char id=12490 x=433 y=107 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    230 char id=12491 x=451 y=107 width=16 height=11 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    231 char id=12492 x=469 y=107 width=16 height=14 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    232 char id=12493 x=487 y=107 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    233 char id=12494 x=1 y=126 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    234 char id=12495 x=19 y=126 width=16 height=12 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    235 char id=12496 x=37 y=126 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    236 char id=12497 x=55 y=126 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    237 char id=12498 x=73 y=126 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    238 char id=12499 x=91 y=126 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    239 char id=12500 x=109 y=126 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    240 char id=12501 x=127 y=126 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    241 char id=12502 x=145 y=126 width=16 height=17 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15
    242 char id=12503 x=163 y=126 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    243 char id=12504 x=181 y=126 width=16 height=11 xoffset=0 yoffset=4 xadvance=16 page=0 chnl=15
    244 char id=12505 x=199 y=126 width=16 height=12 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    245 char id=12506 x=217 y=126 width=16 height=12 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    246 char id=12507 x=235 y=126 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    247 char id=12508 x=253 y=126 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    248 char id=12509 x=271 y=126 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    249 char id=12510 x=289 y=126 width=16 height=14 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    250 char id=12511 x=307 y=126 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    251 char id=12512 x=325 y=126 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    252 char id=12513 x=343 y=126 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    253 char id=12514 x=361 y=126 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    254 char id=12515 x=379 y=126 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    255 char id=12516 x=397 y=126 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    256 char id=12517 x=415 y=126 width=16 height=10 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    257 char id=12518 x=433 y=126 width=16 height=12 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    258 char id=12519 x=451 y=126 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    259 char id=12520 x=469 y=126 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    260 char id=12521 x=487 y=126 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    261 char id=12522 x=1 y=145 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    262 char id=12523 x=19 y=145 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    263 char id=12524 x=37 y=145 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    264 char id=12525 x=55 y=145 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    265 char id=12526 x=73 y=145 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    266 char id=12527 x=91 y=145 width=16 height=14 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    267 char id=12528 x=109 y=145 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    268 char id=12529 x=127 y=145 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    269 char id=12530 x=145 y=145 width=16 height=14 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    270 char id=12531 x=163 y=145 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    271 char id=12532 x=181 y=145 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    272 char id=12533 x=199 y=145 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    273 char id=12534 x=217 y=145 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    274 char id=12535 x=235 y=145 width=16 height=17 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15
    275 char id=12536 x=253 y=145 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    276 char id=12537 x=271 y=145 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    277 char id=12538 x=289 y=145 width=16 height=17 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15
    278 char id=12540 x=307 y=145 width=16 height=8 xoffset=0 yoffset=7 xadvance=16 page=0 chnl=15
    279 char id=12541 x=325 y=145 width=16 height=9 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    280 char id=12542 x=343 y=145 width=16 height=12 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    281 char id=12289 x=361 y=145 width=16 height=5 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=15
    282 char id=12290 x=379 y=145 width=16 height=6 xoffset=0 yoffset=11 xadvance=16 page=0 chnl=15
    283 char id=12539 x=397 y=145 width=16 height=8 xoffset=0 yoffset=7 xadvance=16 page=0 chnl=15
    284 char id=12300 x=415 y=145 width=16 height=14 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    285 char id=12301 x=433 y=145 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    286 char id=12302 x=451 y=145 width=16 height=14 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    287 char id=12303 x=469 y=145 width=16 height=12 xoffset=0 yoffset=5 xadvance=16 page=0 chnl=15
    288 char id=65288 x=487 y=145 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    289 char id=65289 x=1 y=164 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    290 char id=12304 x=19 y=164 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    291 char id=12305 x=37 y=164 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    292 char id=12316 x=55 y=164 width=16 height=9 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    293 char id=8230 x=73 y=164 width=16 height=7 xoffset=0 yoffset=8 xadvance=16 page=0 chnl=15
    294 char id=65281 x=91 y=164 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    295 char id=65311 x=109 y=164 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    296 char id=65306 x=127 y=164 width=16 height=12 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    297 char id=65291 x=145 y=164 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    298 char id=65293 x=163 y=164 width=16 height=7 xoffset=0 yoffset=8 xadvance=16 page=0 chnl=15
    299 char id=215 x=181 y=164 width=10 height=9 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
    300 char id=247 x=193 y=164 width=10 height=8 xoffset=0 yoffset=7 xadvance=10 page=0 chnl=15
    301 char id=65309 x=205 y=164 width=16 height=9 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    302 char id=65285 x=223 y=164 width=16 height=12 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    303 char id=65286 x=241 y=164 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    304 char id=65283 x=259 y=164 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    305 char id=65290 x=277 y=164 width=16 height=13 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    306 char id=12288 x=295 y=164 width=0 height=0 xoffset=0 yoffset=15 xadvance=16 page=0 chnl=15
    307 char id=38283 x=297 y=164 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    308 char id=22987 x=315 y=164 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    309 char id=32066 x=333 y=164 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    310 char id=20102 x=351 y=164 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    311 char id=19968 x=369 y=164 width=16 height=7 xoffset=0 yoffset=8 xadvance=16 page=0 chnl=15
    312 char id=26178 x=387 y=164 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    313 char id=20572 x=405 y=164 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    314 char id=27490 x=423 y=164 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    315 char id=20877 x=441 y=164 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    316 char id=32154 x=459 y=164 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    317 char id=34892 x=477 y=164 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    318 char id=24471 x=495 y=164 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    319 char id=28857 x=1 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    320 char id=26368 x=19 y=183 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    321 char id=39640 x=37 y=183 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    322 char id=27531 x=55 y=183 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    323 char id=27231 x=73 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    324 char id=20307 x=91 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    325 char id=21147 x=109 y=183 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    326 char id=21629 x=127 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    327 char id=21213 x=145 y=183 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    328 char id=21033 x=163 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    329 char id=25943 x=181 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    330 char id=21271 x=199 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    331 char id=24341 x=217 y=183 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    332 char id=20998 x=235 y=183 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    333 char id=27425 x=253 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    334 char id=38754 x=271 y=183 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    335 char id=25147 x=289 y=183 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    336 char id=36984 x=307 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    337 char id=25246 x=325 y=183 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    338 char id=27770 x=343 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    339 char id=23450 x=361 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    340 char id=35373 x=379 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    341 char id=38899 x=397 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    342 char id=37327 x=415 y=183 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    343 char id=36895 x=433 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    344 char id=24230 x=451 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    345 char id=38291 x=469 y=183 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    346 char id=31186 x=487 y=183 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    347 char id=22238 x=1 y=202 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    348 char id=20154 x=19 y=202 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    349 char id=25973 x=37 y=202 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    350 char id=21619 x=55 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    351 char id=26041 x=73 y=202 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    352 char id=23453 x=91 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    353 char id=31665 x=109 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    354 char id=37749 x=127 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    355 char id=25161 x=145 y=202 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    356 char id=26449 x=163 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    357 char id=30010 x=181 y=202 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    358 char id=26862 x=199 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    359 char id=36947 x=217 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    360 char id=22478 x=235 y=202 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    361 char id=29579 x=253 y=202 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    362 char id=23019 x=271 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    363 char id=21191 x=289 y=202 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    364 char id=32773 x=307 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    365 char id=21091 x=325 y=202 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    366 char id=30462 x=343 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    367 char id=24339 x=361 y=202 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    368 char id=30690 x=379 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    369 char id=34220 x=397 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    370 char id=33609 x=415 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    371 char id=37329 x=433 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    372 char id=37504 x=451 y=202 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    373 char id=37509 x=469 y=202 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    374 char id=30707 x=487 y=202 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    375 char id=26408 x=1 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    376 char id=27700 x=19 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    377 char id=28779 x=37 y=221 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    378 char id=39080 x=55 y=221 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    379 char id=22303 x=73 y=221 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    380 char id=20809 x=91 y=221 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    381 char id=38343 x=109 y=221 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    382 char id=25915 x=127 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    383 char id=25731 x=145 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    384 char id=38450 x=163 y=221 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    385 char id=24481 x=181 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    386 char id=39764 x=199 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    387 char id=27861 x=217 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    388 char id=25216 x=235 y=221 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    389 char id=24517 x=253 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    390 char id=27578 x=271 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    391 char id=24489 x=289 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    392 char id=27602 x=307 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    393 char id=30496 x=325 y=221 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    394 char id=27494 x=343 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    395 char id=22120 x=361 y=221 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    396 char id=20855 x=379 y=221 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    397 char id=25345 x=397 y=221 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    398 char id=29289 x=415 y=221 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    399 char id=35013 x=433 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    400 char id=20633 x=451 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    401 char id=36023 x=469 y=221 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    402 char id=22770 x=487 y=221 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    403 char id=24215 x=1 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    404 char id=23487 x=19 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    405 char id=23627 x=37 y=240 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    406 char id=35441 x=55 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    407 char id=32862 x=73 y=240 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    408 char id=35211 x=91 y=240 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    409 char id=26469 x=109 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    410 char id=20837 x=127 y=240 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    411 char id=20986 x=145 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    412 char id=19978 x=163 y=240 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    413 char id=19979 x=181 y=240 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    414 char id=24038 x=199 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    415 char id=21491 x=217 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    416 char id=21069 x=235 y=240 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    417 char id=24460 x=253 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    418 char id=26481 x=271 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    419 char id=35199 x=289 y=240 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    420 char id=21335 x=307 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    421 char id=25276 x=325 y=240 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    422 char id=38626 x=343 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    423 char id=25163 x=361 y=240 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    424 char id=36275 x=379 y=240 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    425 char id=38957 x=397 y=240 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    426 char id=30446 x=415 y=240 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    427 char id=21475 x=433 y=240 width=16 height=14 xoffset=0 yoffset=3 xadvance=16 page=0 chnl=15
    428 char id=32819 x=451 y=240 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    429 char id=24515 x=469 y=240 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    430 char id=27671 x=487 y=240 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    431 char id=20803 x=1 y=259 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    432 char id=22825 x=19 y=259 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    433 char id=22320 x=37 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    434 char id=23665 x=55 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    435 char id=24029 x=73 y=259 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    436 char id=28023 x=91 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    437 char id=31354 x=109 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    438 char id=26143 x=127 y=259 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    439 char id=26376 x=145 y=259 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    440 char id=26085 x=163 y=259 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    441 char id=24180 x=181 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    442 char id=20170 x=199 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    443 char id=26397 x=217 y=259 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    444 char id=26172 x=235 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    445 char id=22812 x=253 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    446 char id=36196 x=271 y=259 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    447 char id=38738 x=289 y=259 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    448 char id=40644 x=307 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    449 char id=32209 x=325 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    450 char id=30333 x=343 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    451 char id=40658 x=361 y=259 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    452 char id=33394 x=379 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    453 char id=22823 x=397 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    454 char id=23567 x=415 y=259 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    455 char id=20302 x=433 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    456 char id=38263 x=451 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    457 char id=30701 x=469 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    458 char id=26032 x=487 y=259 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    459 char id=21476 x=1 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    460 char id=22810 x=19 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    461 char id=23569 x=37 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    462 char id=26089 x=55 y=278 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    463 char id=36933 x=73 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    464 char id=24375 x=91 y=278 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    465 char id=24369 x=109 y=278 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    466 char id=37325 x=127 y=278 width=16 height=15 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    467 char id=36605 x=145 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    468 char id=33391 x=163 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    469 char id=24746 x=181 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    470 char id=27491 x=199 y=278 width=16 height=14 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    471 char id=20840 x=217 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    472 char id=37096 x=235 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    473 char id=21322 x=253 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    474 char id=25968 x=271 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    475 char id=23383 x=289 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    476 char id=25991 x=307 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    477 char id=35501 x=325 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    478 char id=26360 x=343 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    479 char id=35328 x=361 y=278 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    480 char id=35486 x=379 y=278 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    481 char id=33521 x=397 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    482 char id=26412 x=415 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    483 char id=20013 x=433 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    484 char id=22269 x=451 y=278 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    485 char id=21517 x=469 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    486 char id=30058 x=487 y=278 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    487 char id=21495 x=1 y=297 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    488 char id=31532 x=19 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    489 char id=31456 x=37 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    490 char id=35352 x=55 y=297 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    491 char id=37682 x=73 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    492 char id=20445 x=91 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    493 char id=23384 x=109 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    494 char id=36796 x=127 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    495 char id=21066 x=145 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    496 char id=38500 x=163 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    497 char id=30011 x=181 y=297 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    498 char id=34920 x=199 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    499 char id=31034 x=217 y=297 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    500 char id=25805 x=235 y=297 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    501 char id=20316 x=253 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    502 char id=35500 x=271 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    503 char id=26126 x=289 y=297 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    504 char id=36938 x=307 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    505 char id=38627 x=325 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    506 char id=26131 x=343 y=297 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    507 char id=26222 x=361 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    508 char id=36890 x=379 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    509 char id=31777 x=397 y=297 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    510 char id=21336 x=415 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    511 char id=32244 x=433 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    512 char id=32722 x=451 y=297 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    513 char id=23550 x=469 y=297 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    514 char id=25126 x=487 y=297 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    515 char id=35430 x=1 y=316 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    516 char id=21512 x=19 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    517 char id=36000 x=37 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    518 char id=28310 x=55 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    519 char id=23436 x=73 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    520 char id=25104 x=91 y=316 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    521 char id=21151 x=109 y=316 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    522 char id=22833 x=127 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    523 char id=24565 x=145 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    524 char id=27515 x=163 y=316 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    525 char id=29983 x=181 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    526 char id=30772 x=199 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    527 char id=20498 x=217 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    528 char id=24618 x=235 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    529 char id=20027 x=253 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    530 char id=20844 x=271 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    531 char id=20210 x=289 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    532 char id=26053 x=307 y=316 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    533 char id=20882 x=325 y=316 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    534 char id=38522 x=343 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    535 char id=19990 x=361 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    536 char id=30028 x=379 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    537 char id=22259 x=397 y=316 width=16 height=15 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    538 char id=37489 x=415 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    539 char id=27934 x=433 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    540 char id=31391 x=451 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    541 char id=22612 x=469 y=316 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    542 char id=38272 x=487 y=316 width=16 height=16 xoffset=0 yoffset=2 xadvance=16 page=0 chnl=15
    543 char id=27211 x=1 y=335 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    544 char id=23478 x=19 y=335 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    545 char id=23460 x=37 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    546 char id=38542 x=55 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    547 char id=27573 x=73 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    548 char id=31348 x=91 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    549 char id=33853 x=109 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    550 char id=25342 x=127 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    551 char id=20351 x=145 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    552 char id=25448 x=163 y=335 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    553 char id=21463 x=181 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    554 char id=28193 x=199 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    555 char id=25506 x=217 y=335 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    556 char id=35519 x=235 y=335 width=16 height=17 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    557 char id=38598 x=253 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15
    558 char id=24403 x=271 y=335 width=16 height=16 xoffset=0 yoffset=1 xadvance=16 page=0 chnl=15

ファイル: /dev/null | b/assets/fonts/mono16.png

新しいファイル:100644 / バイナリファイル

ファイル: /dev/null | b/assets/fonts/pixel12.fnt

前新
@@ -0,0 +1,558 @@
    1 info face="DejaVu Sans Mono + Noto Sans CJK JP" size=12 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=1,1,1,1 spacing=2,2
    2 common lineHeight=16 base=12 scaleW=512 scaleH=256 pages=1 packed=0
    3 page id=0 file="pixel12.png"
    4 chars count=554
    5 char id=32 x=1 y=1 width=0 height=0 xoffset=0 yoffset=12 xadvance=7 page=0 chnl=15
    6 char id=33 x=3 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    7 char id=34 x=12 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    8 char id=35 x=21 y=1 width=7 height=8 xoffset=0 yoffset=4 xadvance=7 page=0 chnl=15
    9 char id=36 x=30 y=1 width=7 height=11 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    10 char id=37 x=39 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    11 char id=38 x=48 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    12 char id=39 x=57 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    13 char id=40 x=66 y=1 width=7 height=11 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    14 char id=41 x=75 y=1 width=7 height=11 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    15 char id=42 x=84 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    16 char id=43 x=93 y=1 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    17 char id=44 x=102 y=1 width=7 height=3 xoffset=0 yoffset=10 xadvance=7 page=0 chnl=15
    18 char id=45 x=111 y=1 width=7 height=4 xoffset=0 yoffset=8 xadvance=7 page=0 chnl=15
    19 char id=46 x=120 y=1 width=7 height=2 xoffset=0 yoffset=10 xadvance=7 page=0 chnl=15
    20 char id=47 x=129 y=1 width=7 height=10 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    21 char id=48 x=138 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    22 char id=49 x=147 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    23 char id=50 x=156 y=1 width=8 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    24 char id=51 x=166 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    25 char id=52 x=175 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    26 char id=53 x=184 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    27 char id=54 x=193 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    28 char id=55 x=202 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    29 char id=56 x=211 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    30 char id=57 x=220 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    31 char id=58 x=229 y=1 width=7 height=6 xoffset=0 yoffset=6 xadvance=7 page=0 chnl=15
    32 char id=59 x=238 y=1 width=7 height=7 xoffset=0 yoffset=6 xadvance=7 page=0 chnl=15
    33 char id=60 x=247 y=1 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    34 char id=61 x=256 y=1 width=7 height=5 xoffset=0 yoffset=7 xadvance=7 page=0 chnl=15
    35 char id=62 x=265 y=1 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    36 char id=63 x=274 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    37 char id=64 x=283 y=1 width=7 height=10 xoffset=0 yoffset=4 xadvance=7 page=0 chnl=15
    38 char id=65 x=292 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    39 char id=66 x=301 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    40 char id=67 x=310 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    41 char id=68 x=319 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    42 char id=69 x=328 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    43 char id=70 x=337 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    44 char id=71 x=346 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    45 char id=72 x=355 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    46 char id=73 x=364 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    47 char id=74 x=373 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    48 char id=75 x=382 y=1 width=8 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    49 char id=76 x=392 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    50 char id=77 x=401 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    51 char id=78 x=410 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    52 char id=79 x=419 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    53 char id=80 x=428 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    54 char id=81 x=437 y=1 width=7 height=11 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    55 char id=82 x=446 y=1 width=8 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    56 char id=83 x=456 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    57 char id=84 x=465 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    58 char id=85 x=474 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    59 char id=86 x=483 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    60 char id=87 x=492 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    61 char id=88 x=501 y=1 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    62 char id=89 x=1 y=14 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    63 char id=90 x=10 y=14 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    64 char id=91 x=19 y=14 width=7 height=11 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    65 char id=92 x=28 y=14 width=7 height=10 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    66 char id=93 x=37 y=14 width=7 height=11 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    67 char id=94 x=46 y=14 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    68 char id=95 x=55 y=14 width=7 height=3 xoffset=0 yoffset=12 xadvance=7 page=0 chnl=15
    69 char id=96 x=64 y=14 width=7 height=10 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    70 char id=97 x=73 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    71 char id=98 x=82 y=14 width=7 height=10 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    72 char id=99 x=91 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    73 char id=100 x=100 y=14 width=7 height=10 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    74 char id=101 x=109 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    75 char id=102 x=118 y=14 width=7 height=10 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    76 char id=103 x=127 y=14 width=7 height=10 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    77 char id=104 x=136 y=14 width=7 height=10 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    78 char id=105 x=145 y=14 width=7 height=10 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    79 char id=106 x=154 y=14 width=7 height=13 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    80 char id=107 x=163 y=14 width=7 height=10 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    81 char id=108 x=172 y=14 width=7 height=10 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    82 char id=109 x=181 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    83 char id=110 x=190 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    84 char id=111 x=199 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    85 char id=112 x=208 y=14 width=7 height=10 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    86 char id=113 x=217 y=14 width=7 height=10 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    87 char id=114 x=226 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    88 char id=115 x=235 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    89 char id=116 x=244 y=14 width=7 height=9 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=15
    90 char id=117 x=253 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    91 char id=118 x=262 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    92 char id=119 x=271 y=14 width=8 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    93 char id=120 x=281 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    94 char id=121 x=290 y=14 width=7 height=10 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    95 char id=122 x=299 y=14 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    96 char id=123 x=308 y=14 width=7 height=11 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    97 char id=124 x=317 y=14 width=7 height=12 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    98 char id=125 x=326 y=14 width=7 height=11 xoffset=0 yoffset=2 xadvance=7 page=0 chnl=15
    99 char id=126 x=335 y=14 width=7 height=5 xoffset=0 yoffset=7 xadvance=7 page=0 chnl=15
    100 char id=12353 x=344 y=14 width=12 height=10 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    101 char id=12354 x=358 y=14 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    102 char id=12355 x=372 y=14 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    103 char id=12356 x=386 y=14 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    104 char id=12357 x=400 y=14 width=12 height=10 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    105 char id=12358 x=414 y=14 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    106 char id=12359 x=428 y=14 width=12 height=10 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    107 char id=12360 x=442 y=14 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    108 char id=12361 x=456 y=14 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    109 char id=12362 x=470 y=14 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    110 char id=12363 x=484 y=14 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    111 char id=12364 x=498 y=14 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    112 char id=12365 x=1 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    113 char id=12366 x=15 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    114 char id=12367 x=29 y=29 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    115 char id=12368 x=43 y=29 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    116 char id=12369 x=57 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    117 char id=12370 x=71 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    118 char id=12371 x=85 y=29 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    119 char id=12372 x=99 y=29 width=12 height=12 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    120 char id=12373 x=113 y=29 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    121 char id=12374 x=127 y=29 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    122 char id=12375 x=141 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    123 char id=12376 x=155 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    124 char id=12377 x=169 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    125 char id=12378 x=183 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    126 char id=12379 x=197 y=29 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    127 char id=12380 x=211 y=29 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    128 char id=12381 x=225 y=29 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    129 char id=12382 x=239 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    130 char id=12383 x=253 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    131 char id=12384 x=267 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    132 char id=12385 x=281 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    133 char id=12386 x=295 y=29 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    134 char id=12387 x=309 y=29 width=12 height=7 xoffset=0 yoffset=5 xadvance=12 page=0 chnl=15
    135 char id=12388 x=323 y=29 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    136 char id=12389 x=337 y=29 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    137 char id=12390 x=351 y=29 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    138 char id=12391 x=365 y=29 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    139 char id=12392 x=379 y=29 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    140 char id=12393 x=393 y=29 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    141 char id=12394 x=407 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    142 char id=12395 x=421 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    143 char id=12396 x=435 y=29 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    144 char id=12397 x=449 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    145 char id=12398 x=463 y=29 width=12 height=10 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    146 char id=12399 x=477 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    147 char id=12400 x=491 y=29 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    148 char id=12401 x=1 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    149 char id=12402 x=15 y=45 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    150 char id=12403 x=29 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    151 char id=12404 x=43 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    152 char id=12405 x=57 y=45 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    153 char id=12406 x=71 y=45 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    154 char id=12407 x=85 y=45 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    155 char id=12408 x=99 y=45 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    156 char id=12409 x=113 y=45 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    157 char id=12410 x=127 y=45 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    158 char id=12411 x=141 y=45 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    159 char id=12412 x=155 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    160 char id=12413 x=169 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    161 char id=12414 x=183 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    162 char id=12415 x=197 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    163 char id=12416 x=211 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    164 char id=12417 x=225 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    165 char id=12418 x=239 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    166 char id=12419 x=253 y=45 width=12 height=10 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    167 char id=12420 x=267 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    168 char id=12421 x=281 y=45 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    169 char id=12422 x=295 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    170 char id=12423 x=309 y=45 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    171 char id=12424 x=323 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    172 char id=12425 x=337 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    173 char id=12426 x=351 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    174 char id=12427 x=365 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    175 char id=12428 x=379 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    176 char id=12429 x=393 y=45 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    177 char id=12430 x=407 y=45 width=12 height=10 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    178 char id=12431 x=421 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    179 char id=12432 x=435 y=45 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    180 char id=12433 x=449 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    181 char id=12434 x=463 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    182 char id=12435 x=477 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    183 char id=12436 x=491 y=45 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    184 char id=12437 x=1 y=59 width=12 height=10 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    185 char id=12438 x=15 y=59 width=12 height=10 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    186 char id=12445 x=29 y=59 width=12 height=8 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    187 char id=12446 x=43 y=59 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    188 char id=12449 x=57 y=59 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    189 char id=12450 x=71 y=59 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    190 char id=12451 x=85 y=59 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    191 char id=12452 x=99 y=59 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    192 char id=12453 x=113 y=59 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    193 char id=12454 x=127 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    194 char id=12455 x=141 y=59 width=12 height=7 xoffset=0 yoffset=5 xadvance=12 page=0 chnl=15
    195 char id=12456 x=155 y=59 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    196 char id=12457 x=169 y=59 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    197 char id=12458 x=183 y=59 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    198 char id=12459 x=197 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    199 char id=12460 x=211 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    200 char id=12461 x=225 y=59 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    201 char id=12462 x=239 y=59 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    202 char id=12463 x=253 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    203 char id=12464 x=267 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    204 char id=12465 x=281 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    205 char id=12466 x=295 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    206 char id=12467 x=309 y=59 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    207 char id=12468 x=323 y=59 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    208 char id=12469 x=337 y=59 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    209 char id=12470 x=351 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    210 char id=12471 x=365 y=59 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    211 char id=12472 x=379 y=59 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    212 char id=12473 x=393 y=59 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    213 char id=12474 x=407 y=59 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    214 char id=12475 x=421 y=59 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    215 char id=12476 x=435 y=59 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    216 char id=12477 x=449 y=59 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    217 char id=12478 x=463 y=59 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    218 char id=12479 x=477 y=59 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    219 char id=12480 x=491 y=59 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    220 char id=12481 x=1 y=74 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    221 char id=12482 x=15 y=74 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    222 char id=12483 x=29 y=74 width=12 height=8 xoffset=0 yoffset=5 xadvance=12 page=0 chnl=15
    223 char id=12484 x=43 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    224 char id=12485 x=57 y=74 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    225 char id=12486 x=71 y=74 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    226 char id=12487 x=85 y=74 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    227 char id=12488 x=99 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    228 char id=12489 x=113 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    229 char id=12490 x=127 y=74 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    230 char id=12491 x=141 y=74 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    231 char id=12492 x=155 y=74 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    232 char id=12493 x=169 y=74 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    233 char id=12494 x=183 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    234 char id=12495 x=197 y=74 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    235 char id=12496 x=211 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    236 char id=12497 x=225 y=74 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    237 char id=12498 x=239 y=74 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    238 char id=12499 x=253 y=74 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    239 char id=12500 x=267 y=74 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    240 char id=12501 x=281 y=74 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    241 char id=12502 x=295 y=74 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    242 char id=12503 x=309 y=74 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    243 char id=12504 x=323 y=74 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    244 char id=12505 x=337 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    245 char id=12506 x=351 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    246 char id=12507 x=365 y=74 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    247 char id=12508 x=379 y=74 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    248 char id=12509 x=393 y=74 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    249 char id=12510 x=407 y=74 width=12 height=10 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    250 char id=12511 x=421 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    251 char id=12512 x=435 y=74 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    252 char id=12513 x=449 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    253 char id=12514 x=463 y=74 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    254 char id=12515 x=477 y=74 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    255 char id=12516 x=491 y=74 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    256 char id=12517 x=1 y=89 width=12 height=7 xoffset=0 yoffset=5 xadvance=12 page=0 chnl=15
    257 char id=12518 x=15 y=89 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    258 char id=12519 x=29 y=89 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    259 char id=12520 x=43 y=89 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    260 char id=12521 x=57 y=89 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    261 char id=12522 x=71 y=89 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    262 char id=12523 x=85 y=89 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    263 char id=12524 x=99 y=89 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    264 char id=12525 x=113 y=89 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    265 char id=12526 x=127 y=89 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    266 char id=12527 x=141 y=89 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    267 char id=12528 x=155 y=89 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    268 char id=12529 x=169 y=89 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    269 char id=12530 x=183 y=89 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    270 char id=12531 x=197 y=89 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    271 char id=12532 x=211 y=89 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    272 char id=12533 x=225 y=89 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    273 char id=12534 x=239 y=89 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    274 char id=12535 x=253 y=89 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    275 char id=12536 x=267 y=89 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    276 char id=12537 x=281 y=89 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    277 char id=12538 x=295 y=89 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    278 char id=12540 x=309 y=89 width=12 height=7 xoffset=0 yoffset=5 xadvance=12 page=0 chnl=15
    279 char id=12541 x=323 y=89 width=12 height=8 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    280 char id=12542 x=337 y=89 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    281 char id=12289 x=351 y=89 width=12 height=4 xoffset=0 yoffset=9 xadvance=12 page=0 chnl=15
    282 char id=12290 x=365 y=89 width=12 height=4 xoffset=0 yoffset=9 xadvance=12 page=0 chnl=15
    283 char id=12539 x=379 y=89 width=12 height=7 xoffset=0 yoffset=5 xadvance=12 page=0 chnl=15
    284 char id=12300 x=393 y=89 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    285 char id=12301 x=407 y=89 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    286 char id=12302 x=421 y=89 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    287 char id=12303 x=435 y=89 width=12 height=9 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=15
    288 char id=65288 x=449 y=89 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    289 char id=65289 x=463 y=89 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    290 char id=12304 x=477 y=89 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    291 char id=12305 x=491 y=89 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    292 char id=12316 x=1 y=104 width=12 height=7 xoffset=0 yoffset=5 xadvance=12 page=0 chnl=15
    293 char id=8230 x=15 y=104 width=12 height=6 xoffset=0 yoffset=6 xadvance=12 page=0 chnl=15
    294 char id=65281 x=29 y=104 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    295 char id=65311 x=43 y=104 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    296 char id=65306 x=57 y=104 width=12 height=9 xoffset=0 yoffset=3 xadvance=12 page=0 chnl=15
    297 char id=65291 x=71 y=104 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    298 char id=65293 x=85 y=104 width=12 height=5 xoffset=0 yoffset=7 xadvance=12 page=0 chnl=15
    299 char id=215 x=99 y=104 width=7 height=7 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=15
    300 char id=247 x=108 y=104 width=7 height=6 xoffset=0 yoffset=6 xadvance=7 page=0 chnl=15
    301 char id=65309 x=117 y=104 width=12 height=7 xoffset=0 yoffset=5 xadvance=12 page=0 chnl=15
    302 char id=65285 x=131 y=104 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    303 char id=65286 x=145 y=104 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    304 char id=65283 x=159 y=104 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    305 char id=65290 x=173 y=104 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    306 char id=12288 x=187 y=104 width=0 height=0 xoffset=0 yoffset=12 xadvance=12 page=0 chnl=15
    307 char id=38283 x=189 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    308 char id=22987 x=203 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    309 char id=32066 x=217 y=104 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    310 char id=20102 x=231 y=104 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    311 char id=19968 x=245 y=104 width=12 height=6 xoffset=0 yoffset=6 xadvance=12 page=0 chnl=15
    312 char id=26178 x=259 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    313 char id=20572 x=273 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    314 char id=27490 x=287 y=104 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    315 char id=20877 x=301 y=104 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    316 char id=32154 x=315 y=104 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    317 char id=34892 x=329 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    318 char id=24471 x=343 y=104 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    319 char id=28857 x=357 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    320 char id=26368 x=371 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    321 char id=39640 x=385 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    322 char id=27531 x=399 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    323 char id=27231 x=413 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    324 char id=20307 x=427 y=104 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    325 char id=21147 x=441 y=104 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    326 char id=21629 x=455 y=104 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    327 char id=21213 x=469 y=104 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    328 char id=21033 x=483 y=104 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    329 char id=25943 x=497 y=104 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    330 char id=21271 x=1 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    331 char id=24341 x=15 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    332 char id=20998 x=29 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    333 char id=27425 x=43 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    334 char id=38754 x=57 y=120 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    335 char id=25147 x=71 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    336 char id=36984 x=85 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    337 char id=25246 x=99 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    338 char id=27770 x=113 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    339 char id=23450 x=127 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    340 char id=35373 x=141 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    341 char id=38899 x=155 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    342 char id=37327 x=169 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    343 char id=36895 x=183 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    344 char id=24230 x=197 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    345 char id=38291 x=211 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    346 char id=31186 x=225 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    347 char id=22238 x=239 y=120 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    348 char id=20154 x=253 y=120 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    349 char id=25973 x=267 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    350 char id=21619 x=281 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    351 char id=26041 x=295 y=120 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    352 char id=23453 x=309 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    353 char id=31665 x=323 y=120 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    354 char id=37749 x=337 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    355 char id=25161 x=351 y=120 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    356 char id=26449 x=365 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    357 char id=30010 x=379 y=120 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    358 char id=26862 x=393 y=120 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    359 char id=36947 x=407 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    360 char id=22478 x=421 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    361 char id=29579 x=435 y=120 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    362 char id=23019 x=449 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    363 char id=21191 x=463 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    364 char id=32773 x=477 y=120 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    365 char id=21091 x=491 y=120 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    366 char id=30462 x=1 y=135 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    367 char id=24339 x=15 y=135 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    368 char id=30690 x=29 y=135 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    369 char id=34220 x=43 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    370 char id=33609 x=57 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    371 char id=37329 x=71 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    372 char id=37504 x=85 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    373 char id=37509 x=99 y=135 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    374 char id=30707 x=113 y=135 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    375 char id=26408 x=127 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    376 char id=27700 x=141 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    377 char id=28779 x=155 y=135 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    378 char id=39080 x=169 y=135 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    379 char id=22303 x=183 y=135 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    380 char id=20809 x=197 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    381 char id=38343 x=211 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    382 char id=25915 x=225 y=135 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    383 char id=25731 x=239 y=135 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    384 char id=38450 x=253 y=135 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    385 char id=24481 x=267 y=135 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    386 char id=39764 x=281 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    387 char id=27861 x=295 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    388 char id=25216 x=309 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    389 char id=24517 x=323 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    390 char id=27578 x=337 y=135 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    391 char id=24489 x=351 y=135 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    392 char id=27602 x=365 y=135 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    393 char id=30496 x=379 y=135 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    394 char id=27494 x=393 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    395 char id=22120 x=407 y=135 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    396 char id=20855 x=421 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    397 char id=25345 x=435 y=135 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    398 char id=29289 x=449 y=135 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    399 char id=35013 x=463 y=135 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    400 char id=20633 x=477 y=135 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    401 char id=36023 x=491 y=135 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    402 char id=22770 x=1 y=151 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    403 char id=24215 x=15 y=151 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    404 char id=23487 x=29 y=151 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    405 char id=23627 x=43 y=151 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    406 char id=35441 x=57 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    407 char id=32862 x=71 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    408 char id=35211 x=85 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    409 char id=26469 x=99 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    410 char id=20837 x=113 y=151 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    411 char id=20986 x=127 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    412 char id=19978 x=141 y=151 width=12 height=11 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    413 char id=19979 x=155 y=151 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    414 char id=24038 x=169 y=151 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    415 char id=21491 x=183 y=151 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    416 char id=21069 x=197 y=151 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    417 char id=24460 x=211 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    418 char id=26481 x=225 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    419 char id=35199 x=239 y=151 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    420 char id=21335 x=253 y=151 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    421 char id=25276 x=267 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    422 char id=38626 x=281 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    423 char id=25163 x=295 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    424 char id=36275 x=309 y=151 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    425 char id=38957 x=323 y=151 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    426 char id=30446 x=337 y=151 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    427 char id=21475 x=351 y=151 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    428 char id=32819 x=365 y=151 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    429 char id=24515 x=379 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    430 char id=27671 x=393 y=151 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    431 char id=20803 x=407 y=151 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    432 char id=22825 x=421 y=151 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    433 char id=22320 x=435 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    434 char id=23665 x=449 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    435 char id=24029 x=463 y=151 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    436 char id=28023 x=477 y=151 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    437 char id=31354 x=491 y=151 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    438 char id=26143 x=1 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    439 char id=26376 x=15 y=167 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    440 char id=26085 x=29 y=167 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    441 char id=24180 x=43 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    442 char id=20170 x=57 y=167 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    443 char id=26397 x=71 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    444 char id=26172 x=85 y=167 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    445 char id=22812 x=99 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    446 char id=36196 x=113 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    447 char id=38738 x=127 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    448 char id=40644 x=141 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    449 char id=32209 x=155 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    450 char id=30333 x=169 y=167 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    451 char id=40658 x=183 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    452 char id=33394 x=197 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    453 char id=22823 x=211 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    454 char id=23567 x=225 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    455 char id=20302 x=239 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    456 char id=38263 x=253 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    457 char id=30701 x=267 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    458 char id=26032 x=281 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    459 char id=21476 x=295 y=167 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    460 char id=22810 x=309 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    461 char id=23569 x=323 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    462 char id=26089 x=337 y=167 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    463 char id=36933 x=351 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    464 char id=24375 x=365 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    465 char id=24369 x=379 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    466 char id=37325 x=393 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    467 char id=36605 x=407 y=167 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    468 char id=33391 x=421 y=167 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    469 char id=24746 x=435 y=167 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    470 char id=27491 x=449 y=167 width=12 height=10 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    471 char id=20840 x=463 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    472 char id=37096 x=477 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    473 char id=21322 x=491 y=167 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    474 char id=25968 x=1 y=183 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    475 char id=23383 x=15 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    476 char id=25991 x=29 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    477 char id=35501 x=43 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    478 char id=26360 x=57 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    479 char id=35328 x=71 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    480 char id=35486 x=85 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    481 char id=33521 x=99 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    482 char id=26412 x=113 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    483 char id=20013 x=127 y=183 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    484 char id=22269 x=141 y=183 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    485 char id=21517 x=155 y=183 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    486 char id=30058 x=169 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    487 char id=21495 x=183 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    488 char id=31532 x=197 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    489 char id=31456 x=211 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    490 char id=35352 x=225 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    491 char id=37682 x=239 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    492 char id=20445 x=253 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    493 char id=23384 x=267 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    494 char id=36796 x=281 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    495 char id=21066 x=295 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    496 char id=38500 x=309 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    497 char id=30011 x=323 y=183 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    498 char id=34920 x=337 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    499 char id=31034 x=351 y=183 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    500 char id=25805 x=365 y=183 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    501 char id=20316 x=379 y=183 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    502 char id=35500 x=393 y=183 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    503 char id=26126 x=407 y=183 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    504 char id=36938 x=421 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    505 char id=38627 x=435 y=183 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    506 char id=26131 x=449 y=183 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    507 char id=26222 x=463 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    508 char id=36890 x=477 y=183 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    509 char id=31777 x=491 y=183 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    510 char id=21336 x=1 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    511 char id=32244 x=15 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    512 char id=32722 x=29 y=199 width=12 height=12 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    513 char id=23550 x=43 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    514 char id=25126 x=57 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    515 char id=35430 x=71 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    516 char id=21512 x=85 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    517 char id=36000 x=99 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    518 char id=28310 x=113 y=199 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    519 char id=23436 x=127 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    520 char id=25104 x=141 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    521 char id=21151 x=155 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    522 char id=22833 x=169 y=199 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    523 char id=24565 x=183 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    524 char id=27515 x=197 y=199 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    525 char id=29983 x=211 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    526 char id=30772 x=225 y=199 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    527 char id=20498 x=239 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    528 char id=24618 x=253 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    529 char id=20027 x=267 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    530 char id=20844 x=281 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    531 char id=20210 x=295 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    532 char id=26053 x=309 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    533 char id=20882 x=323 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    534 char id=38522 x=337 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    535 char id=19990 x=351 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    536 char id=30028 x=365 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    537 char id=22259 x=379 y=199 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    538 char id=37489 x=393 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    539 char id=27934 x=407 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    540 char id=31391 x=421 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    541 char id=22612 x=435 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    542 char id=38272 x=449 y=199 width=12 height=11 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=15
    543 char id=27211 x=463 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    544 char id=23478 x=477 y=199 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    545 char id=23460 x=491 y=199 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    546 char id=38542 x=1 y=214 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    547 char id=27573 x=15 y=214 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    548 char id=31348 x=29 y=214 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    549 char id=33853 x=43 y=214 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    550 char id=25342 x=57 y=214 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    551 char id=20351 x=71 y=214 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    552 char id=25448 x=85 y=214 width=12 height=14 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    553 char id=21463 x=99 y=214 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    554 char id=28193 x=113 y=214 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    555 char id=25506 x=127 y=214 width=12 height=13 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    556 char id=35519 x=141 y=214 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15
    557 char id=38598 x=155 y=214 width=12 height=13 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
    558 char id=24403 x=169 y=214 width=12 height=12 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=15

ファイル: /dev/null | b/assets/fonts/pixel12.png

新しいファイル:100644 / バイナリファイル

ファイル: /dev/null | b/assets/fonts/pixel5.fnt

前新
@@ -0,0 +1,94 @@
    1 info face="pixfont 3x5" size=5 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=0 padding=0,0,0,0 spacing=1,1
    2 common lineHeight=6 base=5 scaleW=64 scaleH=24 pages=1 packed=0
    3 page id=0 file="pixfont.png"
    4 chars count=90
    5 char id=32 x=0 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    6 char id=33 x=4 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    7 char id=34 x=8 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    8 char id=35 x=12 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    9 char id=36 x=16 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    10 char id=37 x=20 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    11 char id=38 x=24 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    12 char id=39 x=28 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    13 char id=40 x=32 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    14 char id=41 x=36 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    15 char id=42 x=40 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    16 char id=43 x=44 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    17 char id=44 x=48 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    18 char id=45 x=52 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    19 char id=46 x=56 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    20 char id=47 x=60 y=0 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    21 char id=48 x=0 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    22 char id=49 x=4 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    23 char id=50 x=8 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    24 char id=51 x=12 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    25 char id=52 x=16 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    26 char id=53 x=20 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    27 char id=54 x=24 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    28 char id=55 x=28 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    29 char id=56 x=32 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    30 char id=57 x=36 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    31 char id=58 x=40 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    32 char id=59 x=44 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    33 char id=60 x=48 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    34 char id=61 x=52 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    35 char id=62 x=56 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    36 char id=63 x=60 y=6 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    37 char id=64 x=0 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    38 char id=65 x=4 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    39 char id=66 x=8 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    40 char id=67 x=12 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    41 char id=68 x=16 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    42 char id=69 x=20 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    43 char id=70 x=24 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    44 char id=71 x=28 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    45 char id=72 x=32 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    46 char id=73 x=36 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    47 char id=74 x=40 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    48 char id=75 x=44 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    49 char id=76 x=48 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    50 char id=77 x=52 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    51 char id=78 x=56 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    52 char id=79 x=60 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    53 char id=80 x=0 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    54 char id=81 x=4 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    55 char id=82 x=8 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    56 char id=83 x=12 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    57 char id=84 x=16 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    58 char id=85 x=20 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    59 char id=86 x=24 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    60 char id=87 x=28 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    61 char id=88 x=32 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    62 char id=89 x=36 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    63 char id=90 x=40 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    64 char id=91 x=44 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    65 char id=92 x=48 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    66 char id=93 x=52 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    67 char id=94 x=56 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    68 char id=95 x=60 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    69 char id=97 x=4 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    70 char id=98 x=8 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    71 char id=99 x=12 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    72 char id=100 x=16 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    73 char id=101 x=20 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    74 char id=102 x=24 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    75 char id=103 x=28 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    76 char id=104 x=32 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    77 char id=105 x=36 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    78 char id=106 x=40 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    79 char id=107 x=44 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    80 char id=108 x=48 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    81 char id=109 x=52 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    82 char id=110 x=56 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    83 char id=111 x=60 y=12 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    84 char id=112 x=0 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    85 char id=113 x=4 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    86 char id=114 x=8 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    87 char id=115 x=12 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    88 char id=116 x=16 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    89 char id=117 x=20 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    90 char id=118 x=24 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    91 char id=119 x=28 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    92 char id=120 x=32 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    93 char id=121 x=36 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15
    94 char id=122 x=40 y=18 width=3 height=5 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=15

ファイル: a/assets/sprites/pixfont.png | b/assets/fonts/pixfont.png

類似度:100% / 名前の変更元:assets/sprites/pixfont.png / 名前の変更先:assets/fonts/pixfont.png

ファイル: a/assets/sprites/objects_nopad.atlas | /dev/null

前新
@@ -1,7 +0,0 @@
1 # the same tiles WITHOUT gaps (bleeding demo, chapter 25; generated by the author's own script)    
2 image objects_nopad.png    
3 sprite grass 0 0 16 16    
4 sprite dirt 16 0 16 16    
5 sprite brick 32 0 16 16    
6 sprite stone 48 0 16 16    
7 sprite crate 64 0 16 16    

ファイル: a/assets/sprites/objects_nopad.png | /dev/null

削除されたファイル:100644 / バイナリファイル

ファイル: /dev/null | b/demo/demo.hh

前新
@@ -0,0 +1,113 @@
    1 // 第26章のデモ:どのシーンからも使う共有データと、3つのシーン
    2 // The chapter 26 demo: the shared data every scene uses, and the three scenes
    3 #pragma once
    4  
    5 #include "engine/animation.hh"
    6 #include "engine/camera2d.hh"
    7 #include "engine/font.hh"
    8 #include "engine/game_loop.hh"
    9 #include "engine/input.hh"
    10 #include "engine/pixel_canvas.hh"
    11 #include "engine/rng.hh"
    12 #include "engine/scene.hh"
    13 #include "engine/sprite_batch.hh"
    14 #include "engine/sprite_sheet.hh"
    15  
    16 #include <vector>
    17  
    18 // ゲーム全体で一つ。mainが作り、シーンは参照で持つ(エンジンのSceneは中身を知らない)
    19 // One per game. main creates it and the scenes keep a reference (the engine's Scene knows nothing about it)
    20 struct Demo {
    21 Window &window;
    22 Input &input;
    23 GameLoop &loop;
    24 SpriteBatch &batch;
    25 const Font &ui; // mono16:画面の解像度の文字 / text at screen resolution
    26 const Font &pixel; // pixel12:キャンバスの中の文字 / text inside the canvas
    27 const SpriteSheet &hero;
    28 const SpriteSheet &objects;
    29 const AnimationClip &idle, &walk, &coinSpin;
    30 Camera2D world; // 320×180のキャンバス / the 320 × 180 canvas
    31 Camera2D screen; // 1280×720のUI / the 1280 × 720 UI
    32 Viewport uiViewport; // UIの描く場所(マウスの変換にも) / where the UI goes (also for the mouse)
    33 Rng rng{26};
    34 bool interpolate = true;
    35 };
    36  
    37 // タイトル:スペース・Enter・クリックで始める、Escで終わる / the title: Space, Enter or a click starts, Esc quits
    38 class TitleScene : public Scene {
    39 public:
    40 explicit TitleScene(Demo &demo) : d(demo) {}
    41 void enter() override;
    42 void update(float dt) override;
    43 void draw(float alpha) override;
    44 void drawUi(float alpha) override;
    45  
    46 private:
    47 Demo &d;
    48 float time = 0.0f;
    49 Animator heroAnim, coinAnim;
    50 float heroX = -16.0f, heroPrevX = -16.0f;
    51 };
    52  
    53 // 遊び場:主人公を動かし、箱にぶつかり、コインを拾う。HUDにFPSと更新の回数
    54 // The playground: move the hero, bump into boxes, collect coins. The HUD shows FPS and update counts
    55 class PlaygroundScene : public Scene {
    56 public:
    57 explicit PlaygroundScene(Demo &demo);
    58 void enter() override;
    59 void pause() override;
    60 void resume() override;
    61 void update(float dt) override;
    62 void draw(float alpha) override;
    63 void drawUi(float alpha) override;
    64  
    65 private:
    66 struct Coin {
    67 Vec2 position;
    68 float phase;
    69 };
    70 struct Particle {
    71 Vec2 position, velocity;
    72 float life;
    73 Vec4 color;
    74 };
    75 struct Popup {
    76 Vec2 position;
    77 float life;
    78 };
    79 void placeCoin(Coin &coin);
    80 bool blocked(const Rect &r) const;
    81  
    82 Demo &d;
    83 std::vector<Rect> walls, crates, solids;
    84 Rect player; // 当たり判定の箱(足元) / the collision box (the feet)
    85 Vec2 playerPrev; // 前のステップの位置(補間用) / last step's position (for interpolation)
    86 bool facingLeft = false;
    87 Animator heroAnim;
    88 Rect saw;
    89 float sawPrevX = 0.0f, sawDir = 1.0f;
    90 std::vector<Coin> coins;
    91 std::vector<Particle> particles;
    92 std::vector<Popup> popups;
    93 int collected = 0, hits = 0;
    94 float time = 0.0f, hurt = 0.0f;
    95 bool showBoxes = false;
    96 };
    97  
    98 // 一時停止:上に重ねるシーン(isOverlay)。下の遊び場は描かれるが、更新されない
    99 // The pause menu: an overlay scene (isOverlay). The playground below is drawn but not updated
    100 class PauseScene : public Scene {
    101 public:
    102 explicit PauseScene(Demo &demo) : d(demo) {}
    103 bool isOverlay() const override { return true; }
    104 void update(float dt) override;
    105 void draw(float /*alpha*/) override {}
    106 void drawUi(float alpha) override;
    107  
    108 private:
    109 Rect itemRect(int i) const;
    110 Demo &d;
    111 float time = 0.0f;
    112 int selected = 0;
    113 };

ファイル: a/demo/main.cc | b/demo/main.cc

前新
@@ -1,427 +1,86 @@
1 // 第25章:2Dレンダリングとスプライト 1 // 第26章:テキスト・ゲームループ・シーン(ゲームの道具箱)
2 // Chapter 25: 2D rendering and sprites 2 // Chapter 26: text, game loops and scenes (the game toolkit)
3 // 3 //
4 // 操作 / Controls: 4 // タイトル → 遊び場 → 一時停止(スタックに載せる重ねたシーン)。切り替えはフェード付き
5 // 1 / 2 / 3 場面:ピクセルアート(320×180のキャンバス) / 10 000スプライト / フィルタリングの比較 5 // Title → playground → pause (an overlay pushed on the stack), with fades between them
6 // scene: pixel art (a 320 × 180 canvas) / 10 000 sprites / filtering comparison    
7 // ← → / A D 主人公を歩かせる(場面1。押さなければ自動で歩く) / walk the hero (scene 1; walks by itself otherwise)    
8 // T 並べ替え:なし ⇔ テクスチャごと(場面2:描画コール 約10 000 ⇔ 2) / sorting: none ⇔ by texture    
9 // (scene 2: about 10 000 ⇔ 2 draw calls)    
10 // U 頂点の送り方:glNamedBufferSubData ⇔ 永続マップ / vertex upload: glNamedBufferSubData ⇔ persistent    
11 // mapping    
12 // = / - スプライトの数を2倍・半分に(場面2) / twice / half as many sprites (scene 2)    
13 // P アニメーションを止める・動かす / pause / resume the animation    
14 // Esc 終了 / quit    
15 // 6 //
16 // 2Dの約束(エンジン全体):仮想ピクセル、y下向き、左上が原点、正の回転は時計回り。色はsRGBの値のまま混ぜる 7 // 操作 / Controls:
17 // The 2D conventions (engine-wide): virtual pixels, y down, origin at the top left, positive rotation is clockwise. 8 // タイトル / title Space・Enter・クリックで開始、Escで終了 / Space, Enter or a click starts, Esc quits
18 // Colors are blended as sRGB-encoded values 9 // 遊び場 / playground ← → ↑ ↓ / WASD 移動 / move B 当たり判定の箱 / collision boxes
19 #include "engine/animation.hh" 10 // I 補間のオン・オフ / interpolation on / off U 更新 60 Hz ⇔ 10 Hz / update rate
20 #include "engine/camera2d.hh" 11 // P / Esc 一時停止 / pause
21 #include "engine/pixel_canvas.hh" 12 // 一時停止 / pause ↑ ↓ / W S 選ぶ / select Space・Enter・クリック 決定 / confirm P / Esc 再開 / resume
22 #include "engine/sprite_batch.hh" 13 #include "demo.hh"
23 #include "engine/sprite_sheet.hh" 14  
24 #include "engine/window.hh" 15 #include "engine/window.hh"
25   16  
26 #include <algorithm>    
27 #include <chrono>    
28 #include <cmath>    
29 #include <cstdint>    
30 #include <cstdio> 17 #include <cstdio>
    18 #include <memory>
31 #include <optional> 19 #include <optional>
32 #include <string>    
33 #include <string_view>    
34 #include <vector>    
35      
36 // 第25章のHUD:3×5のピクセルフォント(格子のシート、ASCII 32〜95)で文字を描く。第26章でFontクラスになる    
37 // The chapter 25 HUD: text drawn with the 3 × 5 pixel font (a grid sheet, ASCII 32-95). Chapter 26 turns this into    
38 // the Font class    
39 static void drawPixelText(SpriteBatch &batch, const SpriteSheet &font, std::string_view text, Vec2 position,    
40 float scale, Vec4 color, float layer = 100.0f) {    
41 Vec2 pen = position;    
42 for (char c : text) {    
43 if (c == '\n') {    
44 pen = {position.x, pen.y + 6.0f * scale};    
45 continue;    
46 }    
47 if (c >= 'a' && c <= 'z') c = static_cast<char>(c - 'a' + 'A'); // 大文字だけ / capitals only    
48 int index = c - 32;    
49 if (index > 0 && index < font.count()) {    
50 Sprite s = font.sprite(index, pen, {0.0f, 0.0f}, scale);    
51 s.color = color;    
52 s.layer = layer;    
53 batch.draw(s);    
54 }    
55 pen.x += 4.0f * scale; // 送り幅:3ピクセル+隙間1 / advance: 3 pixels + 1 gap    
56 }    
57 }    
58      
59 // drawPixelTextが覆う大きさ(一番長い行 × 行数。最後の文字の後の隙間は数えない):HUDの箱を文字に合わせる    
60 // The size drawPixelText covers (the longest line × the lines, without the gap after the last character): fits the    
61 // HUD box to its text    
62 static Vec2 pixelTextSize(std::string_view text, float scale) {    
63 int column = 0, widest = 0, lines = 1;    
64 for (char c : text) {    
65 if (c == '\n') {    
66 ++lines;    
67 column = 0;    
68 continue;    
69 }    
70 widest = std::max(widest, ++column);    
71 }    
72 return Vec2{4.0f * static_cast<float>(widest) - 1.0f, 6.0f * static_cast<float>(lines) - 1.0f} * scale;    
73 }    
74      
75 // 乱数(第26章でRngクラスになる) / random numbers (chapter 26 turns this into the Rng class)    
76 static float random01(std::uint32_t &state) {    
77 state = state * 1664525u + 1013904223u;    
78 return static_cast<float>(state >> 8) / 16777216.0f;    
79 }    
80      
81 // 場面2の一枚:位置・速さ・回転・どのシートのどのコマか / one sprite of scene 2: position, velocity, spin, which    
82 // sheet and frame    
83 struct Mover {    
84 Vec2 position, velocity;    
85 float angle, spin;    
86 int kind; // 0 = 主人公(hero.png)、1 = コイン(objects.png) / 0 = hero (hero.png), 1 = coin (objects.png)    
87 float phase; // アニメーションのずれ / animation offset    
88 };    
89      
90 static std::vector<Mover> makeMovers(int count, Vec2 area) {    
91 std::vector<Mover> movers;    
92 std::uint32_t seed = 25;    
93 for (int i = 0; i < count; ++i) {    
94 Mover m;    
95 m.position = {random01(seed) * area.x, random01(seed) * area.y};    
96 float a = 6.2831853f * random01(seed), speed = 40.0f + 120.0f * random01(seed);    
97 m.velocity = {speed * std::cos(a), speed * std::sin(a)};    
98 m.angle = 6.2831853f * random01(seed);    
99 m.spin = (random01(seed) - 0.5f) * 4.0f;    
100 // 交互に別のテクスチャ:並べ替えなしだと1枚ごとに描画コールが要る / alternate textures: without sorting every    
101 // sprite needs its own draw call    
102 m.kind = i % 2;    
103 m.phase = random01(seed);    
104 movers.push_back(m);    
105 }    
106 return movers;    
107 }    
108   20  
109 int main() { 21 int main() {
110 Window window; 22 Window window;
111 if (!window.create(1280, 720, "OpenGL Tutorial - Chapter 25")) return 1; 23 if (!window.create(1280, 720, "OpenGL Tutorial - Chapter 26")) return 1;
112   24  
113 // 二つのスプライトバッチ:頂点の送り方だけが違う(Uで切り替え) / two sprite batches that differ only in how 25 std::optional<SpriteBatch> batch = SpriteBatch::create();
114 // vertices are uploaded (U switches) 26 // 画面の解像度の文字(アンチエイリアス)と、キャンバスの中の文字(1ビット、GL_NEAREST)
115 std::optional<SpriteBatch> subDataBatch = SpriteBatch::create({.upload = SpriteUpload::SubData}); 27 // Text at screen resolution (antialiased) and text inside the canvas (1-bit, GL_NEAREST)
116 std::optional<SpriteBatch> persistentBatch = SpriteBatch::create({.upload = SpriteUpload::Persistent}); 28 std::optional<Font> ui = Font::load("assets/fonts/mono16.fnt");
117 // ピクセルアートはGL_NEAREST。比較用にGL_LINEARでも読む / pixel art uses GL_NEAREST; also loaded with GL_LINEAR for 29 std::optional<Font> pixel = Font::load("assets/fonts/pixel12.fnt", TextureFilter::Nearest);
118 // the comparison    
119 std::optional<SpriteSheet> hero = SpriteSheet::loadGrid("assets/sprites/hero.png", 16, 16, 1, 1); 30 std::optional<SpriteSheet> hero = SpriteSheet::loadGrid("assets/sprites/hero.png", 16, 16, 1, 1);
120 std::optional<SpriteSheet> heroLinear =    
121 SpriteSheet::loadGrid("assets/sprites/hero.png", 16, 16, 1, 1, TextureFilter::Linear);    
122 std::optional<SpriteSheet> objects = SpriteSheet::loadAtlas("assets/sprites/objects.atlas"); 31 std::optional<SpriteSheet> objects = SpriteSheet::loadAtlas("assets/sprites/objects.atlas");
123 std::optional<SpriteSheet> objectsLinear = SpriteSheet::loadAtlas("assets/sprites/objects.atlas", TextureFilter::Linear); 32 if (!batch || !ui || !pixel || !hero || !objects) return 1;
124 std::optional<SpriteSheet> noPadLinear = SpriteSheet::loadAtlas("assets/sprites/objects_nopad.atlas", TextureFilter::Linear);    
125 std::optional<SpriteSheet> font = SpriteSheet::loadGrid("assets/sprites/pixfont.png", 4, 6);    
126 if (!subDataBatch || !persistentBatch || !hero || !heroLinear || !objects || !objectsLinear || !noPadLinear || !font)    
127 return 1;    
128      
129 // 主人公のクリップ:コマの番号はhero.pngの並び(0〜1 待機、2〜5 歩き、6 ジャンプ)    
130 // The hero's clips: frame numbers follow hero.png (0-1 idle, 2-5 walk, 6 jump)    
131 hero->addClip({.name = "idle", .frames = {0, 0, 0, 0, 0, 0, 1}, .fps = 6.0f}); 33 hero->addClip({.name = "idle", .frames = {0, 0, 0, 0, 0, 0, 1}, .fps = 6.0f});
132 hero->addClip({.name = "walk", .frames = {2, 3, 4, 5}, .fps = 10.0f}); 34 hero->addClip({.name = "walk", .frames = {2, 3, 4, 5}, .fps = 10.0f});
133 const AnimationClip *idleClip = hero->clip("idle"); 35 const AnimationClip *coinSpin = objects->clip("coin_spin");
134 const AnimationClip *walkClip = hero->clip("walk"); 36 if (!coinSpin) return 1;
135 const AnimationClip *coinClip = objects->clip("coin_spin"); 37  
136 const AnimationClip *slimeClip = objects->clip("slime_bounce"); 38 // 入力:ウィンドウのコールバックを引き受け、行動に名前を付ける(キーを変えたくなったらここだけ直す)
137 if (!idleClip || !walkClip || !coinClip || !slimeClip) return 1; 39 // Input: takes over the window's callbacks; actions get names (to change the keys, edit only this)
138   40 Input input;
139 // 場面1:320×180の仮想解像度(1280×720にちょうど4倍) / scene 1: a 320 × 180 virtual resolution (exactly 4× in 1280 × 720) 41 input.attach(window);
    42 input.bind("left", {InputBinding::key(GLFW_KEY_LEFT), InputBinding::key(GLFW_KEY_A)});
    43 input.bind("right", {InputBinding::key(GLFW_KEY_RIGHT), InputBinding::key(GLFW_KEY_D)});
    44 input.bind("up", {InputBinding::key(GLFW_KEY_UP), InputBinding::key(GLFW_KEY_W)});
    45 input.bind("down", {InputBinding::key(GLFW_KEY_DOWN), InputBinding::key(GLFW_KEY_S)});
    46 input.bind("confirm", {InputBinding::key(GLFW_KEY_SPACE), InputBinding::key(GLFW_KEY_ENTER)});
    47  
    48 // 固定ステップ:更新は1/60秒ごと、1フレームに最大5回 / fixed step: an update every 1/60 s, at most 5 per frame
    49 GameLoop loop({.step = 1.0 / 60.0, .maxSteps = 5});
140 PixelCanvas canvas(320, 180); 50 PixelCanvas canvas(320, 180);
141 Camera2D canvasCamera = Camera2D::screen(canvas.size()); 51 Demo demo{.window = window, .input = input, .loop = loop, .batch = *batch, .ui = *ui, .pixel = *pixel,
142 // 場面2・3:ウィンドウのピクセルそのまま / scenes 2 and 3: plain window pixels 52 .hero = *hero, .objects = *objects, .idle = *hero->clip("idle"), .walk = *hero->clip("walk"),
143 Camera2D screenCamera = Camera2D::screen({1280.0f, 720.0f}); 53 .coinSpin = *coinSpin, .world = Camera2D::screen(canvas.size()),
144 // 場面3のキャンバス比較用:48×48の小さなキャンバス / for scene 3's canvas comparison: a small 48 × 48 canvas 54 .screen = Camera2D::screen({1280.0f, 720.0f}), .uiViewport = {}};
145 PixelCanvas smallCanvas(48, 48);    
146 Camera2D smallCamera = Camera2D::screen(smallCanvas.size());    
147      
148 int scene = 0, spriteCount = 10000;    
149 bool sortByTexture = true, persistent = false, paused = false;    
150 std::vector<Mover> movers = makeMovers(spriteCount, {1280.0f, 720.0f});    
151 window.onKey = [&](int key, int action, int /*mods*/) {    
152 if (action != GLFW_PRESS) return;    
153 if (key == GLFW_KEY_ESCAPE) window.close();    
154 if (key >= GLFW_KEY_1 && key <= GLFW_KEY_3) scene = key - GLFW_KEY_1;    
155 if (key == GLFW_KEY_T) sortByTexture = !sortByTexture;    
156 if (key == GLFW_KEY_U) persistent = !persistent;    
157 if (key == GLFW_KEY_P) paused = !paused;    
158 if (key == GLFW_KEY_EQUAL || key == GLFW_KEY_MINUS) {    
159 spriteCount = key == GLFW_KEY_EQUAL ? std::min(spriteCount * 2, 160000) : std::max(spriteCount / 2, 10);    
160 movers = makeMovers(spriteCount, {1280.0f, 720.0f});    
161 printf("sprites: %d\n", spriteCount);    
162 }    
163 };    
164   55  
165 // 主人公(場面1) / the hero (scene 1) 56 SceneManager scenes;
166 Animator heroAnim; 57 scenes.push(std::make_unique<TitleScene>(demo));
167 heroAnim.play(walkClip);    
168 Vec2 heroPos = {60.0f, 144.0f}; // 足元 / feet    
169 float heroDir = 1.0f;    
170 Animator coinAnim, slimeAnim;    
171 coinAnim.play(coinClip);    
172 slimeAnim.play(slimeClip);    
173   58  
174 float time = 0.0f;    
175 double lastTime = window.time();    
176 auto lastFrame = std::chrono::steady_clock::now();    
177 float frameMs = 0.0f;    
178 int frame = 0; 59 int frame = 0;
179 while (!window.shouldClose()) { 60 loop.run(
180 double now = window.time(); 61 window, input,
181 float dt = static_cast<float>(now - lastTime); 62 [&](float dt) {
182 lastTime = now; 63 scenes.update(dt);
183 window.pollEvents(); 64 if (scenes.empty()) window.close(); // 最後のシーンが外れたら終わり / quit when the last scene is gone
184 // 本当の時間(CPU):1フレームにかかったミリ秒(なめらかに) / real time (CPU): milliseconds per frame (smoothed) 65 },
185 auto wall = std::chrono::steady_clock::now(); 66 [&](float alpha) {
186 float ms = std::chrono::duration<float, std::milli>(wall - lastFrame).count(); 67 // 1. 世界:320×180のキャンバスに描き、整数倍で画面へ / 1. the world: into the 320 × 180 canvas, then scaled by
187 lastFrame = wall; 68 // a whole number onto the screen
188 frameMs = frame == 0 ? ms : 0.9f * frameMs + 0.1f * ms; 69 canvas.begin(hexColor(0x1b1726ff));
189 if (paused) dt = 0.0f; 70 scenes.draw(alpha);
190 time += dt; 71 canvas.present(window.width(), window.height());
191   72 // 2. UI:1280×720の仮想画面をウィンドウに合わせる(ここでは1倍) / 2. the UI: the 1280 × 720 virtual screen
192 SpriteBatch &batch = persistent ? *persistentBatch : *subDataBatch; 73 // fitted to the window (1× here)
193 coinAnim.update(dt); 74 demo.uiViewport = letterbox(window.width(), window.height(), demo.screen.viewSize, false);
194 slimeAnim.update(dt); 75 demo.uiViewport.apply();
195   76 scenes.drawUi(alpha);
196 if (scene == 0) { 77 // 3. フェード(全部の上に) / 3. the fade (on top of everything)
197 //------------------------------------------------------------------ 78 scenes.drawFade(*batch, demo.screen.matrix(), demo.screen.viewSize);
198 // 場面1:ピクセルアート。320×180のキャンバスに描いて、整数倍で画面へ 79 // 60フレームごとに1行(frame = 描いたフレームの数、このフレームを含む) / a line every 60 frames (frame = the
199 // Scene 1: pixel art. Drawn into the 320 × 180 canvas, then scaled by a whole number onto the screen 80 // number of frames drawn, this one included)
200 //------------------------------------------------------------------ 81 if (++frame % 60 == 30)
201 float input = 0.0f; 82 printf("frame %d: %zu scene(s), steps %d, alpha %.2f, fps %.1f\n", frame, scenes.size(),
202 if (window.keyDown(GLFW_KEY_LEFT) || window.keyDown(GLFW_KEY_A)) input -= 1.0f; 83 loop.stats().steps, static_cast<double>(loop.stats().alpha), static_cast<double>(loop.stats().fps));
203 if (window.keyDown(GLFW_KEY_RIGHT) || window.keyDown(GLFW_KEY_D)) input += 1.0f; 84 });
204 if (input != 0.0f) heroDir = input;    
205 else if (heroPos.x > 290.0f) heroDir = -1.0f; // 自動で往復 / walks back and forth by itself    
206 else if (heroPos.x < 30.0f) heroDir = 1.0f;    
207 heroPos.x = std::clamp(heroPos.x + heroDir * 40.0f * dt, 8.0f, 312.0f);    
208 heroAnim.play(dt > 0.0f ? walkClip : idleClip);    
209 heroAnim.update(dt);    
210      
211 canvas.begin(hexColor(0x8fd3ffff));    
212 batch.begin(canvasCamera.matrix(), SpriteSort::Layer);    
213 // 雲:ゆっくり流れる(奥、layer 0) / clouds drift slowly (at the back, layer 0)    
214 int cloud = objects->find("cloud");    
215 for (int i = 0; i < 3; ++i) {    
216 float x = std::fmod(40.0f + 130.0f * static_cast<float>(i) + 6.0f * time, 380.0f) - 40.0f;    
217 Sprite s = objects->sprite(cloud, {std::round(x), 18.0f + 14.0f * static_cast<float>(i % 2)});    
218 batch.draw(s);    
219 }    
220 // 地面:草の列と土の列。layer 1 / the ground: a row of grass and a row of dirt. Layer 1    
221 int grass = objects->find("grass"), dirt = objects->find("dirt"), brick = objects->find("brick");    
222 int crate = objects->find("crate"), stone = objects->find("stone");    
223 for (int x = 0; x < 20; ++x) {    
224 Sprite g = objects->sprite(grass, {16.0f * static_cast<float>(x), 144.0f});    
225 g.layer = 1.0f;    
226 batch.draw(g);    
227 for (float y : {160.0f, 176.0f}) {    
228 Sprite d = objects->sprite(dirt, {16.0f * static_cast<float>(x), y});    
229 d.layer = 1.0f;    
230 batch.draw(d);    
231 }    
232 }    
233 // レンガの足場と木箱 / a brick ledge and crates    
234 for (int x = 0; x < 4; ++x) {    
235 Sprite b = objects->sprite(brick, {176.0f + 16.0f * static_cast<float>(x), 96.0f});    
236 b.layer = 1.0f;    
237 batch.draw(b);    
238 }    
239 for (Vec2 p : {Vec2{24.0f, 128.0f}, Vec2{40.0f, 128.0f}, Vec2{32.0f, 112.0f}}) {    
240 Sprite c = objects->sprite(crate, p);    
241 c.layer = 1.0f;    
242 batch.draw(c);    
243 }    
244 for (int y = 0; y < 3; ++y) {    
245 Sprite s = objects->sprite(stone, {256.0f, 96.0f + 16.0f * static_cast<float>(y)});    
246 s.layer = 1.0f;    
247 batch.draw(s);    
248 }    
249 // 回る丸のこ(回転は中心の周り:origin = (0.5, 0.5)) / a spinning saw blade (rotates about its center:    
250 // origin = (0.5, 0.5))    
251 Sprite saw = objects->sprite(objects->find("saw"), {264.0f, 84.0f}, {0.5f, 0.5f});    
252 saw.rotation = 3.0f * time;    
253 saw.layer = 2.0f;    
254 batch.draw(saw);    
255 // コイン(アニメーション)と宝石・ハート・花 / coins (animated), a gem, a heart and flowers    
256 for (int i = 0; i < 4; ++i) {    
257 Sprite c = objects->sprite(coinAnim.frame(), {76.0f + 16.0f * static_cast<float>(i), 112.0f});    
258 c.layer = 2.0f;    
259 batch.draw(c);    
260 }    
261 Sprite gem = objects->sprite(objects->find("gem"), {150.0f, 118.0f + std::round(2.0f * std::sin(3.0f * time))});    
262 gem.layer = 2.0f;    
263 batch.draw(gem);    
264 Sprite heart = objects->sprite(objects->find("heart"), {170.0f, 120.0f});    
265 heart.layer = 2.0f;    
266 batch.draw(heart);    
267 for (float x : {96.0f, 152.0f, 228.0f, 300.0f}) {    
268 Sprite f = objects->sprite(objects->find("flower"), {x, 136.0f});    
269 f.layer = 2.0f;    
270 batch.draw(f);    
271 }    
272 // スライム2匹(同じクリップ、片方は左右反転) / two slimes (the same clip, one mirrored)    
273 for (int i = 0; i < 2; ++i) {    
274 Sprite s = objects->sprite(slimeAnim.frame(), {200.0f + 90.0f * static_cast<float>(i), 128.0f});    
275 s.flipX = i == 1;    
276 s.layer = 2.0f;    
277 batch.draw(s);    
278 }    
279 // 色を掛けた主人公:赤、半透明、影(黒) / tinted heroes: red, half transparent, a black silhouette    
280 const Vec4 tints[] = {hexColor(0xff7070ff), {1.0f, 1.0f, 1.0f, 0.45f}, hexColor(0x000000b0)};    
281 for (int i = 0; i < 3; ++i) {    
282 Sprite s = hero->sprite(0, {192.0f + 20.0f * static_cast<float>(i), 96.0f}, {0.5f, 1.0f});    
283 s.color = tints[i];    
284 s.layer = 2.0f;    
285 batch.draw(s);    
286 }    
287 // 主人公:足元(下の中心)が基準。左へ歩くときは左右反転 / the hero: the pivot is the feet (bottom center).    
288 // Mirrored when walking left    
289 Sprite h = hero->sprite(heroAnim.frame(), {std::round(heroPos.x), heroPos.y}, {0.5f, 1.0f});    
290 h.flipX = heroDir < 0.0f;    
291 h.layer = 3.0f;    
292 batch.draw(h);    
293 batch.end();    
294 SpriteStats stats = batch.stats();    
295 // HUD(同じキャンバス、別のbegin/end) / the HUD (same canvas, a separate begin/end)    
296 batch.begin(canvasCamera.matrix());    
297 char hud[128];    
298 snprintf(hud, sizeof hud, "SCENE 1: PIXEL ART 320X180 X4\nSPRITES %d DRAW CALLS %d", stats.sprites, stats.drawCalls);    
299 Vec2 hudSize = pixelTextSize(hud, 1.0f);    
300 batch.drawRect({2.0f, 2.0f, hudSize.x + 4.0f, hudSize.y + 4.0f}, hexColor(0x1b172699)); // 2ピクセルの余白 / 2 px margin    
301 drawPixelText(batch, *font, hud, {4.0f, 4.0f}, 1.0f, kWhite);    
302 batch.end();    
303 canvas.present(window.width(), window.height());    
304 } else if (scene == 1) {    
305 //------------------------------------------------------------------    
306 // 場面2:たくさんのスプライトを一つのバッチで / Scene 2: many sprites in one batch    
307 //------------------------------------------------------------------    
308 for (Mover &m : movers) {    
309 m.position += m.velocity * dt;    
310 if (m.position.x < 0.0f || m.position.x > 1280.0f) m.velocity.x = -m.velocity.x;    
311 if (m.position.y < 0.0f || m.position.y > 720.0f) m.velocity.y = -m.velocity.y;    
312 m.angle += m.spin * dt;    
313 }    
314 Framebuffer::bindDefault(window.width(), window.height());    
315 glClearColor(0.07f, 0.08f, 0.13f, 1.0f);    
316 glClear(GL_COLOR_BUFFER_BIT);    
317 auto start = std::chrono::steady_clock::now();    
318 batch.begin(screenCamera.matrix(), sortByTexture ? SpriteSort::Texture : SpriteSort::None);    
319 for (const Mover &m : movers) {    
320 // 主人公は歩き、コインは回る。コマはそれぞれの時間のずれで / heroes walk, coins spin, each with its own offset    
321 int heroFrame = 2 + static_cast<int>((time + m.phase) * 10.0f) % 4;    
322 int coinFrame = coinClip->frames[static_cast<size_t>((time + m.phase) * 8.0f) % 4];    
323 Sprite s = m.kind == 0 ? hero->sprite(heroFrame, m.position, {0.5f, 0.5f}, 2.0f)    
324 : objects->sprite(coinFrame, m.position, {0.5f, 0.5f}, 2.0f);    
325 s.rotation = m.angle;    
326 batch.draw(s);    
327 }    
328 batch.end();    
329 float batchMs = std::chrono::duration<float, std::milli>(std::chrono::steady_clock::now() - start).count();    
330 SpriteStats stats = batch.stats();    
331 batch.begin(screenCamera.matrix());    
332 char hud[256];    
333 snprintf(hud, sizeof hud,    
334 "SCENE 2: %d SPRITES IN ONE BATCH\nDRAW CALLS %d SORT %s (T) UPLOAD %s (U)\n"    
335 "BATCH %.1f MS FRAME %.1f MS (CPU)",    
336 stats.sprites, stats.drawCalls, sortByTexture ? "BY TEXTURE" : "NONE",    
337 persistent ? "PERSISTENT MAP" : "SUBDATA", static_cast<double>(batchMs), static_cast<double>(frameMs));    
338 Vec2 hudSize = pixelTextSize(hud, 4.0f);    
339 batch.drawRect({8.0f, 8.0f, hudSize.x + 16.0f, hudSize.y + 16.0f}, hexColor(0x000000c0)); // 余白8 / 8 px margin    
340 drawPixelText(batch, *font, hud, {16.0f, 16.0f}, 4.0f, hexColor(0xffe08aff));    
341 batch.end();    
342 if (frame % 60 == 2)    
343 printf("scene 2: %d sprites, %d draw calls (%s, %s), batch %.1f ms\n", stats.sprites, stats.drawCalls,    
344 sortByTexture ? "by texture" : "unsorted", persistent ? "persistent" : "subdata",    
345 static_cast<double>(batchMs));    
346 } else {    
347 //------------------------------------------------------------------    
348 // 場面3:フィルタリング:GL_NEAREST ⇔ GL_LINEAR、整数倍 ⇔ 半端な倍率と回転、直接 ⇔ キャンバス、隙間 ⇔ にじみ    
349 // Scene 3: filtering: GL_NEAREST ⇔ GL_LINEAR, whole ⇔ fractional scale and rotation, direct ⇔ canvas,    
350 // gaps ⇔ bleeding    
351 //------------------------------------------------------------------    
352 heroAnim.play(walkClip);    
353 heroAnim.update(dt);    
354 float angle = 0.35f * std::sin(0.8f * time);    
355 // 小さなキャンバスに回る主人公と丸のこ(48×48の本物のピクセル) / a turning hero and saw in the small canvas    
356 // (real 48 × 48 pixels)    
357 smallCanvas.begin(hexColor(0x2a3350ff));    
358 batch.begin(smallCamera.matrix());    
359 Sprite small = hero->sprite(heroAnim.frame(), {24.0f, 22.0f}, {0.5f, 0.5f}, 2.0f);    
360 small.rotation = angle;    
361 batch.draw(small);    
362 Sprite smallSaw = objects->sprite(objects->find("saw"), {38.0f, 38.0f}, {0.5f, 0.5f});    
363 smallSaw.rotation = 2.0f * time;    
364 batch.draw(smallSaw);    
365 batch.end();    
366      
367 Framebuffer::bindDefault(window.width(), window.height());    
368 glClearColor(0.10f, 0.11f, 0.16f, 1.0f);    
369 glClear(GL_COLOR_BUFFER_BIT);    
370 batch.begin(screenCamera.matrix());    
371 const Vec4 label = hexColor(0xffe08aff), panel = hexColor(0x2a3350ff);    
372 // 上の段:×12(整数)と×7.5で回転、それぞれGL_NEARESTとGL_LINEAR / top row: ×12 (whole) and ×7.5 rotated, each    
373 // with GL_NEAREST and GL_LINEAR    
374 const char *names[] = {"NEAREST X12", "LINEAR X12", "NEAREST X7.5 TURNED", "LINEAR X7.5 TURNED"};    
375 for (int i = 0; i < 4; ++i) {    
376 float x0 = 20.0f + 315.0f * static_cast<float>(i);    
377 batch.drawRect({x0, 40.0f, 300.0f, 280.0f}, panel);    
378 drawPixelText(batch, *font, names[i], {x0 + 8.0f, 48.0f}, 3.0f, label);    
379 const SpriteSheet &sheet = i % 2 == 0 ? *hero : *heroLinear;    
380 Sprite s = sheet.sprite(0, {x0 + 150.0f, 190.0f}, {0.5f, 0.5f}, i < 2 ? 12.0f : 7.5f);    
381 if (i >= 2) s.rotation = angle;    
382 batch.draw(s);    
383 }    
384 // 中の段:直接(画面の細かいピクセルで回る) ⇔ キャンバス(48×48を6倍) / middle row: direct (turns with the    
385 // screen's fine pixels) ⇔ canvas (48 × 48 enlarged 6×)    
386 batch.drawRect({20.0f, 340.0f, 300.0f, 330.0f}, panel);    
387 drawPixelText(batch, *font, "DIRECT X6", {28.0f, 348.0f}, 3.0f, label);    
388 Sprite direct = hero->sprite(heroAnim.frame(), {20.0f + 6.0f * 24.0f + 6.0f, 380.0f + 6.0f * 22.0f}, {0.5f, 0.5f}, 12.0f);    
389 direct.rotation = angle;    
390 batch.draw(direct);    
391 Sprite directSaw = objects->sprite(objects->find("saw"), {26.0f + 6.0f * 38.0f, 380.0f + 6.0f * 38.0f}, {0.5f, 0.5f}, 6.0f);    
392 directSaw.rotation = 2.0f * time;    
393 batch.draw(directSaw);    
394 batch.drawRect({335.0f, 340.0f, 300.0f, 330.0f}, panel);    
395 drawPixelText(batch, *font, "CANVAS X6", {343.0f, 348.0f}, 3.0f, label);    
396 // FBOの色テクスチャは下の行がv = 0(GLの約束):y下向きの2DではflipYで描く    
397 // An FBO's color texture has its bottom row at v = 0 (the GL convention): draw it with flipY in y-down 2D    
398 Sprite canvasSprite = {.texture = &smallCanvas.framebuffer().color(), .position = {341.0f, 380.0f},    
399 .size = {288.0f, 288.0f}, .flipY = true};    
400 batch.draw(canvasSprite);    
401 // 右下:タイルをGL_LINEARで×3.3に。隙間(縁の複製)あり ⇔ なし / bottom right: tiles at ×3.3 with GL_LINEAR, with    
402 // gaps (extruded edges) ⇔ without    
403 for (int k = 0; k < 2; ++k) {    
404 float y0 = 340.0f + 170.0f * static_cast<float>(k);    
405 batch.drawRect({650.0f, y0, 610.0f, 160.0f}, panel);    
406 drawPixelText(batch, *font, k == 0 ? "LINEAR X3.3, 1 PX EXTRUDED GAPS" : "LINEAR X3.3, NO GAPS: BLEEDING",    
407 {658.0f, y0 + 8.0f}, 3.0f, label);    
408 const SpriteSheet &sheet = k == 0 ? *objectsLinear : *noPadLinear;    
409 const char *tiles[] = {"grass", "dirt", "brick", "stone", "crate"};    
410 for (int t = 0; t < 10; ++t) {    
411 int index = sheet.find(tiles[t / 2]);    
412 batch.draw(sheet.sprite(index, {660.0f + 52.8f * static_cast<float>(t) + 0.3f, y0 + 45.0f + 0.4f}, {0.0f, 0.0f}, 3.3f));    
413 batch.draw(sheet.sprite(index, {660.0f + 52.8f * static_cast<float>(t) + 0.3f, y0 + 45.0f + 52.8f + 0.4f}, {0.0f, 0.0f}, 3.3f));    
414 }    
415 }    
416 batch.end();    
417 }    
418      
419 if (frame++ % 120 == 1) {    
420 char title[128];    
421 snprintf(title, sizeof title, "OpenGL Tutorial - Chapter 25 - scene %d - %d draw calls", scene + 1, batch.stats().drawCalls);    
422 window.setTitle(title);    
423 }    
424 window.swapBuffers();    
425 }    
426 return 0; 85 return 0;
427 } 86 }

ファイル: /dev/null | b/demo/pause_scene.cc

前新
@@ -0,0 +1,58 @@
    1 // 一時停止のメニュー:上に重ねるシーン / the pause menu: an overlay scene
    2 #include "demo.hh"
    3  
    4 #include "engine/collision.hh"
    5  
    6 #include <algorithm>
    7 #include <memory>
    8  
    9 static const char *const kItems[] = {"再開 / Resume", "タイトルへ / Back to title"};
    10  
    11 Rect PauseScene::itemRect(int i) const { return Rect::fromCentre({640.0f, 380.0f + 60.0f * static_cast<float>(i)}, {520.0f, 48.0f}); }
    12  
    13 void PauseScene::update(float dt) {
    14 time += dt;
    15 Input &in = d.input;
    16 // マウス:ウィンドウの座標 → UIの座標(レターボックスの位置と倍率) / the mouse: window → UI coordinates (the
    17 // letterbox's offset and scale)
    18 Vec2 mouse = d.screen.toWorld(d.uiViewport.toView(in.mousePosition()));
    19 bool choose = false;
    20 for (int i = 0; i < 2; ++i)
    21 if (contains(itemRect(i), mouse) && in.mousePressed(GLFW_MOUSE_BUTTON_LEFT)) {
    22 selected = i;
    23 choose = true;
    24 }
    25 if (!choose) {
    26 if (in.actionPressed("up")) selected = std::max(0, selected - 1);
    27 if (in.actionPressed("down")) selected = std::min(1, selected + 1);
    28 if (in.pressed(GLFW_KEY_ESCAPE) || in.pressed(GLFW_KEY_P)) {
    29 scenes().pop(); // すぐに戻る(フェードなし) / back at once (no fade)
    30 return;
    31 }
    32 choose = in.actionPressed("confirm");
    33 }
    34 if (!choose) return;
    35 if (selected == 0) scenes().pop();
    36 // 全部外してタイトルだけに。フェード付き / clear everything and leave only the title, with a fade
    37 else scenes().replaceAll(std::make_unique<TitleScene>(d), {.duration = 0.8f});
    38 }
    39  
    40 void PauseScene::drawUi(float /*alpha*/) {
    41 SpriteBatch &b = d.batch;
    42 // 0.25秒かけて暗くする(シーン自身の演出:SceneManagerのフェードとは別) / darkens over 0.25 s (the scene's own
    43 // effect, separate from the SceneManager's fade)
    44 float t = std::min(1.0f, time / 0.25f);
    45 b.begin(d.screen.matrix());
    46 b.drawRect({0.0f, 0.0f, 1280.0f, 720.0f}, {0.03f, 0.02f, 0.06f, 0.65f * t});
    47 b.drawRect(Rect::fromCentre({640.0f, 360.0f}, {600.0f, 300.0f}), {0.11f, 0.09f, 0.16f, 0.95f * t});
    48 b.drawRectOutline(Rect::fromCentre({640.0f, 360.0f}, {600.0f, 300.0f}), {0.95f, 0.76f, 0.31f, t}, 3.0f);
    49 d.ui.draw(b, "一時停止 / PAUSED", {640.0f, 245.0f},
    50 {.color = {1.0f, 0.96f, 0.84f, t}, .scale = 3.0f, .align = TextAlign::Centre});
    51 for (int i = 0; i < 2; ++i) {
    52 Rect r = itemRect(i);
    53 if (i == selected) b.drawRect(r, {0.95f, 0.76f, 0.31f, 0.9f * t});
    54 Vec4 color = i == selected ? Vec4{0.1f, 0.08f, 0.15f, t} : Vec4{0.85f, 0.85f, 0.9f, t};
    55 d.ui.draw(b, kItems[i], {640.0f, r.y + 8.0f}, {.color = color, .scale = 2.0f, .align = TextAlign::Centre});
    56 }
    57 b.end();
    58 }

ファイル: /dev/null | b/demo/playground_scene.cc

前新
@@ -0,0 +1,226 @@
    1 // 遊び場:固定ステップの更新、行動への入力の割り当て、AABBの当たり判定、乱数
    2 // The playground: fixed-step updates, input actions, AABB collision, random numbers
    3 #include "demo.hh"
    4  
    5 #include "engine/collision.hh"
    6  
    7 #include <algorithm>
    8 #include <cmath>
    9 #include <cstdio>
    10 #include <memory>
    11  
    12 constexpr float kTile = 16.0f;
    13 constexpr float kSpeed = 90.0f; // ピクセル毎秒 / pixels per second
    14  
    15 // 壁と木箱の配置(20 × 11タイル、#=レンガの壁、C=木箱) / where walls and crates are (20 × 11 tiles, # = brick
    16 // wall, C = crate)
    17 static const char *const kLevel[] = {
    18 "####################",
    19 "#..................#",
    20 "#....C.........CC..#",
    21 "#....CC............#",
    22 "#..................#",
    23 "#...........CC.....#",
    24 "#............C.....#",
    25 "#..................#",
    26 "#........C.........#",
    27 "#..................#",
    28 "####################",
    29 };
    30  
    31 PlaygroundScene::PlaygroundScene(Demo &demo) : d(demo) {
    32 for (int row = 0; row < 11; ++row)
    33 for (int col = 0; col < 20; ++col) {
    34 Rect r = {kTile * static_cast<float>(col), kTile * static_cast<float>(row), kTile, kTile};
    35 if (kLevel[row][col] == '#') walls.push_back(r);
    36 if (kLevel[row][col] == 'C') crates.push_back(r);
    37 }
    38 solids = walls;
    39 solids.insert(solids.end(), crates.begin(), crates.end());
    40 // 当たり判定は絵(16×16)より小さい足元の箱:壁の隙間を通りやすい / the collision box is a foot box smaller than the
    41 // picture (16 × 16): it passes gaps more easily
    42 player = {40.0f, 70.0f, 10.0f, 8.0f};
    43 playerPrev = player.position();
    44 saw = Rect::fromCentre({60.0f, 9.0f * kTile + 4.0f}, {12.0f, 12.0f});
    45 sawPrevX = saw.x;
    46 }
    47  
    48 void PlaygroundScene::enter() {
    49 heroAnim.play(&d.idle);
    50 coins.resize(5);
    51 for (Coin &c : coins) placeCoin(c);
    52 }
    53  
    54 // 一時停止のシーンが上に載った:更新が止まるので、前の位置 = 今の位置にしておく(でないと補間で震える)
    55 // The pause scene went on top: updates stop, so make the previous position = the current one (otherwise the
    56 // interpolation would make things shake)
    57 void PlaygroundScene::pause() {
    58 playerPrev = player.position();
    59 sawPrevX = saw.x;
    60 }
    61  
    62 void PlaygroundScene::resume() { printf("playground: resumed\n"); }
    63  
    64 bool PlaygroundScene::blocked(const Rect &r) const {
    65 for (const Rect &s : solids)
    66 if (overlaps(r, s)) return true;
    67 return overlaps(r, player);
    68 }
    69  
    70 // 空いているタイルの真ん中にコインを置く(乱数、種26なので毎回同じ並び) / puts a coin in the middle of a free tile
    71 // (random, seed 26: the same sequence on every run)
    72 void PlaygroundScene::placeCoin(Coin &coin) {
    73 for (int tries = 0; tries < 100; ++tries) {
    74 int col = d.rng.range(1, 18), row = d.rng.range(1, 9);
    75 Rect cell = {kTile * static_cast<float>(col), kTile * static_cast<float>(row), kTile, kTile};
    76 if (blocked(cell)) continue;
    77 coin = {cell.centre(), d.rng.unit()};
    78 return;
    79 }
    80 }
    81  
    82 void PlaygroundScene::update(float dt) {
    83 time += dt;
    84 Input &in = d.input;
    85 if (in.pressed(GLFW_KEY_ESCAPE) || in.pressed(GLFW_KEY_P)) {
    86 scenes().push(std::make_unique<PauseScene>(d));
    87 return;
    88 }
    89 if (in.pressed(GLFW_KEY_B)) showBoxes = !showBoxes;
    90 if (in.pressed(GLFW_KEY_I)) d.interpolate = !d.interpolate;
    91 if (in.pressed(GLFW_KEY_U)) {
    92 // 更新の速さ:60 Hz ⇔ 10 Hz(補間の効き目がよく分かる) / update rate 60 Hz ⇔ 10 Hz (shows what interpolation does)
    93 d.loop.setStep(d.loop.step() < 0.05 ? 0.1 : 1.0 / 60.0);
    94 }
    95  
    96 // 主人公:行動の軸(左右・上下)で動き、壁と木箱に沿って滑る / the hero: moves by the action axes and slides along
    97 // walls and crates
    98 playerPrev = player.position();
    99 Vec2 move = {in.axis("left", "right"), in.axis("up", "down")};
    100 if (move.x != 0.0f) facingLeft = move.x < 0.0f;
    101 moveAndSlide(player, normalize(move) * (kSpeed * dt), solids);
    102 heroAnim.play(move.x != 0.0f || move.y != 0.0f ? &d.walk : &d.idle);
    103 heroAnim.update(dt);
    104  
    105 // 丸のこ:左右に往復。主人公に当たったらMTVで押し出す(ただし押し出した先が壁なら戻す)
    106 // The saw: goes back and forth. When it hits the hero, the hero is pushed out by the MTV (undone if that would put
    107 // the hero inside a wall)
    108 sawPrevX = saw.x;
    109 saw.x += sawDir * 70.0f * dt;
    110 if (saw.right() > 19.0f * kTile || saw.left() < kTile) sawDir = -sawDir;
    111 if (std::optional<Vec2> push = penetration(player, saw)) {
    112 Vec2 knock = *push + normalize(*push) * 6.0f; // 少し余分に弾く / bounce a little further
    113 moveAndSlide(player, knock, solids);
    114 if (hurt <= 0.0f) ++hits;
    115 hurt = 0.5f;
    116 }
    117 hurt = std::max(0.0f, hurt - dt);
    118  
    119 // コイン:重なったら拾う。紙吹雪(乱数の向きと速さ)と「+1」を出し、別の場所に置き直す
    120 // Coins: collected on overlap. Confetti (random directions and speeds) and a "+1", then the coin moves elsewhere
    121 for (Coin &c : coins) {
    122 Rect box = Rect::fromCentre(c.position, {10.0f, 10.0f});
    123 if (!overlaps(player, box)) continue;
    124 ++collected;
    125 for (int i = 0; i < 16; ++i) {
    126 Vec4 color = d.rng.chance(0.5f) ? hexColor(0xf2c14eff) : hexColor(0xffec96ff);
    127 particles.push_back({c.position, d.rng.direction() * d.rng.range(30.0f, 90.0f), d.rng.range(0.3f, 0.7f), color});
    128 }
    129 popups.push_back({c.position - Vec2{0.0f, 8.0f}, 0.8f});
    130 placeCoin(c);
    131 }
    132 for (Particle &p : particles) {
    133 p.position += p.velocity * dt;
    134 p.velocity.y += 160.0f * dt; // 落ちる / gravity
    135 p.life -= dt;
    136 }
    137 std::erase_if(particles, [](const Particle &p) { return p.life <= 0.0f; });
    138 for (Popup &p : popups) {
    139 p.position.y -= 20.0f * dt;
    140 p.life -= dt;
    141 }
    142 std::erase_if(popups, [](const Popup &p) { return p.life <= 0.0f; });
    143 }
    144  
    145 void PlaygroundScene::draw(float alpha) {
    146 // 補間:前のステップと今のステップの間のalphaの所に描く。Iで切ると、更新の瞬間の位置に飛び飛びに描く
    147 // Interpolation: draw at alpha between the previous and the current step. With I off, things jump to each update's
    148 // position
    149 float a = d.interpolate ? alpha : 1.0f;
    150 Vec2 p = lerp(playerPrev, player.position(), a);
    151 float sawX = sawPrevX + (saw.x - sawPrevX) * a;
    152  
    153 SpriteBatch &b = d.batch;
    154 b.begin(d.world.matrix(), SpriteSort::Layer);
    155 int stone = d.objects.find("stone"), brick = d.objects.find("brick"), crate = d.objects.find("crate");
    156 for (int row = 0; row < 12; ++row)
    157 for (int col = 0; col < 20; ++col) {
    158 bool wall = row >= 11 || kLevel[row][col] == '#';
    159 Sprite s = d.objects.sprite(wall ? brick : stone, {kTile * static_cast<float>(col), kTile * static_cast<float>(row)});
    160 if (!wall) s.color = hexColor(0xb8bccaff); // 床は少し暗く / the floor a little darker
    161 b.draw(s);
    162 }
    163 for (const Rect &c : crates) {
    164 Sprite s = d.objects.sprite(crate, c.position());
    165 s.layer = 1.0f;
    166 b.draw(s);
    167 }
    168 for (const Coin &c : coins) {
    169 int frame = d.coinSpin.frames[static_cast<size_t>((time + c.phase) * d.coinSpin.fps) % d.coinSpin.frames.size()];
    170 Sprite s = d.objects.sprite(frame, c.position, {0.5f, 0.5f});
    171 s.position.y += std::round(1.5f * std::sin(4.0f * time + 6.0f * c.phase));
    172 s.layer = 1.0f;
    173 b.draw(s);
    174 }
    175 Sprite sawSprite = d.objects.sprite(d.objects.find("saw"), Vec2{sawX, saw.y} + 0.5f * saw.size(), {0.5f, 0.5f});
    176 sawSprite.rotation = 8.0f * time;
    177 sawSprite.layer = 2.0f;
    178 b.draw(sawSprite);
    179 // 主人公の絵は足元の箱の下の中央に合わせる。当たった直後は赤く点滅 / the hero's picture is aligned to the bottom
    180 // center of the foot box. Flashes red right after a hit
    181 Sprite h = d.hero.sprite(heroAnim.frame(), {std::round(p.x + 0.5f * player.w), std::round(p.y + player.h)}, {0.5f, 1.0f});
    182 h.flipX = facingLeft;
    183 h.layer = 3.0f;
    184 if (hurt > 0.0f && std::fmod(hurt, 0.2f) > 0.1f) h.color = hexColor(0xff6060ff);
    185 b.draw(h);
    186 for (const Particle &pt : particles) {
    187 Vec4 c = pt.color;
    188 c.w = std::min(1.0f, pt.life * 4.0f);
    189 b.drawRect({std::round(pt.position.x), std::round(pt.position.y), 2.0f, 2.0f}, c, 4.0f);
    190 }
    191 // キャンバスの中の文字(1ビットのpixel12) / text inside the canvas (the 1-bit pixel12)
    192 for (const Popup &pp : popups)
    193 d.pixel.draw(b, "+1", pp.position,
    194 {.color = {1.0f, 0.93f, 0.55f, std::min(1.0f, pp.life * 3.0f)}, .align = TextAlign::Centre,
    195 .layer = 5.0f, .shadow = hexColor(0x1b1726ff)});
    196 if (showBoxes) {
    197 // 当たり判定の箱を見せる(B) / show the collision boxes (B)
    198 for (const Rect &s : solids) b.drawRectOutline(s, hexColor(0x40a0ffb0), 1.0f, 6.0f);
    199 b.drawRectOutline(Rect{p.x, p.y, player.w, player.h}, hexColor(0x40ff60ff), 1.0f, 6.0f);
    200 b.drawRectOutline(Rect{sawX, saw.y, saw.w, saw.h}, hexColor(0xff4040ff), 1.0f, 6.0f);
    201 for (const Coin &c : coins) b.drawRectOutline(Rect::fromCentre(c.position, {10.0f, 10.0f}), hexColor(0xffe040ff), 1.0f, 6.0f);
    202 }
    203 b.end();
    204 }
    205  
    206 void PlaygroundScene::drawUi(float /*alpha*/) {
    207 SpriteBatch &b = d.batch;
    208 const GameLoopStats &st = d.loop.stats();
    209 char line[256];
    210 snprintf(line, sizeof line, "FPS %.0f steps/frame %d alpha %.2f update %.0f Hz (U) interpolation %s (I)",
    211 static_cast<double>(st.fps), st.steps, static_cast<double>(st.alpha), 1.0 / d.loop.step(),
    212 d.interpolate ? "on" : "off");
    213 b.begin(d.screen.matrix());
    214 b.drawRect({0.0f, 0.0f, 1280.0f, 30.0f}, hexColor(0x1b1726d0));
    215 TextStyle hud = {.color = hexColor(0xfff4d6ff), .shadow = hexColor(0x000000ff)};
    216 d.ui.draw(b, line, {12.0f, 6.0f}, hud);
    217 snprintf(line, sizeof line, "コイン / coins %d 当たり / hits %d", collected, hits);
    218 hud.align = TextAlign::Right;
    219 hud.color = hexColor(0xf2c14eff);
    220 d.ui.draw(b, line, {1268.0f, 6.0f}, hud);
    221 b.drawRect({0.0f, 690.0f, 1280.0f, 30.0f}, hexColor(0x1b1726d0));
    222 hud.align = TextAlign::Centre;
    223 hud.color = hexColor(0xc8cce0ff);
    224 d.ui.draw(b, "arrows / WASD: move B: boxes I: interpolation U: 60 / 10 Hz P / Esc: pause", {640.0f, 696.0f}, hud);
    225 b.end();
    226 }

ファイル: /dev/null | b/demo/title_scene.cc

前新
@@ -0,0 +1,76 @@
    1 // タイトル画面 / the title screen
    2 #include "demo.hh"
    3  
    4 #include <cmath>
    5 #include <memory>
    6  
    7 void TitleScene::enter() {
    8 heroAnim.play(&d.walk);
    9 coinAnim.play(&d.coinSpin);
    10 }
    11  
    12 void TitleScene::update(float dt) {
    13 time += dt;
    14 heroAnim.update(dt);
    15 coinAnim.update(dt);
    16 heroPrevX = heroX;
    17 heroX += 40.0f * dt;
    18 if (heroX > 336.0f) heroPrevX = heroX = -16.0f; // 右から出たら左へ戻す(補間しない) / wrap around (no interpolation)
    19  
    20 // 始める:遊び場と入れ替え、0.8秒のフェード(暗くなって0.4秒で入れ替わり、0.4秒で明るくなる)
    21 // Start: replace with the playground, with a 0.8 s fade (0.4 s to black, switch, 0.4 s back)
    22 if (d.input.actionPressed("confirm") || d.input.mousePressed(GLFW_MOUSE_BUTTON_LEFT))
    23 scenes().replace(std::make_unique<PlaygroundScene>(d), {.duration = 0.8f});
    24 // スタックが空になればmainが終わらせる / main quits once the stack is empty
    25 if (d.input.pressed(GLFW_KEY_ESCAPE)) scenes().pop();
    26 }
    27  
    28 void TitleScene::draw(float alpha) {
    29 SpriteBatch &b = d.batch;
    30 b.begin(d.world.matrix(), SpriteSort::Layer);
    31 b.drawRect({0.0f, 0.0f, 320.0f, 180.0f}, hexColor(0x8fd3ffff), -1.0f);
    32 int cloud = d.objects.find("cloud");
    33 for (int i = 0; i < 4; ++i) {
    34 float x = std::fmod(20.0f + 95.0f * static_cast<float>(i) + 5.0f * time, 380.0f) - 40.0f;
    35 b.draw(d.objects.sprite(cloud, {std::round(x), 14.0f + 20.0f * static_cast<float>(i % 2)}));
    36 }
    37 int grass = d.objects.find("grass"), dirt = d.objects.find("dirt");
    38 for (int x = 0; x < 20; ++x) {
    39 Sprite g = d.objects.sprite(grass, {16.0f * static_cast<float>(x), 148.0f});
    40 Sprite s = d.objects.sprite(dirt, {16.0f * static_cast<float>(x), 164.0f});
    41 g.layer = s.layer = 1.0f;
    42 b.draw(g);
    43 b.draw(s);
    44 }
    45 for (int i = 0; i < 5; ++i) {
    46 Sprite c = d.objects.sprite(coinAnim.frame(), {112.0f + 20.0f * static_cast<float>(i), 128.0f});
    47 c.layer = 2.0f;
    48 b.draw(c);
    49 }
    50 // 描画は前と今の位置の間(alpha):更新が60 Hzでも画面のフレームに合わせて滑らか
    51 // Drawn between the previous and the current position (alpha): smooth at any frame rate with 60 Hz updates
    52 float x = d.interpolate ? heroPrevX + (heroX - heroPrevX) * alpha : heroX;
    53 Sprite h = d.hero.sprite(heroAnim.frame(), {std::round(x), 148.0f}, {0.5f, 1.0f});
    54 h.layer = 3.0f;
    55 b.draw(h);
    56 b.end();
    57 }
    58  
    59 void TitleScene::drawUi(float /*alpha*/) {
    60 SpriteBatch &b = d.batch;
    61 b.begin(d.screen.matrix());
    62 // 文字の後ろに半透明の帯:明るい空の上でも読める / a translucent band behind the text: readable over the bright sky
    63 b.drawRect({0.0f, 110.0f, 1280.0f, 330.0f}, hexColor(0x1b172699));
    64 const Vec4 shadow = hexColor(0x1b1726ff);
    65 d.ui.draw(b, "2D GAME TOOLKIT", {640.0f, 140.0f},
    66 {.color = hexColor(0xf2c14eff), .scale = 4.0f, .align = TextAlign::Centre, .shadow = shadow});
    67 d.ui.draw(b, "2Dゲームの道具箱(第26章) / Chapter 26", {640.0f, 240.0f},
    68 {.color = hexColor(0xfff4d6ff), .scale = 2.0f, .align = TextAlign::Centre, .shadow = shadow});
    69 // 点滅:時間で透明度を変える / blinking: the opacity follows the time
    70 float blink = 0.55f + 0.45f * std::cos(4.0f * time);
    71 d.ui.draw(b, "PRESS SPACE / スペースキーで開始", {640.0f, 330.0f},
    72 {.color = {1.0f, 1.0f, 1.0f, blink}, .scale = 2.0f, .align = TextAlign::Centre, .shadow = shadow});
    73 d.ui.draw(b, "Esc: quit / 終了", {640.0f, 395.0f},
    74 {.color = hexColor(0xc8cce0ff), .scale = 1.0f, .align = TextAlign::Centre, .shadow = shadow});
    75 b.end();
    76 }

ファイル: a/engine/CMakeLists.txt | b/engine/CMakeLists.txt

前新
@@ -40,7 +40,14 @@ add_library(engine STATIC
40 src/pixel_canvas.cc 40 src/pixel_canvas.cc
41 src/sprite_batch.cc 41 src/sprite_batch.cc
42 src/sprite_sheet.cc 42 src/sprite_sheet.cc
43 src/animation.cc) 43 src/animation.cc
    44 # 第26章:ゲームの道具 / chapter 26: the game toolkit
    45 src/font.cc
    46 src/input.cc
    47 src/game_loop.cc
    48 src/scene.cc
    49 src/collision.cc
    50 src/rng.cc)
44   51  
45 # PUBLIC:エンジンを使う側(ゲーム)にも include/、linalg.hh、GLAD、GLFWが見える 52 # PUBLIC:エンジンを使う側(ゲーム)にも include/、linalg.hh、GLAD、GLFWが見える
46 # PUBLIC: whoever links the engine (the games) also sees include/, linalg.hh, GLAD and GLFW 53 # PUBLIC: whoever links the engine (the games) also sees include/, linalg.hh, GLAD and GLFW

ファイル: /dev/null | b/engine/include/engine/collision.hh

前新
@@ -0,0 +1,40 @@
    1 // 2Dの当たり判定(第26章):軸に平行な箱(AABB = Rect)同士 / 2D collision (chapter 26): axis-aligned boxes (AABB =
    2 // Rect) against each other
    3 #pragma once
    4  
    5 #include "engine/rect.hh"
    6  
    7 #include <optional>
    8 #include <span>
    9  
    10 // 重なっているか。辺が接しているだけなら重ならない / do they overlap? Merely touching edges do not count
    11 bool overlaps(const Rect &a, const Rect &b);
    12 // 点が中にあるか(左・上の辺は含み、右・下の辺は含まない) / is the point inside (left/top edges included,
    13 // right/bottom excluded)?
    14 bool contains(const Rect &r, Vec2 point);
    15  
    16 // 最小移動ベクトル(MTV):aをこれだけ動かせばbから離れる。重なりの浅い方の軸に沿う。重なっていなければnullopt
    17 // The minimum translation vector (MTV): move a by this and it no longer overlaps b. Along the axis of the shallower
    18 // overlap. nullopt if they do not overlap
    19 std::optional<Vec2> penetration(const Rect &a, const Rect &b);
    20  
    21 // 動く箱の掃引テスト:movingがdeltaだけ動く間にtargetに当たるか。time = 0〜1(deltaの何割で当たるか)、
    22 // normal = 当たった面の向き(targetの外向き)。最初から重なっていればtime = 0、normal = (0, 0)
    23 // Swept test: does `moving` hit `target` while moving by delta? time = 0..1 (the fraction of delta at contact),
    24 // normal = the face that was hit (pointing out of target). Already overlapping: time = 0, normal = (0, 0)
    25 struct SweepHit {
    26 float time = 0.0f;
    27 Vec2 normal;
    28 };
    29 std::optional<SweepHit> sweep(const Rect &moving, Vec2 delta, const Rect &target);
    30  
    31 // 箱をdeltaだけ動かす:まずx、次にyの順に動かし、固い箱(solids)に当たったらその軸だけ止める(壁に沿って滑る)。
    32 // 1回の移動が箱より大きいとすり抜けることがある(速い物はsweepか、細かく分けて動かす)
    33 // Moves a box by delta: first along x, then along y; hitting a solid stops only that axis (the box slides along
    34 // walls). A move larger than the boxes can tunnel through (use sweep, or split fast moves into smaller ones)
    35 struct MoveResult {
    36 bool hitX = false, hitY = false;
    37 bool hitLeft = false, hitRight = false, hitTop = false, hitBottom = false; // どちら側が当たったか / which side
    38 // touched
    39 };
    40 MoveResult moveAndSlide(Rect &box, Vec2 delta, std::span<const Rect> solids);

ファイル: /dev/null | b/engine/include/engine/font.hh

前新
@@ -0,0 +1,76 @@
    1 // ビットマップフォント(第26章):文字の画像を並べたアトラス+BMFontのテキスト形式の説明(.fnt)
    2 // Bitmap fonts (chapter 26): an atlas of glyph images + a description in the BMFont text format (.fnt)
    3 #pragma once
    4  
    5 #include "engine/rect.hh"
    6 #include "engine/sprite_batch.hh"
    7 #include "engine/sprite_sheet.hh"
    8 #include "engine/texture.hh"
    9  
    10 #include <array>
    11 #include <optional>
    12 #include <string>
    13 #include <string_view>
    14 #include <unordered_map>
    15 #include <unordered_set>
    16  
    17 // 一文字の画像と置き方(ピクセル) / one glyph's image and placement (pixels)
    18 struct Glyph {
    19 Rect pixels; // アトラスの中の長方形 / rectangle in the atlas
    20 Vec2 offset; // 行の左上から画像の左上まで / from the line's top left to the image's top left
    21 float advance; // 次の文字までの幅 / distance to the next character
    22 };
    23  
    24 enum class TextAlign { Left, Centre, Right };
    25  
    26 struct TextStyle {
    27 Vec4 color = kWhite;
    28 float scale = 1.0f; // 1 = アトラスのピクセルのまま / 1 = the atlas's own pixels
    29 TextAlign align = TextAlign::Left; // 行ごとに:positionが左端・中央・右端 / per line: position is the left edge,
    30 // center or right edge
    31 float layer = 0.0f; // SpriteSort::Layer用 / for SpriteSort::Layer
    32 Vec4 shadow = {0.0f, 0.0f, 0.0f, 0.0f}; // 影の色(アルファ0 = 影なし) / shadow color (alpha 0 = no shadow)
    33 Vec2 shadowOffset = {1.0f, 1.0f}; // 影のずれ(scale倍される) / shadow offset (multiplied by scale)
    34 // 文字をワールドの整数座標にそろえる:拡大率1でピクセルにぴったり乗り、ぼけない / snap glyphs to whole world units:
    35 // at scale 1 they sit exactly on pixels and stay sharp
    36 bool snap = true;
    37 };
    38  
    39 // UTF-8の文字列から一文字(コードポイント)を読み、iを進める。壊れたバイトはU+FFFD
    40 // Reads one character (code point) from a UTF-8 string and advances i. Broken bytes give U+FFFD
    41 char32_t decodeUtf8(std::string_view text, size_t &i);
    42  
    43 // ビットマップフォント(RAII、コピー不可・移動可)。文字はSpriteBatchで一枚ずつスプライトとして描く
    44 // A bitmap font (RAII, non-copyable, movable). Each character is drawn as one sprite through the SpriteBatch
    45 class Font {
    46 public:
    47 // .fntを読み、page行の画像(.fntと同じフォルダ)を読む。ピクセルフォントはTextureFilter::Nearestで
    48 // Loads the .fnt and the image named by its page line (in the same folder). Use TextureFilter::Nearest for pixel
    49 // fonts
    50 static std::optional<Font> load(const std::string &fntPath, TextureFilter filter = TextureFilter::Linear);
    51  
    52 // 文字列の大きさ:幅 = 一番長い行、高さ = 行数 × lineHeight(× scale) / the size of a string: width = the widest
    53 // line, height = lines × lineHeight (× scale)
    54 Vec2 measure(std::string_view utf8, float scale = 1.0f) const;
    55 // positionは1行目の上端(y下向き)。alignで横の基準が変わる。\nで改行
    56 // position is the top of the first line (y down); align changes the horizontal reference. \n starts a new line
    57 void draw(SpriteBatch &batch, std::string_view utf8, Vec2 position, const TextStyle &style = {}) const;
    58  
    59 // なければnullptr / nullptr if missing
    60 const Glyph *glyph(char32_t c) const;
    61 float lineHeight() const { return lineGap; }
    62 float base() const { return baseline; } // 行の上端からベースラインまで / from the line's top to the baseline
    63 const Texture2D &texture() const { return image; }
    64  
    65 private:
    66 Font() = default;
    67 float lineWidth(std::string_view utf8, size_t start) const;
    68 const Glyph &glyphOrFallback(char32_t c) const;
    69  
    70 Texture2D image;
    71 std::array<Glyph, 128> ascii = {}; // 速く引けるように / fast lookup
    72 std::array<bool, 128> hasAscii = {};
    73 std::unordered_map<char32_t, Glyph> others;
    74 float lineGap = 0.0f, baseline = 0.0f;
    75 mutable std::unordered_set<char32_t> warned; // ない文字は一度だけ警告 / warn once per missing character
    76 };

ファイル: /dev/null | b/engine/include/engine/game_loop.hh

前新
@@ -0,0 +1,66 @@
    1 // 固定ステップのゲームループ(第26章):更新は決まった間隔(既定1/60秒)で、描画はできるだけ速く
    2 // The fixed-timestep game loop (chapter 26): updates at a fixed interval (1/60 s by default), drawing as often as
    3 // possible
    4 #pragma once
    5  
    6 #include "engine/input.hh"
    7 #include "engine/window.hh"
    8  
    9 #include <algorithm>
    10 #include <functional>
    11  
    12 struct GameLoopSettings {
    13 double step = 1.0 / 60.0; // 更新1回の時間(秒) / seconds per update
    14 // 1フレームで追いつく更新の上限。超えた分の時間は捨てる(遅いPCで「死のスパイラル」にならないように)
    15 // The most updates run in one frame to catch up; time beyond that is dropped (no "spiral of death" on slow PCs)
    16 int maxSteps = 5;
    17 // これより長いフレーム(デバッガーで止めた等)は、この長さだったことにする / longer frames (e.g. stopped in a
    18 // debugger) count as this long
    19 double maxFrame = 0.25;
    20 // フレームの時間がステップの整数倍にこれだけ近ければ、ちょうどにする(60 Hzの画面で16.4〜16.9 msを16.67 msに)。
    21 // 揺れで更新が0回・2回と交互になるのを防ぐ。貯金がステップにこれだけ足りないときも更新する(maxStepsで
    22 // 捨てるときも1ステップと数える)
    23 // Snap a frame's duration to a whole number of steps when it is this close (16.4-16.9 ms become 16.67 ms on a
    24 // 60 Hz screen); stops jitter from alternating 0 and 2 updates. An accumulator this close to a step also updates
    25 // (and counts as a whole step when time is dropped at maxSteps)
    26 double snapTolerance = 0.0002;
    27 };
    28  
    29 struct GameLoopStats {
    30 int steps = 0; // 前のフレームの更新の回数 / updates in the last frame
    31 long long totalSteps = 0; // 始めてからの更新の回数 / updates since the start
    32 float alpha = 0.0f; // 前のフレームの補間の割合 / the last frame's interpolation factor
    33 float fps = 0.0f; // 1秒あたりのフレーム数(0.5秒ごとに計算) / frames per second (computed every 0.5 s)
    34 double droppedSeconds = 0.0; // maxSteps・maxFrameで捨てた時間の合計 / total time dropped by maxSteps / maxFrame
    35 };
    36  
    37 // 固定ステップのループ:経過時間を「貯金」(accumulator)に足し、stepずつ引きながら更新する。残りの割合が
    38 // alpha(0〜1):描画では前の状態と今の状態の間をalphaで補間すると、更新と描画の速さが違っても滑らかに動く
    39 // The fixed-step loop: elapsed time goes into an accumulator, and every update takes `step` out of it. What is left,
    40 // as a fraction of a step, is alpha (0..1): drawing between the previous and the current state with alpha keeps motion
    41 // smooth even when updates and frames run at different rates
    42 class GameLoop {
    43 public:
    44 explicit GameLoop(const GameLoopSettings &settings = {}) : config(settings) {}
    45  
    46 // ウィンドウが閉じるまで:イベント → update(step)を0回以上(毎回の後にinput.endStep()) → draw(alpha) → 表示
    47 // Until the window closes: events → update(step) zero or more times (input.endStep() after each) → draw(alpha) →
    48 // present
    49 void run(Window &window, Input &input, const std::function<void(float dt)> &update,
    50 const std::function<void(float alpha)> &draw);
    51  
    52 // 1フレーム分の計算だけ(runが使う。自分でループを書くときにも):frameSecondsを足し、今回の更新の回数を返す
    53 // One frame's arithmetic only (run uses it; also for a hand-written loop): adds frameSeconds and returns how many
    54 // updates to run now
    55 int advance(double frameSeconds);
    56 float alpha() const { return static_cast<float>(std::clamp(accumulator / config.step, 0.0, 1.0)); }
    57  
    58 double step() const { return config.step; }
    59 void setStep(double seconds) { config.step = seconds; }
    60 const GameLoopStats &stats() const { return info; }
    61  
    62 private:
    63 GameLoopSettings config;
    64 GameLoopStats info;
    65 double accumulator = 0.0;
    66 };

ファイル: /dev/null | b/engine/include/engine/input.hh

前新
@@ -0,0 +1,89 @@
    1 // 入力の状態(第26章):キーとマウスボタンの「押した・押している・離した」と、行動(アクション)への割り当て
    2 // Input state (chapter 26): pressed / held / released for keys and mouse buttons, plus mapping them to actions
    3 #pragma once
    4  
    5 #include "engine/mathx.hh"
    6 #include "engine/window.hh"
    7  
    8 #include <array>
    9 #include <cstdint>
    10 #include <initializer_list>
    11 #include <string>
    12 #include <string_view>
    13 #include <vector>
    14  
    15 // 行動に割り当てるもの:キー(GLFW_KEY_…)かマウスボタン(GLFW_MOUSE_BUTTON_…)
    16 // What an action is bound to: a key (GLFW_KEY_...) or a mouse button (GLFW_MOUSE_BUTTON_...)
    17 struct InputBinding {
    18 enum class Device { Key, MouseButton } device = Device::Key;
    19 int code = 0;
    20  
    21 static InputBinding key(int k) { return {Device::Key, k}; }
    22 static InputBinding mouse(int button) { return {Device::MouseButton, button}; }
    23 };
    24  
    25 // 入力(コピー・移動不可:Windowのコールバックがthisを持つ)。使い方:
    26 // Input input; input.attach(window); // ウィンドウのonKey・onMouseButton・onScrollを引き受ける
    27 // … 更新の中で input.pressed(GLFW_KEY_SPACE)、input.actionHeld("left") …
    28 // input.endStep(); // 更新1ステップの後(GameLoopが呼ぶ)
    29 // 「押した」「離した」はイベント(コールバック)で覚えておき、次の更新ステップで一度だけtrueになる:
    30 // 1フレームの間に押して離しても取りこぼさず、更新がないフレームでも消えない。
    31 // Input (neither copyable nor movable: the Window's callbacks hold `this`). Usage:
    32 // Input input; input.attach(window); // takes over the window's onKey, onMouseButton and onScroll
    33 // ... in the update: input.pressed(GLFW_KEY_SPACE), input.actionHeld("left") ...
    34 // input.endStep(); // after each update step (GameLoop calls it)
    35 // "Pressed" and "released" are recorded from events (callbacks) and are true during exactly one update step: a tap
    36 // shorter than a frame is not lost, and frames without an update step do not drop it.
    37 class Input {
    38 public:
    39 Input() = default;
    40 Input(const Input &) = delete;
    41 Input &operator=(const Input &) = delete;
    42  
    43 void attach(Window &window);
    44 // 「押した」「離した」とホイールを消す。更新1ステップの後に呼ぶ / clears pressed, released and the scroll; call it
    45 // after each update step
    46 void endStep();
    47  
    48 // キー(GLFW_KEY_…) / keys (GLFW_KEY_...)
    49 bool held(int key) const { return valid(key) && keys[static_cast<size_t>(key)].down; }
    50 bool pressed(int key) const { return valid(key) && keys[static_cast<size_t>(key)].pressed; }
    51 bool released(int key) const { return valid(key) && keys[static_cast<size_t>(key)].released; }
    52 // マウス(GLFW_MOUSE_BUTTON_…、位置はウィンドウのピクセルで左上が原点) / the mouse (GLFW_MOUSE_BUTTON_...; the
    53 // position is in window pixels, origin top left)
    54 bool mouseHeld(int button) const { return validButton(button) && buttons[static_cast<size_t>(button)].down; }
    55 bool mousePressed(int button) const { return validButton(button) && buttons[static_cast<size_t>(button)].pressed; }
    56 bool mouseReleased(int button) const { return validButton(button) && buttons[static_cast<size_t>(button)].released; }
    57 Vec2 mousePosition() const;
    58 float scroll() const { return scrollSum; } // 前のステップからの回転量 / scrolled since the last step
    59  
    60 // 行動("left"、"jump"…)。同じ名前に何度もbindすると割り当てが増える / actions ("left", "jump"...). Binding the
    61 // same name again adds more bindings
    62 void bind(std::string_view action, std::initializer_list<InputBinding> bindings);
    63 bool actionHeld(std::string_view action) const;
    64 bool actionPressed(std::string_view action) const;
    65 bool actionReleased(std::string_view action) const;
    66 // -1〜1:negativeが押されていれば-1、positiveなら+1、両方なら0 / -1..1: -1 while negative is held, +1 for
    67 // positive, 0 for both
    68 float axis(std::string_view negative, std::string_view positive) const;
    69  
    70 private:
    71 struct State {
    72 bool down = false, pressed = false, released = false;
    73 };
    74 struct Action {
    75 std::string name;
    76 std::vector<InputBinding> bindings;
    77 };
    78 static bool valid(int key) { return key >= 0 && key <= GLFW_KEY_LAST; }
    79 static bool validButton(int b) { return b >= 0 && b <= GLFW_MOUSE_BUTTON_LAST; }
    80 static void apply(State &s, int action);
    81 const Action *find(std::string_view name) const;
    82 const State &state(const InputBinding &b) const;
    83  
    84 Window *window = nullptr;
    85 std::array<State, GLFW_KEY_LAST + 1> keys = {};
    86 std::array<State, GLFW_MOUSE_BUTTON_LAST + 1> buttons = {};
    87 float scrollSum = 0.0f;
    88 std::vector<Action> actions;
    89 };

ファイル: /dev/null | b/engine/include/engine/rng.hh

前新
@@ -0,0 +1,49 @@
    1 // 乱数(第26章):種(シード)を決めれば毎回同じ並び。std::mt19937の包み / random numbers (chapter 26): the same
    2 // sequence for the same seed. A wrapper around std::mt19937
    3 #pragma once
    4  
    5 #include "engine/mathx.hh"
    6  
    7 #include <cmath>
    8 #include <cstdint>
    9 #include <random>
    10 #include <span>
    11  
    12 // std::mt19937の出す数は規格で決まっている(どのコンパイラでも同じ)。でもstd::uniform_int_distributionなどの
    13 // 分布は実装ごとに違う:同じ種でもMSVCとGCCで別の結果になる。リプレイやテストのために、範囲への変換は自分で書く
    14 // The numbers std::mt19937 produces are fixed by the standard (identical with every compiler), but distributions
    15 // such as std::uniform_int_distribution differ per implementation: the same seed gives different results with MSVC
    16 // and GCC. For replays and tests we write the mapping to ranges ourselves
    17 class Rng {
    18 public:
    19 explicit Rng(std::uint32_t seed = 1) : engine(seed) {}
    20 void seed(std::uint32_t s) { engine.seed(s); }
    21  
    22 std::uint32_t next() { return static_cast<std::uint32_t>(engine()); } // 32ビット / 32 bits
    23 // [0, 1):上の24ビットだけ使う(floatの仮数に収まる) / [0, 1): uses the top 24 bits (they fit a float's mantissa)
    24 float unit() { return static_cast<float>(next() >> 8) * (1.0f / 16777216.0f); }
    25 // [lo, hi)。丸めでhiちょうどになることがある(例:range(100, 101)でunit()が1に近いとき)ので、そのときはhiの一つ手前の
    26 // float / [lo, hi). Rounding can land exactly on hi (e.g. range(100, 101) with unit() close to 1): then it returns
    27 // the float just below hi
    28 float range(float lo, float hi) {
    29 float r = lo + (hi - lo) * unit();
    30 return r >= hi && hi > lo ? std::nextafter(hi, lo) : r;
    31 }
    32 // [lo, hi](両端を含む)。棄却法で偏りなし / [lo, hi] (both included). Unbiased, by rejection
    33 int range(int lo, int hi);
    34 // 確率pでtrue / true with probability p
    35 bool chance(float p) { return unit() < p; }
    36 // 長さ1のランダムな向き / a random direction of length 1
    37 Vec2 direction();
    38  
    39 // 配列から一つ選ぶ(空でないこと) / picks one element (the span must not be empty)
    40 template <typename T>
    41 const T &pick(std::span<const T> items) {
    42 return items[static_cast<size_t>(range(0, static_cast<int>(items.size()) - 1))];
    43 }
    44  
    45 std::mt19937 &raw() { return engine; } // std::shuffleなどに / for std::shuffle and friends
    46  
    47 private:
    48 std::mt19937 engine;
    49 };

ファイル: /dev/null | b/engine/include/engine/scene.hh

前新
@@ -0,0 +1,109 @@
    1 // シーン(第26章):タイトル・ゲーム本体・一時停止…を別々のクラスにして、スタックで切り替える
    2 // Scenes (chapter 26): the title, the game itself, the pause menu... as separate classes, switched with a stack
    3 #pragma once
    4  
    5 #include "engine/mathx.hh"
    6 #include "engine/sprite_batch.hh"
    7  
    8 #include <memory>
    9 #include <vector>
    10  
    11 class SceneManager;
    12  
    13 // シーンの基底クラス。必要なフックだけ上書きする。ゲームの共有データ(バッチ、フォント、入力…)は
    14 // 各ゲームが自分のコンストラクターで渡す(エンジンは中身を知らない)
    15 // The scene base class; override the hooks you need. A game's shared data (batch, fonts, input...) is passed in by
    16 // each game through its own constructors (the engine does not know what it is)
    17 class Scene {
    18 public:
    19 virtual ~Scene() = default;
    20  
    21 virtual void enter() {} // スタックに載った / was put on the stack
    22 virtual void exit() {} // スタックから外される直前 / is about to be removed from the stack
    23 virtual void pause() {} // 上に別のシーンが載った / another scene was pushed on top
    24 virtual void resume() {} // 上のシーンが外れて、また一番上になった / the scene above was popped; on top again
    25 // 固定ステップの更新(一番上のシーンだけ) / the fixed-step update (top scene only)
    26 virtual void update(float dt) = 0;
    27 // 描画:世界(キャンバスなど)とUI(画面の解像度の文字など)の2回。下から上の順に呼ばれる
    28 // Drawing in two passes: the world (into a canvas, say) and the UI (text at screen resolution, say). Called bottom
    29 // to top
    30 virtual void draw(float alpha) = 0;
    31 virtual void drawUi(float /*alpha*/) {}
    32 // trueなら下のシーンも描かれる(一時停止のメニューなど、上に重ねるシーン) / true: the scenes below are drawn too
    33 // (overlays such as a pause menu)
    34 virtual bool isOverlay() const { return false; }
    35  
    36 protected:
    37 // このシーンを持つマネージャー:scenes().push(…)などで切り替えを頼む / the manager that owns this scene: ask it for
    38 // changes with scenes().push(...) etc.
    39 SceneManager &scenes() const { return *owner; }
    40  
    41 private:
    42 friend class SceneManager;
    43 SceneManager *owner = nullptr;
    44 };
    45  
    46 // 切り替えの演出:duration秒かけてcolorに塗りつぶし(フェードアウト)、切り替えて、元に戻す(フェードイン)。
    47 // duration = 0なら一瞬で切り替える
    48 // A transition: fade to `color` over half of `duration` (fade out), switch, and fade back (fade in).
    49 // duration = 0 switches at once
    50 struct Transition {
    51 float duration = 0.0f;
    52 Vec4 color = {0.0f, 0.0f, 0.0f, 1.0f};
    53 };
    54  
    55 // シーンのスタック。push・pop・replaceは「頼む」だけで、今の更新が終わってから(フェードならフェードアウトの後で)
    56 // 実行される:update()の途中でシーンが消えることはない
    57 // The scene stack. push, pop and replace only *request* a change; it happens after the current update (after the
    58 // fade out, with a fade): a scene is never deleted in the middle of its own update()
    59 class SceneManager {
    60 public:
    61 SceneManager() = default;
    62 SceneManager(const SceneManager &) = delete;
    63 SceneManager &operator=(const SceneManager &) = delete;
    64  
    65 void push(std::unique_ptr<Scene> scene, Transition transition = {});
    66 void pop(Transition transition = {});
    67 void replace(std::unique_ptr<Scene> scene, Transition transition = {}); // 一番上を入れ替える / swaps the top
    68 void replaceAll(std::unique_ptr<Scene> scene, Transition transition = {}); // 全部外して載せる / clears, then pushes
    69  
    70 // 切り替えを進め、一番上のシーンを更新する(フェードアウトの間は誰も更新しない)
    71 // Advances changes and fades, and updates the top scene (nobody is updated during a fade out)
    72 void update(float dt);
    73 // 一番上から下へ、覆い隠さないシーン(isOverlay)が続く所まで遡って、下から順に描く。フェードアウトの間は
    74 // alpha = 1(止まった今の状態)で描く
    75 // Draws from the lowest visible scene up: below the top scene for as long as the scenes above are overlays.
    76 // During a fade out the scenes are drawn with alpha = 1 (the frozen current state)
    77 void draw(float alpha);
    78 void drawUi(float alpha);
    79 // 画面全体をフェードの色で塗る(UIの後に)。viewSizeはcameraMatrixの仮想画面の大きさ
    80 // Covers the screen with the fade color (after the UI). viewSize is the virtual screen of cameraMatrix
    81 void drawFade(SpriteBatch &batch, const Mat4 &cameraMatrix, Vec2 viewSize) const;
    82  
    83 // 0 = 塗りなし 〜 1 = 全部フェードの色 / 0 = no cover .. 1 = completely the fade color
    84 float fadeAmount() const;
    85 bool transitioning() const { return phase != Phase::None || !pending.empty(); }
    86 bool empty() const { return stack.empty() && pending.empty(); }
    87 size_t size() const { return stack.size(); }
    88 Scene *top() const { return stack.empty() ? nullptr : stack.back().get(); }
    89  
    90 private:
    91 enum class Op { Push, Pop, Replace, ReplaceAll };
    92 struct Request {
    93 Op op;
    94 std::unique_ptr<Scene> scene;
    95 Transition transition;
    96 };
    97 enum class Phase { None, Out, In };
    98  
    99 void request(Op op, std::unique_ptr<Scene> scene, Transition transition);
    100 void apply(Request &r);
    101 size_t firstVisible() const;
    102 float drawAlpha(float alpha) const;
    103  
    104 std::vector<std::unique_ptr<Scene>> stack;
    105 std::vector<Request> pending;
    106 Phase phase = Phase::None;
    107 float phaseTime = 0.0f;
    108 Transition current;
    109 };

ファイル: /dev/null | b/engine/src/collision.cc

前新
@@ -0,0 +1,85 @@
    1 #include "engine/collision.hh"
    2  
    3 #include <algorithm>
    4 #include <cmath>
    5 #include <limits>
    6  
    7 bool overlaps(const Rect &a, const Rect &b) {
    8 return a.left() < b.right() && b.left() < a.right() && a.top() < b.bottom() && b.top() < a.bottom();
    9 }
    10  
    11 bool contains(const Rect &r, Vec2 p) { return p.x >= r.left() && p.x < r.right() && p.y >= r.top() && p.y < r.bottom(); }
    12  
    13 std::optional<Vec2> penetration(const Rect &a, const Rect &b) {
    14 if (!overlaps(a, b)) return std::nullopt;
    15 // 左右・上下それぞれ、どちらへ押し出すと近いか / for each axis, which way out is shorter
    16 float pushLeft = b.left() - a.right(), pushRight = b.right() - a.left(); // < 0 と > 0
    17 float pushUp = b.top() - a.bottom(), pushDown = b.bottom() - a.top();
    18 float dx = -pushLeft < pushRight ? pushLeft : pushRight;
    19 float dy = -pushUp < pushDown ? pushUp : pushDown;
    20 // 浅い方の軸だけで押し出す / push out along the shallower axis only
    21 if (std::fabs(dx) < std::fabs(dy)) return Vec2{dx, 0.0f};
    22 return Vec2{0.0f, dy};
    23 }
    24  
    25 std::optional<SweepHit> sweep(const Rect &moving, Vec2 delta, const Rect &target) {
    26 if (overlaps(moving, target)) return SweepHit{0.0f, {0.0f, 0.0f}};
    27 // targetをmovingの大きさだけ太らせると(ミンコフスキー和)、movingの左上の点が動く線分と箱の交差になる
    28 // Growing target by moving's size (a Minkowski sum) turns this into a ray (moving's top-left point) against a box
    29 Rect grown = {target.x - moving.w, target.y - moving.h, target.w + moving.w, target.h + moving.h};
    30 constexpr float kInf = std::numeric_limits<float>::infinity();
    31 float enter = -kInf, leave = kInf;
    32 Vec2 normal;
    33 // スラブ法:軸ごとに入る時間と出る時間 / the slab method: entry and exit time per axis
    34 for (int axis = 0; axis < 2; ++axis) {
    35 float p = axis == 0 ? moving.x : moving.y, d = axis == 0 ? delta.x : delta.y;
    36 float lo = axis == 0 ? grown.left() : grown.top(), hi = axis == 0 ? grown.right() : grown.bottom();
    37 if (d == 0.0f) {
    38 if (p <= lo || p >= hi) return std::nullopt; // この軸で一度も重ならない / never overlaps on this axis
    39 continue;
    40 }
    41 float t0 = (lo - p) / d, t1 = (hi - p) / d;
    42 if (t0 > t1) std::swap(t0, t1);
    43 if (t0 > enter) {
    44 enter = t0;
    45 normal = axis == 0 ? Vec2{d > 0.0f ? -1.0f : 1.0f, 0.0f} : Vec2{0.0f, d > 0.0f ? -1.0f : 1.0f};
    46 }
    47 leave = std::min(leave, t1);
    48 }
    49 // enter == leaveは角をかすめるだけ(接するが重ならない):overlapsと同じく当たりではない
    50 // enter == leave only grazes a corner (touching, never overlapping): like overlaps, not a hit
    51 if (enter >= leave || enter < 0.0f || enter > 1.0f) return std::nullopt;
    52 return SweepHit{enter, normal};
    53 }
    54  
    55 MoveResult moveAndSlide(Rect &box, Vec2 delta, std::span<const Rect> solids) {
    56 MoveResult result;
    57 // x:動いてから、重なった固い箱の手前に戻す / x: move, then back out of every solid it now overlaps
    58 box.x += delta.x;
    59 for (const Rect &s : solids) {
    60 if (!overlaps(box, s)) continue;
    61 if (delta.x > 0.0f) {
    62 box.x = s.left() - box.w;
    63 result.hitRight = true;
    64 } else if (delta.x < 0.0f) {
    65 box.x = s.right();
    66 result.hitLeft = true;
    67 }
    68 result.hitX = true;
    69 }
    70 // y:同じように(y下向き:正 = 下へ、下で当たる = 地面に立った) / y: the same (y down: positive = downwards; hitting
    71 // below = standing on the ground)
    72 box.y += delta.y;
    73 for (const Rect &s : solids) {
    74 if (!overlaps(box, s)) continue;
    75 if (delta.y > 0.0f) {
    76 box.y = s.top() - box.h;
    77 result.hitBottom = true;
    78 } else if (delta.y < 0.0f) {
    79 box.y = s.bottom();
    80 result.hitTop = true;
    81 }
    82 result.hitY = true;
    83 }
    84 return result;
    85 }

ファイル: /dev/null | b/engine/src/font.cc

前新
@@ -0,0 +1,191 @@
    1 #include "engine/font.hh"
    2  
    3 #include "engine/file_util.hh"
    4  
    5 #include <algorithm>
    6 #include <cmath>
    7 #include <cstdio>
    8 #include <cstdlib>
    9 #include <sstream>
    10  
    11 char32_t decodeUtf8(std::string_view s, size_t &i) {
    12 auto byte = [&](size_t k) { return static_cast<unsigned char>(s[k]); };
    13 unsigned char b0 = byte(i++);
    14 if (b0 < 0x80) return b0; // ASCII
    15 // 先頭バイトの上のビットで長さが決まる:110xxxxx = 2、1110xxxx = 3、11110xxx = 4バイト
    16 // The leading byte's top bits give the length: 110xxxxx = 2, 1110xxxx = 3, 11110xxx = 4 bytes
    17 int extra = (b0 & 0xE0) == 0xC0 ? 1 : (b0 & 0xF0) == 0xE0 ? 2 : (b0 & 0xF8) == 0xF0 ? 3 : -1;
    18 if (extra < 0 || i + static_cast<size_t>(extra) > s.size()) return 0xFFFD;
    19 char32_t c = b0 & (0x3F >> extra);
    20 for (int k = 0; k < extra; ++k) {
    21 unsigned char b = byte(i);
    22 if ((b & 0xC0) != 0x80) return 0xFFFD; // 続きのバイトは10xxxxxx / continuation bytes are 10xxxxxx
    23 c = (c << 6) | (b & 0x3F);
    24 ++i;
    25 }
    26 return c;
    27 }
    28  
    29 // BMFontの1行の key=value を読む(file="…" の引用符も) / reads the key=value pairs of one BMFont line (also quoted
    30 // file="...")
    31 static std::unordered_map<std::string, std::string> parseFields(const std::string &line) {
    32 std::unordered_map<std::string, std::string> fields;
    33 size_t i = line.find(' ');
    34 while (i != std::string::npos && i < line.size()) {
    35 while (i < line.size() && line[i] == ' ') ++i;
    36 size_t eq = line.find('=', i);
    37 if (eq == std::string::npos) break;
    38 std::string key = line.substr(i, eq - i);
    39 size_t end;
    40 std::string value;
    41 if (eq + 1 < line.size() && line[eq + 1] == '"') {
    42 end = line.find('"', eq + 2);
    43 if (end == std::string::npos) end = line.size();
    44 value = line.substr(eq + 2, end - eq - 2);
    45 ++end;
    46 } else {
    47 end = line.find(' ', eq + 1);
    48 value = line.substr(eq + 1, end == std::string::npos ? std::string::npos : end - eq - 1);
    49 }
    50 fields[key] = value;
    51 i = end;
    52 }
    53 return fields;
    54 }
    55  
    56 std::optional<Font> Font::load(const std::string &fntPath, TextureFilter filter) {
    57 std::optional<std::string> text = readTextFile(fntPath);
    58 if (!text) {
    59 fprintf(stderr, "%s: 読めない / cannot read (プロジェクトのルートから実行した? / running from the project root?)\n",
    60 fntPath.c_str());
    61 return std::nullopt;
    62 }
    63 Font font;
    64 std::string pageFile;
    65 std::istringstream lines(*text);
    66 std::string line;
    67 int lineNumber = 0, glyphs = 0;
    68 while (std::getline(lines, line)) {
    69 ++lineNumber;
    70 if (!line.empty() && line.back() == '\r') line.pop_back();
    71 std::string tag = line.substr(0, line.find(' '));
    72 auto f = parseFields(line);
    73 auto number = [&](const char *key) {
    74 auto it = f.find(key);
    75 return it == f.end() ? 0.0f : std::strtof(it->second.c_str(), nullptr);
    76 };
    77 if (tag == "common") {
    78 font.lineGap = number("lineHeight");
    79 font.baseline = number("base");
    80 if (number("pages") > 1) fprintf(stderr, "%s: 最初のページだけ使う / only the first page is used\n", fntPath.c_str());
    81 } else if (tag == "page") {
    82 if (number("id") == 0) pageFile = f["file"];
    83 } else if (tag == "char") {
    84 if (f.find("id") == f.end()) {
    85 fprintf(stderr, "%s:%d: idのないchar / char without id\n", fntPath.c_str(), lineNumber);
    86 return std::nullopt;
    87 }
    88 char32_t id = static_cast<char32_t>(std::strtoul(f["id"].c_str(), nullptr, 10));
    89 Glyph g{{number("x"), number("y"), number("width"), number("height")},
    90 {number("xoffset"), number("yoffset")}, number("xadvance")};
    91 if (id < 128) {
    92 font.ascii[id] = g;
    93 font.hasAscii[id] = true;
    94 } else {
    95 font.others[id] = g;
    96 }
    97 ++glyphs;
    98 }
    99 // info, chars, kerning… は使わない(等幅フォントなのでカーニングなし) / info, chars, kerning... are not used
    100 // (monospaced fonts need no kerning)
    101 }
    102 if (pageFile.empty() || glyphs == 0 || font.lineGap <= 0.0f) {
    103 fprintf(stderr, "%s: BMFontのテキスト形式ではない? / not a BMFont text file? (page, char, common lineHeight)\n",
    104 fntPath.c_str());
    105 return std::nullopt;
    106 }
    107 size_t slash = fntPath.find_last_of("/\\");
    108 std::string folder = slash == std::string::npos ? "" : fntPath.substr(0, slash + 1);
    109 std::optional<Texture2D> texture = loadSpriteTexture(folder + pageFile, filter);
    110 if (!texture) return std::nullopt;
    111 font.image = std::move(*texture);
    112 return font;
    113 }
    114  
    115 const Glyph *Font::glyph(char32_t c) const {
    116 if (c < 128) return hasAscii[c] ? &ascii[c] : nullptr;
    117 auto it = others.find(c);
    118 return it == others.end() ? nullptr : &it->second;
    119 }
    120  
    121 const Glyph &Font::glyphOrFallback(char32_t c) const {
    122 if (const Glyph *g = glyph(c)) return *g;
    123 if (warned.insert(c).second) fprintf(stderr, "フォントにない文字 / character not in the font: U+%04X\n", static_cast<unsigned>(c));
    124 // 代わりに「?」(それもなければ空白の幅) / a "?" instead (or the width of a space if even that is missing)
    125 if (const Glyph *q = glyph(U'?')) return *q;
    126 static const Glyph empty{{0, 0, 0, 0}, {0, 0}, 0};
    127 return empty;
    128 }
    129  
    130 float Font::lineWidth(std::string_view s, size_t i) const {
    131 float width = 0.0f;
    132 while (i < s.size()) {
    133 char32_t c = decodeUtf8(s, i);
    134 if (c == U'\n') break;
    135 width += glyphOrFallback(c).advance;
    136 }
    137 return width;
    138 }
    139  
    140 Vec2 Font::measure(std::string_view s, float scale) const {
    141 float widest = 0.0f;
    142 int lines = 1;
    143 size_t i = 0;
    144 widest = lineWidth(s, 0);
    145 while (i < s.size()) {
    146 if (decodeUtf8(s, i) == U'\n') {
    147 ++lines;
    148 widest = std::max(widest, lineWidth(s, i));
    149 }
    150 }
    151 return Vec2{widest, lineGap * static_cast<float>(lines)} * scale;
    152 }
    153  
    154 void Font::draw(SpriteBatch &batch, std::string_view s, Vec2 position, const TextStyle &style) const {
    155 // 影は同じ文字をずらして先に描く(同じlayerの中で先 = 奥) / the shadow is the same text drawn first, offset (first
    156 // within the same layer = behind)
    157 if (style.shadow.w > 0.0f) {
    158 TextStyle shadowStyle = style;
    159 shadowStyle.shadow.w = 0.0f;
    160 shadowStyle.color = style.shadow;
    161 draw(batch, s, position + style.shadowOffset * style.scale, shadowStyle);
    162 }
    163 auto lineStart = [&](size_t i) {
    164 float w = lineWidth(s, i) * style.scale;
    165 float x = style.align == TextAlign::Left ? position.x : style.align == TextAlign::Centre ? position.x - 0.5f * w
    166 : position.x - w;
    167 return style.snap ? std::round(x) : x;
    168 };
    169 float y = style.snap ? std::round(position.y) : position.y;
    170 float x = lineStart(0);
    171 size_t i = 0;
    172 while (i < s.size()) {
    173 char32_t c = decodeUtf8(s, i);
    174 if (c == U'\n') {
    175 y += lineGap * style.scale;
    176 x = lineStart(i);
    177 continue;
    178 }
    179 const Glyph &g = glyphOrFallback(c);
    180 if (g.pixels.w > 0.0f && g.pixels.h > 0.0f) {
    181 float w = static_cast<float>(image.width()), h = static_cast<float>(image.height());
    182 batch.draw({.texture = &image,
    183 .position = {x + g.offset.x * style.scale, y + g.offset.y * style.scale},
    184 .size = g.pixels.size() * style.scale,
    185 .uv = {g.pixels.x / w, g.pixels.y / h, g.pixels.w / w, g.pixels.h / h},
    186 .color = style.color,
    187 .layer = style.layer});
    188 }
    189 x += g.advance * style.scale;
    190 }
    191 }

ファイル: /dev/null | b/engine/src/game_loop.cc

前新
@@ -0,0 +1,64 @@
    1 #include "engine/game_loop.hh"
    2  
    3 #include <cmath>
    4  
    5 int GameLoop::advance(double frameSeconds) {
    6 if (frameSeconds > config.maxFrame) {
    7 info.droppedSeconds += frameSeconds - config.maxFrame;
    8 frameSeconds = config.maxFrame;
    9 }
    10 if (frameSeconds < 0.0) frameSeconds = 0.0;
    11 // ステップの整数倍に近ければそろえる / snap to a whole number of steps when close
    12 double multiple = std::round(frameSeconds / config.step);
    13 if (multiple >= 1.0 && std::fabs(frameSeconds - multiple * config.step) < config.snapTolerance)
    14 frameSeconds = multiple * config.step;
    15  
    16 accumulator += frameSeconds;
    17 int steps = 0;
    18 // 貯金がステップにほんの少し足りないだけ(浮動小数点の誤差:0.0333…×3 = 0.0999…)なら更新する。
    19 // 残りがわずかに負になっても、alpha()は0に切り詰める
    20 // Also update when the accumulator is only a hair short of a step (floating-point error: 0.0333... × 3 =
    21 // 0.0999...). If what is left goes slightly negative, alpha() clamps it to 0
    22 while (accumulator > config.step - config.snapTolerance && steps < config.maxSteps) {
    23 accumulator -= config.step;
    24 ++steps;
    25 }
    26 // 上限に達しても丸ごとのステップが残っていれば捨てる(追いつけない分)。上と同じ許容差で数えるので、
    27 // ほんの少し足りないだけの分も1ステップとして捨てる / whole steps still left at the limit are dropped (they cannot
    28 // be caught up), counted with the same tolerance as above: one that is only a hair short is dropped too
    29 if (steps == config.maxSteps && accumulator > config.step - config.snapTolerance) {
    30 double whole = std::floor((accumulator + config.snapTolerance) / config.step);
    31 info.droppedSeconds += whole * config.step;
    32 accumulator -= whole * config.step;
    33 }
    34 info.steps = steps;
    35 info.totalSteps += steps;
    36 info.alpha = alpha();
    37 return steps;
    38 }
    39  
    40 void GameLoop::run(Window &window, Input &input, const std::function<void(float dt)> &update,
    41 const std::function<void(float alpha)> &draw) {
    42 double last = window.time();
    43 double fpsStart = last;
    44 int fpsFrames = 0;
    45 while (!window.shouldClose()) {
    46 window.pollEvents(); // ここでInputのコールバックが呼ばれる / Input's callbacks run here
    47 double now = window.time();
    48 int steps = advance(now - last);
    49 last = now;
    50 for (int i = 0; i < steps; ++i) {
    51 update(static_cast<float>(config.step));
    52 input.endStep(); // 「押した」は1ステップだけ / "pressed" lasts one step
    53 }
    54 draw(alpha());
    55 window.swapBuffers();
    56  
    57 ++fpsFrames;
    58 if (now - fpsStart >= 0.5) {
    59 info.fps = static_cast<float>(fpsFrames / (now - fpsStart));
    60 fpsStart = now;
    61 fpsFrames = 0;
    62 }
    63 }
    64 }

ファイル: /dev/null | b/engine/src/input.cc

前新
@@ -0,0 +1,81 @@
    1 #include "engine/input.hh"
    2  
    3 void Input::apply(State &s, int action) {
    4 if (action == GLFW_PRESS) {
    5 s.down = true;
    6 s.pressed = true;
    7 } else if (action == GLFW_RELEASE) {
    8 s.down = false;
    9 s.released = true;
    10 }
    11 // GLFW_REPEAT(押しっぱなしの自動連打)は無視 / GLFW_REPEAT (auto-repeat while held) is ignored
    12 }
    13  
    14 void Input::attach(Window &w) {
    15 window = &w;
    16 w.onKey = [this](int key, int action, int /*mods*/) {
    17 if (valid(key)) apply(keys[static_cast<size_t>(key)], action);
    18 };
    19 w.onMouseButton = [this](int button, int action, int /*mods*/) {
    20 if (validButton(button)) apply(buttons[static_cast<size_t>(button)], action);
    21 };
    22 w.onScroll = [this](double /*dx*/, double dy) { scrollSum += static_cast<float>(dy); };
    23 }
    24  
    25 void Input::endStep() {
    26 for (State &s : keys) s.pressed = s.released = false;
    27 for (State &s : buttons) s.pressed = s.released = false;
    28 scrollSum = 0.0f;
    29 }
    30  
    31 Vec2 Input::mousePosition() const {
    32 return window ? Vec2{static_cast<float>(window->mouseX()), static_cast<float>(window->mouseY())} : Vec2{};
    33 }
    34  
    35 void Input::bind(std::string_view action, std::initializer_list<InputBinding> bindings) {
    36 for (Action &a : actions)
    37 if (a.name == action) {
    38 a.bindings.insert(a.bindings.end(), bindings);
    39 return;
    40 }
    41 actions.push_back({std::string(action), std::vector<InputBinding>(bindings)});
    42 }
    43  
    44 const Input::Action *Input::find(std::string_view name) const {
    45 for (const Action &a : actions)
    46 if (a.name == name) return &a;
    47 return nullptr;
    48 }
    49  
    50 const Input::State &Input::state(const InputBinding &b) const {
    51 static const State none;
    52 if (b.device == InputBinding::Device::Key) return valid(b.code) ? keys[static_cast<size_t>(b.code)] : none;
    53 return validButton(b.code) ? buttons[static_cast<size_t>(b.code)] : none;
    54 }
    55  
    56 bool Input::actionHeld(std::string_view name) const {
    57 if (const Action *a = find(name))
    58 for (const InputBinding &b : a->bindings)
    59 if (state(b).down) return true;
    60 return false;
    61 }
    62  
    63 bool Input::actionPressed(std::string_view name) const {
    64 if (const Action *a = find(name))
    65 for (const InputBinding &b : a->bindings)
    66 if (state(b).pressed) return true;
    67 return false;
    68 }
    69  
    70 // 離した:どれかを離して、もう何も押していない(AとLEFTの両方を押していたら、両方離したとき)
    71 // Released: one binding was released and none is held any more (with both A and LEFT held: when both are up)
    72 bool Input::actionReleased(std::string_view name) const {
    73 bool any = false;
    74 if (const Action *a = find(name))
    75 for (const InputBinding &b : a->bindings) any = any || state(b).released;
    76 return any && !actionHeld(name);
    77 }
    78  
    79 float Input::axis(std::string_view negative, std::string_view positive) const {
    80 return (actionHeld(positive) ? 1.0f : 0.0f) - (actionHeld(negative) ? 1.0f : 0.0f);
    81 }

ファイル: /dev/null | b/engine/src/rng.cc

前新
@@ -0,0 +1,22 @@
    1 #include "engine/rng.hh"
    2  
    3 #include <cmath>
    4 #include <utility>
    5  
    6 int Rng::range(int lo, int hi) {
    7 if (hi < lo) std::swap(lo, hi);
    8 // 幅n。2^32をnで割った余りの分だけ大きい数を捨てると、どの値も同じ確率になる(% nだけだと小さい値が少し多い)
    9 // Width n. Throwing away the top (2^32 mod n) values makes every result equally likely (plain % n slightly favors
    10 // small values)
    11 std::uint64_t n = static_cast<std::uint64_t>(static_cast<std::int64_t>(hi) - lo) + 1;
    12 std::uint64_t limit = (std::uint64_t{1} << 32) - ((std::uint64_t{1} << 32) % n);
    13 std::uint64_t x;
    14 do x = next();
    15 while (x >= limit);
    16 return static_cast<int>(static_cast<std::int64_t>(lo) + static_cast<std::int64_t>(x % n));
    17 }
    18  
    19 Vec2 Rng::direction() {
    20 float a = range(0.0f, 2.0f * PI);
    21 return {std::cos(a), std::sin(a)};
    22 }

ファイル: /dev/null | b/engine/src/scene.cc

前新
@@ -0,0 +1,106 @@
    1 #include "engine/scene.hh"
    2  
    3 #include <algorithm>
    4 #include <cmath>
    5  
    6 void SceneManager::request(Op op, std::unique_ptr<Scene> scene, Transition transition) {
    7 pending.push_back({op, std::move(scene), transition});
    8 }
    9  
    10 void SceneManager::push(std::unique_ptr<Scene> scene, Transition t) { request(Op::Push, std::move(scene), t); }
    11 void SceneManager::pop(Transition t) { request(Op::Pop, nullptr, t); }
    12 void SceneManager::replace(std::unique_ptr<Scene> scene, Transition t) { request(Op::Replace, std::move(scene), t); }
    13 void SceneManager::replaceAll(std::unique_ptr<Scene> scene, Transition t) {
    14 request(Op::ReplaceAll, std::move(scene), t);
    15 }
    16  
    17 void SceneManager::apply(Request &r) {
    18 auto removeTop = [&] {
    19 stack.back()->exit();
    20 stack.pop_back();
    21 };
    22 if (r.op == Op::Pop || r.op == Op::Replace) {
    23 if (!stack.empty()) removeTop();
    24 if (r.op == Op::Pop && !stack.empty()) stack.back()->resume();
    25 }
    26 if (r.op == Op::ReplaceAll)
    27 while (!stack.empty()) removeTop();
    28 if (r.scene) {
    29 if (r.op == Op::Push && !stack.empty()) stack.back()->pause();
    30 r.scene->owner = this;
    31 stack.push_back(std::move(r.scene));
    32 stack.back()->enter();
    33 }
    34 }
    35  
    36 void SceneManager::update(float dt) {
    37 if (phase == Phase::Out) {
    38 // フェードアウト中:誰も更新しない。半分の時間で切り替えてフェードインへ / fading out: no updates. Switch at half
    39 // time and fade in
    40 phaseTime += dt;
    41 if (phaseTime >= 0.5f * current.duration) {
    42 apply(pending.front());
    43 pending.erase(pending.begin());
    44 phase = Phase::In;
    45 phaseTime = 0.0f;
    46 }
    47 return;
    48 }
    49 if (phase == Phase::In) {
    50 phaseTime += dt;
    51 if (phaseTime >= 0.5f * current.duration) phase = Phase::None;
    52 }
    53 if (Scene *s = top()) s->update(dt);
    54 // 頼まれた切り替え:フェードなしなら今すぐ全部、フェード付きならフェードアウトを始める
    55 // Requested changes: without a fade apply them now, with a fade start fading out
    56 while (!pending.empty() && phase == Phase::None) {
    57 if (pending.front().transition.duration > 0.0f) {
    58 current = pending.front().transition;
    59 phase = Phase::Out;
    60 phaseTime = 0.0f;
    61 break;
    62 }
    63 apply(pending.front());
    64 pending.erase(pending.begin());
    65 }
    66 }
    67  
    68 size_t SceneManager::firstVisible() const {
    69 size_t i = stack.size() - 1;
    70 while (i > 0 && stack[i]->isOverlay()) --i;
    71 return i;
    72 }
    73  
    74 void SceneManager::draw(float alpha) {
    75 if (stack.empty()) return;
    76 for (size_t i = firstVisible(); i < stack.size(); ++i) stack[i]->draw(drawAlpha(alpha));
    77 }
    78  
    79 void SceneManager::drawUi(float alpha) {
    80 if (stack.empty()) return;
    81 for (size_t i = firstVisible(); i < stack.size(); ++i) stack[i]->drawUi(drawAlpha(alpha));
    82 }
    83  
    84 float SceneManager::fadeAmount() const {
    85 if (phase == Phase::None || current.duration <= 0.0f) return 0.0f;
    86 float t = std::clamp(phaseTime / (0.5f * current.duration), 0.0f, 1.0f);
    87 return phase == Phase::Out ? t : 1.0f - t;
    88 }
    89  
    90 float SceneManager::drawAlpha(float alpha) const {
    91 // フェードアウト中は誰も更新されない:止まった今の状態(alpha = 1)を描く。前と今の間の補間を続けると、
    92 // alphaが変わるたびに動いていたものが前後に揺れる / during a fade out nobody is updated: draw the frozen current
    93 // state (alpha = 1). Interpolating on between previous and current would make moving things shuffle back and forth
    94 // as alpha changes
    95 return phase == Phase::Out ? 1.0f : alpha;
    96 }
    97  
    98 void SceneManager::drawFade(SpriteBatch &batch, const Mat4 &cameraMatrix, Vec2 viewSize) const {
    99 float amount = fadeAmount();
    100 if (amount <= 0.0f) return;
    101 Vec4 c = current.color;
    102 c.w *= amount;
    103 batch.begin(cameraMatrix);
    104 batch.drawRect({0.0f, 0.0f, viewSize.x, viewSize.y}, c);
    105 batch.end();
    106 }


コメント(0)

まだコメントはありません。