コード例 #1
0
ファイル: NPC.cpp プロジェクト: goatattack/goatattack
void NPC::create_npc(NPCAnimation type, const std::string& filename,
    int animation_speed, bool one_shot, ZipReader *zip) throw (Exception)
{
    PNG png(filename, zip);
    tiles[DirectionRight][type] = create_tile(png, animation_speed, one_shot, false);
    png.flip_h();
    tiles[DirectionLeft][type] = create_tile(png, animation_speed, one_shot, true);
}
コード例 #2
0
ファイル: tile_set.cpp プロジェクト: keyor/godot
bool TileSet::_set(const StringName& p_name, const Variant& p_value) {

    String n = p_name;
    int slash = n.find("/");
    if (slash==-1)
        return false;
    int id = String::to_int(n.c_str(),slash);

    if (!tile_map.has(id))
        create_tile(id);
    String what = n.substr(slash+1,n.length());

    if (what=="name")
        tile_set_name(id,p_value);
    else if (what=="texture")
        tile_set_texture(id,p_value);
    else if (what=="tex_offset")
        tile_set_texture_offset(id,p_value);
    else if (what=="shape_offset")
        tile_set_shape_offset(id,p_value);
    else if (what=="region")
        tile_set_region(id,p_value);
    else if (what=="shape")
        tile_set_shape(id,p_value);
    else if (what=="shapes")
        _tile_set_shapes(id,p_value);
    else
        return false;

    return true;

}
コード例 #3
0
ファイル: levelGenerator.c プロジェクト: happypandaface/icmm
// This will make it easier to make tiles and change the way tiles are made
int addTile(struct TileElement **tiles, float x, float y, int curr)
{
	struct Tile* tile = malloc(sizeof(*tile));
	//((tile->pos)) = malloc(sizeof((tile->pos)));
	create_tile(tile);
	tile->pos.x = x;
	tile->pos.y = y;
	game_add_tile(tiles, tile);
	//tiles[curr] = t;
	return 1;
};
コード例 #4
0
ファイル: tile_set.cpp プロジェクト: rrrfffrrr/godot
bool TileSet::_set(const StringName &p_name, const Variant &p_value) {

	String n = p_name;
	int slash = n.find("/");
	if (slash == -1)
		return false;
	int id = String::to_int(n.c_str(), slash);

	if (!tile_map.has(id))
		create_tile(id);
	String what = n.substr(slash + 1, n.length());

	if (what == "name")
		tile_set_name(id, p_value);
	else if (what == "texture")
		tile_set_texture(id, p_value);
	else if (what == "normal_map")
		tile_set_normal_map(id, p_value);
	else if (what == "tex_offset")
		tile_set_texture_offset(id, p_value);
	else if (what == "material")
		tile_set_material(id, p_value);
	else if (what == "modulate")
		tile_set_modulate(id, p_value);
	else if (what == "region")
		tile_set_region(id, p_value);
	else if (what == "shape")
		tile_set_shape(id, 0, p_value);
	else if (what == "shape_offset") {
		Transform2D xform = tile_get_shape_transform(id, 0);
		xform.set_origin(p_value);
		tile_set_shape_transform(id, 0, xform);
	} else if (what == "shape_transform")
		tile_set_shape_transform(id, 0, p_value);
	else if (what == "shape_one_way")
		tile_set_shape_one_way(id, 0, p_value);
	else if (what == "shapes")
		_tile_set_shapes(id, p_value);
	else if (what == "occluder")
		tile_set_light_occluder(id, p_value);
	else if (what == "occluder_offset")
		tile_set_occluder_offset(id, p_value);
	else if (what == "navigation")
		tile_set_navigation_polygon(id, p_value);
	else if (what == "navigation_offset")
		tile_set_navigation_polygon_offset(id, p_value);
	else
		return false;

	return true;
}
コード例 #5
0
ファイル: Animation.cpp プロジェクト: goatattack/goatattack
Animation::Animation(Subsystem& subsystem, const std::string& filename, ZipReader *zip)
    throw (KeyValueException, AnimationException)
    : Properties(filename + ".animation", zip), subsystem(subsystem),
      tile(0), sound(0)
{
    try {
        tile_width = atoi(get_value("width").c_str());
        tile_height = atoi(get_value("height").c_str());
        animation_speed = atoi(get_value("speed").c_str());
        duration = atoi(get_value("duration").c_str());
        sound_loops = atoi(get_value("sound_loops").c_str());
        springiness = atof(get_value("springiness").c_str());
        impact = atof(get_value("impact").c_str());
        spread = atoi(get_value("spread").c_str());

        x_offset = atoi(get_value("x_offset").c_str());
        y_offset = atoi(get_value("y_offset").c_str());

        spread_count = atoi(get_value("spread_count").c_str());
        if (spread_count < 1) {
            spread_count = 1;
        }

        screen_shaker = atoi(get_value("screen_shaker").c_str());

        in_background = (atoi(get_value("background").c_str()) ? true : false);

        projectile = (atoi(get_value("projectile").c_str()) ? true : false);
        damage = atoi(get_value("damage").c_str());
        randomized_index = atoi(get_value("randomized_index").c_str());

        physics = (atoi(get_value("physics").c_str()) != 0 ? true : false);
        recoil = atof(get_value("recoil").c_str());

        physics_colbox.x = atoi(get_value("physics_colbox_x").c_str());
        physics_colbox.y = atoi(get_value("physics_colbox_y").c_str());
        physics_colbox.width = atoi(get_value("physics_colbox_width").c_str());
        physics_colbox.height = atoi(get_value("physics_colbox_height").c_str());

        if (tile_width != tile_height || tile_width < 16 || tile_width > 64) {
            throw AnimationException("Malformed tile size: " + filename);
        }
        create_tile(filename + ".png", zip);
    } catch (const AnimationException&) {
        throw;
    } catch (const Exception& e) {
        throw AnimationException(e.what());
    }
}
コード例 #6
0
ファイル: Tileset.cpp プロジェクト: SuperNascher/goatattack
Tileset::Tileset(Subsystem& subsystem, const std::string& filename, ZipReader *zip)
    throw (KeyValueException, TilesetException)
    : Properties(filename + ".tileset", zip), subsystem(subsystem)
{
    try {
        tile_width = atoi(get_value("width").c_str());
        tile_height = atoi(get_value("height").c_str());
        if (tile_width != tile_height || tile_width < 16 || tile_width > static_cast<int>(sizeof(mask_t) * 8)) {
            throw TilesetException("Malformed tile size: " + filename);
        }
        create_tile(filename + ".png", zip);
    } catch (const TilesetException&) {
        throw;
    } catch (const Exception& e) {
        throw TilesetException(e.what());
    }
}
コード例 #7
0
ファイル: Channel.cpp プロジェクト: TannerTaphorn/datastore
void Channel::add_data_internal(const std::vector<DataSample<T> > &data, DataRanges *channel_ranges) {
  if (!data.size()) return;
  // Sanity check
  if (data[0].time < 0) throw std::runtime_error("Unimplemented feature: adding data with negative time");
  for (unsigned i = 0; i < data.size()-1; i++) {
    if (data[i].time > data[i+1].time) throw std::runtime_error("Attempt to add data that is not sorted by ascending time");
  }

  //	regenerate = empty set
  Locker lock(*this);  // Lock self and hold lock until exiting this method
  std::set<TileIndex> to_regenerate;

  ChannelInfo info;
  bool success = read_info(info);
  if (!success) {
    // New channel
    info.magic = ChannelInfo::MAGIC;
    info.version = 0x00010000;
    info.times = Range(data[0].time, data.back().time);
    info.nonnegative_root_tile_index = TileIndex::nonnegative_all();
    create_tile(TileIndex::nonnegative_all());
    info.negative_root_tile_index = TileIndex::null();
  } else {
    info.times.add(Range(data[0].time, data.back().time));
    // If we're not the all-tile, see if we need to move the root upwards
    if (info.nonnegative_root_tile_index != TileIndex::nonnegative_all()) {
      TileIndex new_nonnegative_root_tile_index = TileIndex::index_containing(info.times);
      if (new_nonnegative_root_tile_index.level > info.nonnegative_root_tile_index.level) {
	// Root index changed.  Confirm new root is parent or more distant ancestor of old root
	assert(new_nonnegative_root_tile_index.is_ancestor_of(info.nonnegative_root_tile_index));
	// Trigger regeneration from old root's parent, up through new root
	to_regenerate.insert(info.nonnegative_root_tile_index.parent());
	move_root_upwards(new_nonnegative_root_tile_index, info.nonnegative_root_tile_index);
	info.nonnegative_root_tile_index = new_nonnegative_root_tile_index;
      }
    }
  }

  unsigned i=0;

  while (i < data.size()) {
    TileIndex ti= find_lowest_child_overlapping_time(info.nonnegative_root_tile_index, data[i].time);
    assert(!ti.is_null());

    Tile tile;
    assert(read_tile(ti, tile));
    const DataSample<T> *begin = &data[i];
    while (i < data.size() && ti.contains_time(data[i].time)) i++;
    const DataSample<T> *end = &data[i];
    tile.insert_samples(begin, end);
    
    TileIndex new_root = split_tile_if_needed(ti, tile);
    if (new_root != TileIndex::null()) {
      assert(ti == TileIndex::nonnegative_all());
      if (verbosity) log_f("Channel: %s changing root from %s to %s",
                           descriptor().c_str(), ti.to_string().c_str(),
                           new_root.to_string().c_str());
      info.nonnegative_root_tile_index = new_root;
      delete_tile(ti); // Delete old root
      ti = new_root;
    }
    write_tile(ti, tile);
    if (ti == info.nonnegative_root_tile_index && channel_ranges) { *channel_ranges = tile.ranges; }
    if (ti != info.nonnegative_root_tile_index) to_regenerate.insert(ti.parent());
  }
  
  // Regenerate from lowest level to highest
  while (!to_regenerate.empty()) {
    TileIndex ti = *to_regenerate.begin();
    to_regenerate.erase(to_regenerate.begin());
    Tile regenerated, children[2];
    assert(read_tile(ti.left_child(), children[0]));
    assert(read_tile(ti.right_child(), children[1]));
    create_parent_tile_from_children(ti, regenerated, children);
    write_tile(ti, regenerated);
    if (ti == info.nonnegative_root_tile_index && channel_ranges) { *channel_ranges = regenerated.ranges; }
    if (ti != info.nonnegative_root_tile_index) to_regenerate.insert(ti.parent());
  }
  write_info(info);
}
コード例 #8
0
ファイル: tilemap.c プロジェクト: RylandAlmanza/soul-stick
struct tile create_soul_tree_tile(int x, int y) {
  return create_tile("Soul Tree", "The Soul Tree is f*****g huge!", x, y,
		     UNWALKABLE, '#', GREEN_ON_YELLOW);
}
コード例 #9
0
ファイル: tilemap.c プロジェクト: RylandAlmanza/soul-stick
struct tile create_wall_tile(int x, int y) {
  return create_tile("Wall",
		     "Walls. Always keeping you out of places. F**k 'em.", x,
		     y, UNWALKABLE, '#', WHITE_ON_WHITE);
}
コード例 #10
0
ファイル: tilemap.c プロジェクト: RylandAlmanza/soul-stick
struct tile create_grass_tile(int x, int y) {
  return create_tile("Grass", "Little blades of plant.", x, y, WALKABLE, '.',
	      WHITE_ON_GREEN);
}
コード例 #11
0
ファイル: tilemap.c プロジェクト: RylandAlmanza/soul-stick
struct tile create_bridge_tile(int x, int y) {
  return create_tile("Bridge",
		     "It's a bridge. You use it to walk over things.", x, y,
		     WALKABLE, '=', BLACK_ON_YELLOW);
}
コード例 #12
0
ファイル: tilemap.c プロジェクト: RylandAlmanza/soul-stick
struct tile create_water_tile(int x, int y) {
  return create_tile("Water", "It's water. Swim swim.", x, y, UNWALKABLE, '~',
	      WHITE_ON_BLUE);
}