Giter VIP home page Giter VIP logo

a5taku's Introduction

5TAKU / 5TQ / ごたくファイル読込クラス

一斉を風靡したクイズゲーム「ごたく」のデータファイルを読むためのクラスです。

使い方

<?php
require_once 'A5taku.php';
$a5taku = new A5taku();
$a5taku->load('data.5tq');
var_dump($a5taku->genre);

以下、「ごたく開発キット」の添付資料からの引用です。

=== ごたく問題ファイルのフォーマット ===

基本的に 256[byte] を単位ブロックとして、先頭の 8 ブロックが問題への
エントリとなるヘッダ、それ以降の残りが問題の本体となっています。
この先頭のブロックはそれぞれが独立したジャンルへのエントリとして
運用的には使われており、この中には各ジャンルの問題にアクセスする
ために必要な情報が入っています。

# 将来的にブロックサイズは拡張される可能性があるような感じが…

図にすると以下の様になります:

    0     256    ...    2048   ...
    +------+------+------+------+------+------+------+------+
    |ヘッダ| .... | .... |問題文|問題文| .... | .... | .... |
    +------+------+------+------+------+------+------+------+

ヘッダおよび問題文ブロックの内部構造はそれぞれ以下の通り:

  # 以下のフォーマットは C 言語のフォーマットで、char: 8bit
  # かつ short: 16bit という前提で書かれています。これは
  # 規格ではない前提なので、実装時には注意して下さい。

  ===ヘッダ===

  struct head {
    unsigned char type[16];  # ジャンル名
    short         pass;      # 未使用
    short         size;      # ジャンル中の問題数(ブロック数と等価)
    short         skip;      # アクセスのために読み飛ばすブロック数
    unsigned char file[12];  # プレーヤーデータファイル名
    unsigned char code[8];   # マジックコード(5TAKUQDT or 5TAKUQDX)
    unsigned char fill[214]; # ブロックアライメントの調整用詰めもの
  };
                                                                                                                                           
  ===問題文===

  struct data {
    unsigned char message[116];    # 問題
    unsigned char choices[28 * 5]; # 選択(計5つ)
  };

なお、データ中においては常に最初の選択が回答として扱われます。
したがって、ゲームを実装する際には適当にかき混ぜてから表示する
必要があります。

Masahiko Tokita [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.