void
PlayerStatus::write(lisp::Writer& writer)
{
  switch(bonus) {
    case NO_BONUS:
      writer.write_string("bonus", "none");
      break;
    case GROWUP_BONUS:
      writer.write_string("bonus", "growup");
      break;
    case FIRE_BONUS:
      writer.write_string("bonus", "fireflower");
      break;
    case ICE_BONUS:
      writer.write_string("bonus", "iceflower");
      break;
    default:
      log_warning << "Unknown bonus type." << std::endl;
      writer.write_string("bonus", "none");
  }
  writer.write_int("fireflowers", max_fire_bullets);
  writer.write_int("iceflowers", max_ice_bullets);
  
  writer.write_int("coins", coins);
  writer.write_int("max-score-multiplier", max_score_multiplier);
}
Ejemplo n.º 2
0
void
CloudParticleSystem::write(lisp::Writer& writer)
{
  writer.start_list("particles-clouds");
  writer.write_int("z-pos", z_pos);
  writer.end_list("particles-clouds");
}
Ejemplo n.º 3
0
void
GhostParticleSystem::write(lisp::Writer& writer)
{
  writer.start_list("particles-ghosts");
  writer.write_int("z-pos", z_pos);
  writer.end_list("particles-ghosts");
}
Ejemplo n.º 4
0
void
SnowParticleSystem::write(lisp::Writer& writer)
{
  writer.start_list("particles-snow");
  writer.write_int("z-pos", z_pos);
  writer.end_list("particles-snow");
}
Ejemplo n.º 5
0
void save_squirrel_table(HSQUIRRELVM vm, int table_idx, lisp::Writer& writer)
{
  // offset because of sq_pushnull
  if(table_idx < 0)
    table_idx -= 1;
  
  //iterator table
  sq_pushnull(vm);
  while(SQ_SUCCEEDED(sq_next(vm, table_idx))) {
    if(sq_gettype(vm, -2) != OT_STRING) {
      std::cerr << "Table contains non-string key\n";
      continue;
    }
    const char* key;
    sq_getstring(vm, -2, &key);

    switch(sq_gettype(vm, -1)) {
      case OT_INTEGER: {
        int val;
        sq_getinteger(vm, -1, &val);
        writer.write_int(key, val);
        break;
      }
      case OT_FLOAT: {
        float val;
        sq_getfloat(vm, -1, &val);
        writer.write_float(key, val);
        break;
      }
      case OT_BOOL: {
        SQBool val;
        sq_getbool(vm, -1, &val);
        writer.write_bool(key, val);
        break;
      }
      case OT_STRING: {
        const char* str;
        sq_getstring(vm, -1, &str);
        writer.write_string(key, str);
        break;
      }
      case OT_TABLE: {
        writer.start_list(key, true);
        save_squirrel_table(vm, -1, writer);
        writer.end_list(key);
        break;
      }
      case OT_CLOSURE:
        break; // ignore
      case OT_NATIVECLOSURE:
        break;
      default:
        std::cerr << "Can't serialize key '" << key << "' in table.\n";
        break;
    }
    sq_pop(vm, 2);
  }
  sq_pop(vm, 1);
}
Ejemplo n.º 6
0
void
DartTrap::write(lisp::Writer& writer)
{
  writer.start_list("darttrap");
  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);
  writer.write_float("initial-delay", initial_delay);
  writer.write_float("fire-delay", fire_delay);
  writer.write_int("ammo", ammo);
  writer.end_list("darttrap");
}
Ejemplo n.º 7
0
void
Statistics::write(lisp::Writer& writer)
{
  writer.write_int("coins-collected", coins);
  writer.write_int("coins-collected-total", total_coins);
  writer.write_int("badguys-killed", badguys);
  writer.write_int("badguys-killed-total", total_badguys);
  writer.write_float("time-needed", time);
  writer.write_int("secrets-found", secrets);
  writer.write_int("secrets-found-total", total_secrets);
}
Ejemplo n.º 8
0
void
Background::write(lisp::Writer& writer)
{
  writer.start_list("background");

  if (image_top.get() != NULL)
    writer.write_string("image-top", imagefile_top);
    
  writer.write_string("image", imagefile);
  if (image_bottom.get() != NULL)
    writer.write_string("image-bottom", imagefile_bottom);

  writer.write_float("speed", speed);
  writer.write_float("speed-y", speed_y);
  writer.write_int("layer", layer);
  
  writer.end_list("background");
}