brickviking / night-hawk

Nighthawk is a tribute to one of the most playable and contagious games ever written—Paradroid by Andrew Braybrook. Feel the excitement as you battle through hordes of droids to gain your object of removing all droids on the level.
3 stars 0 forks source link

Beginnings of writing out misc file from editor #8

Open brickviking opened 4 years ago

brickviking commented 4 years ago

I have a suggestion. If we can find a way of including doors, power_bay, transports and consoles (sprites) and writing these out to the .m after we run tedit_floor::save, we could integrate everything into ned, instead of having to write the levelname.m out manually.

I've got the beginnings of a tedit_floor::msave(), but I need help in setting it to rights. I'm sure there's something else wrong, but I lack the experience with the code to know what.

void tedit_floor::msave(void)
{
    FILE *mp;
    int x, y, i;
    char str[STR_LEN + 1];

    snprintf(str, STR_LEN, "%s.m", floor_relpath);
    printf("Saving misc: %s\n", str);
    mp = fopen(rel_to_abs_filepath(str), "w");
    if(mp == NULL)
        print_error(__func__, "fopen(map.m)");

    // So far, we need to convert orientation from 0/1 to h/v
    for (i=0;i<door_ptr;i++) {
        if (!fprintf(mp, "%s: %d %d %c\n", "door", door[door_ptr]->pos_x, door[door_ptr]->pos_y, door[door_ptr]->type==0 ? 'v' : 'h'))
          print_error(__func__, "fprintf(1)");
    }

    if (power_bay) {
        if (!fprintf(mp, "%s: %d %d %c\n", "power_bay", power_bay->pos_x, power_bay->pos_y))
              print_error(__func__, "fprintf(1)");
    }

    for (i=0;i<transport_ptr;i++) {
        if (!fprintf(mp, "%s: %d %d\n", "transport", sx, sy))
          print_error(__func__, "fprintf(1)");
    }

    if (console) {
        if (!fprintf(mp, "%s: %d %d\n", "console", sx, sy))
          print_error(__func__, "fprintf(1)");
      }

    // Still missing noise

    fclose(mp);
}

We'll still have to have a way of switching between tiles (which we have now) and sprites (doors, power_bays, transports, and consoles). I don't have a good solution to offer for this yet.

jsno8192 commented 4 years ago

I looked into this, then discovered this was going to be a lot of work. The easiest/cleanest way to do it (and still would be a lot of work) is to abandon the tedit_floor.h class and make a tedit_ship.h class. This class would have access to all subordinate objects like doors, and power bays etc.