某岛

… : "…アッカリ~ン . .. . " .. .
August 9, 2021

GameCreator 自动生成行走图

const fs = require('fs');

function gen(png, target, offset_x = 0, offset_y= 0, w  = 32, h = 32) {

    let t;
    let json = JSON.parse(fs.readFileSync('avatar5.json', 'utf8'));
    json["picUrls"] = ["asset/image/_RM/VA/Characters/" + png + ".png"];

    t = json["actionListArr"][0]["frameImageInfo"];
    
    let ox = offset_x*(w*3);
    let oy = offset_y*(h*4);

    for (let i=0;i<4;++i) {
        t[i][0]["rect"][0] = -(w*1+ox);
        t[i][0]["rect"][1] = -(h*i+oy);
        t[i][0]["rect"][2] = w;
        t[i][0]["rect"][3] = h;
        t[i][0]["width"] = w;
        t[i][0]["height"] = h;
        t[i][0].x = -Math.floor(w/2);
        t[i][0].y = -(h-1);
    }

    t = json["actionListArr"][1]["frameImageInfo"];

    for (let i=0;i<4;++i) {
        t[i].pop();
        for (let j=0;j<3;++j) {
            t[i][j]["picUrlIndex"] = 0;
            t[i][j]["rect"][0] = -(w*j+ox);
            t[i][j]["rect"][1] = -(h*i+oy);
            t[i][j]["rect"][2] = w;
            t[i][j]["rect"][3] = h;
            t[i][j]["width"] = w;
            t[i][j]["height"] = h;
            t[i][j].x = -Math.floor(w/2);
            t[i][j].y = -(h-1);
        }
    }

    fs.writeFileSync(target, JSON.stringify(json,null, 4));
}

gen("$キッカ", 'avatar8001.json')
gen("Actor5", 'avatar8002.json', 1, 1)
gen("$ラヴィアン", 'avatar8003.json')
gen("$タミネ", 'avatar8004.json')
gen("Vehicle", 'avatar44.json', 1, 0)

const int N = int(2e5) + 9;
char buf[5*96*96];

int n;

int main() {
#ifndef ONLINE_JUDGE
    //freopen("PORTMAP.001", "rb", stdin);
    freopen("PORTMAP001.json", "w", stdout);
#endif
    int n;
    }*/
    char c;

    REP(i, 101) {
        fstream file, outfile;
        string name = "PORTMAP.";
        int x = i;
        int c = x % 10; x /= 10;
        int b = x % 10; x /= 10;
        int a = x % 10;
        name += ('0'+a);
        name += ('0'+b);
        name += ('0'+c);

        file.open(name.c_str(), ios::binary|ios::in);

        string out_name = "PORTMAP";
        out_name += ('0'+a);
        out_name += ('0'+b);
        out_name += ('0'+c);
        out_name += ".json";
        outfile.open(out_name.c_str(), ios::out);

        file.read(buf, 96*96);
        REP(i, 96*96) {
            if (i) outfile << ",";
            outfile << int(byte(buf[i]));
        }

        outfile.close();
        file.close();
    }
}
let t = Game.player.sceneObject.avatar;
t.loadData(1001);