Пример #1
0
Move* Character::getMove(SDL_Renderer *renderer, string name, int sprite_amount)
{
    //Sprites load
    vector<Sprite*>sprites;
    string align_file_path = "assets/" + name + "/align.txt";
    ifstream align_file(align_file_path.c_str());
    for(int i=1;i<=sprite_amount;i++)
    {
        string path="assets/" + name + "/" + toString(i) + ".png";
        int align_x;
        int align_y;
        align_file>>align_x;
        align_file>>align_y;

        sprites.push_back(new Sprite(renderer,path,500,align_x,align_y));
    }

    //Cancel load
    string cancels_file_path = "assets/" + name + "/cancel.txt";
    ifstream cancels_file(cancels_file_path.c_str());
    vector<string>cancels;
    string cancel_temp;
    while(cancels_file>>cancel_temp)
    {
        cancels.push_back(cancel_temp);
    }

    return new Move(renderer,sprites,cancels);
}
Пример #2
0
Move* Character::getMove(SDL_Renderer *renderer, string name, int sprite_amount)
{
    //Sprites load
    vector<Sprite*>sprites;
    string align_file_path = "assets/" + name + "/align.txt";
    ifstream align_file(align_file_path.c_str());
    for(int i=1;i<=sprite_amount;i++)
    {
        string path="assets/" + name + "/" + toString(i) + ".png";
        int align_x;
        int align_y;
        align_file>>align_x;
        align_file>>align_y;

        vector<Hitbox*>hitboxes;

        string hitbox_file_path = "assets/" + name + "/hitboxes/"+toString(i)+".txt";
        ifstream hitbox_file(hitbox_file_path.c_str());

        int x,y,w,h;
        while(hitbox_file>>x)
        {
            hitbox_file>>y;
            hitbox_file>>w;
            hitbox_file>>h;
            hitboxes.push_back(new Hitbox(x,y,w,h));
        }

        sprites.push_back(new Sprite(renderer,path,10,align_x,align_y,hitboxes));
    }

    //Cancel load
    string cancels_file_path = "assets/" + name + "/cancel.txt";
    ifstream cancels_file(cancels_file_path.c_str());
    vector<string>cancels;
    string cancel_temp;
    while(cancels_file>>cancel_temp)
    {
        cancels.push_back(cancel_temp);
    }

    string buttons_file_path = "assets/" + name + "/buttons.txt";
    ifstream buttons_file(buttons_file_path.c_str());
    vector<Button*>buttons;
    char button_temp;
    while(buttons_file>>button_temp)
    {
        buttons.push_back(new Button(button_temp));
    }

    return new Move(renderer,sprites,cancels,buttons);
}