本文整理汇总了C++中Tiles类的典型用法代码示例。如果您正苦于以下问题:C++ Tiles类的具体用法?C++ Tiles怎么用?C++ Tiles使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tiles类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
void WorldState::Init(RenderContext& ctx,Scene* m_scene){
std::cout << "Initializing WorldState\n";
ctx.checkFS(isFullscreen = false);
Tiles* tile;
tile->CreateMap(ctx,m_scene);
m_scene->add(GameObject(ctx, std::string("res/hero1.png"), std::string("hero")), 0, {300, 200}, true);
}
示例2:
Tiles
ParallelRenderer::worker (TaskDispatcher& _task_dispatcher, World& _world,
Settings& _settings, Engine& _engine, SuperSampling& _super_sampling)
{
Tiles result;
SerialRenderer serial_renderer;
Settings settings = _settings;
while (1)
{
boost::optional<Task> optional_task = _task_dispatcher.get_task();
if (!optional_task)
break;
Task task = optional_task.get();
settings.area = task;
Image rendered_image = serial_renderer.render(_world, settings, _engine,
_super_sampling);
Tile tile;
tile.task = task;
tile.image = rendered_image;
result.push_back(tile);
}
return result;
}
示例3: task_dispatcher
Image
ParallelRenderer::render (World& _world, Settings& _settings, Engine&
_engine, SuperSampling& _super_sampling)
{
TaskDispatcher task_dispatcher(_settings);
std::vector<std::future<Tiles>> futures(0);
for (unsigned i = 0; i < _settings.max_thread_count; i++)
{
// TODO can this be done better? it must be possible
futures.push_back(std::async(std::launch::async, [this, &task_dispatcher,
&_world, &_settings, &_engine, &_super_sampling] () {
return worker(task_dispatcher, _world, _settings, _engine,
_super_sampling); }));
}
for (unsigned i = 0; i < futures.size(); i++)
{
futures[i].wait();
}
Image final_image(_settings.area.size);
for (unsigned i = 0; i < futures.size(); i++)
{
Tiles tiles = futures[i].get();
for (unsigned j = 0; j < tiles.size(); j++)
{
final_image.paste(tiles[j].task.start, tiles[j].image);
}
}
return final_image;
}
示例4: hitTile
int hitTile(Tiles &tiles, int x, int y)
{
int ty =(y - TILES_TOP)/ TILE_H;
int tx =(x - TILES_LEFT)/ TILE_W;
const boolean hit = ty >= 0 && ty < ROWS && tx >= 0 && tx < COLS && tiles.exists(tx,ty);
if (!hit) return 0;
tiles.clearTile( tx, ty );
const int score = ROWS - ty;
ty*= TILE_H;
ty+= TILES_TOP;
tft.fillRectangle(TILES_LEFT + tx * TILE_W, ty, TILE_W - 2, TILE_H - 2, BACKGROUND_COLOR);
const int ty2= ty + TILE_H;
if ( (yi > 0 && y > ty) || (yi < 0 && y > ty2))
{
xi *=-1;
}
else
{
yi *=-1;
}
return score;
}
示例5: make_tiles
static Tiles make_tiles(void)
{
Tiles t;
t.init(WIN_SIZEVI);
return t;
}
示例6: trace
static void trace(Node *n, Tiles &v) {
v.clear();
while (n) {
v.push_back(n->tile);
n = n->next;
}
std::reverse(v.begin(), v.end());
}
示例7: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Tiles w;
w.readPositionSettings();
w.show();
return a.exec();
}
示例8: UniqueTiles
// return the largest subset of mutually compatible tiles
Tiles Tiles::LongestRun(void) const {
// clones are never compatible, so consider only the unique tiles
Tiles const unique = UniqueTiles();
Tiles result;
Tiles const empty_run;
unique.BuildRuns(empty_run, result);
ASSERT(result.AreAllCompatible());
return result;
}
示例9: PullRandomTiles
Tiles Tiles::PullRandomTiles(SizeType tileCnt) {
Tiles result;
for (SizeType i_tile = 0; i_tile < tileCnt; i_tile++) {
if (IsEmpty()) {
break;
}
Tile const tile = PullRandomTile();
result.Add(tile);
}
return result;
}
示例10: finish
void UpgradeWork::finish(Island* island, const Event& e) {
Tiles* tiles = island->getTiles();
tiles->clear_state(e.tile_x,e.tile_y,TS_ACTIVE);
Tile& t = tiles->get(e.tile_x, e.tile_y);
++t.level;
// remove old regular work
island->removeWork(PT_REGULAR,e.tile_x, e.tile_y);
// create new
island->calculateMaxResources();
Resources tmp;
if (gContext->price_registry.get(PT_REGULAR, 0, t.building_id, t.level, &tmp)) {
island->createWork(PT_REGULAR, e.tile_x, e.tile_y, t.building_id, t.level);
}
}
示例11: make_tiles
static Tiles make_tiles(void)
{
Tiles t;
t.init(WIN_SIZEVI
, /*ft::Vec2<int> const triangleSize =*/ ft::Vec2<int>(95, 95)
, /*int const pointRandomRadius =*/ 30
, /*float const percentGray =*/ 0.33f
, /*ft::Vec3<int> const gray =*/ ft::Vec3<int>(120, 181, 129)
, /*ft::Vec3<int> const pink =*/ ft::Vec3<int>(10, 150, 10)
// , /*ft::Vec3<int> const pink =*/ ft::Vec3<int>(230, 46, 77)
, /*ft::Vec3<int> const deltaPink =*/ ft::Vec3<int>(10, 45, 10));
// , /*ft::Vec3<int> const deltaPink =*/ ft::Vec3<int>(50, 10, 77));
return t;
}
示例12: run
// construct "runs": subsets of mutually-compatible tiles - RECURSIVE
void Tiles::BuildRuns(Tiles const& rRunSoFar, Tiles& rLongestRun) const {
if (IsEmpty()) {
if (rRunSoFar.Count() > rLongestRun.Count()) {
rLongestRun = rRunSoFar;
}
} else {
Tiles run(rRunSoFar);
Tiles remainder(*this);
Tile const first = remainder.PullFirstTile();
// build runs without the first tile
remainder.BuildRuns(run, rLongestRun);
if (run.AreAllCompatibleWith(first)) {
// build runs with the first tile
run.Add(first);
remainder.BuildRuns(run, rLongestRun);
}
}
}
示例13: describe_building
// ------------------------------------------------------
// describe building
// ------------------------------------------------------
bool describe_building(Island* island,int x, int y) {
Tiles* tiles = island->getTiles();
int idx = x + y * tiles->width;
if (tiles->getBuildingID(idx) == -1) {
gContext->messages.report_error("There is no building at %d %d", x, y);
return false;
}
const Tile& t = tiles->get(x, y);
printf("Building: %s\n", gContext->building_definitions.getName(t.building_id));
printf(" Level: %d\n", t.level);
Resources tmp;
if (gContext->price_registry.get(PT_REGULAR, 2, t.building_id, t.level, &tmp)) {
printf("Regular income:\n");
printf("Duration: %d\n", gContext->price_registry.getDuration(PT_REGULAR, t.building_id, t.level));
res::show_resources(gContext->resource_registry, tmp, false);
}
printf("Available work:\n");
for (int i = 1; i <= t.level; ++i) {
if (gContext->price_registry.get(PT_WORK, 0, t.building_id, i, &tmp)) {
printf(" Level %d\n", i);
printf("Duration: %d\n", gContext->price_registry.getDuration(PT_WORK, t.building_id, i));
printf("Costs:\n");
res::show_resources(gContext->resource_registry, tmp, false);
}
if (gContext->price_registry.get(PT_WORK, 1, t.building_id, i, &tmp)) {
printf("Income:\n");
Resources collect;
if (gContext->price_registry.get(PT_WORK, 2, t.building_id, i, &collect)) {
tmp.add(collect);
}
res::show_resources(gContext->resource_registry, tmp, false);
}
}
// FIXME: list start options
return true;
}
示例14: start
// ------------------------------------------------------
// StartWork
// ------------------------------------------------------
bool UpgradeWork::start(Island* island, const TextLine& line) {
int x = line.get_int(1);
int y = line.get_int(2);
Tiles* tiles = island->getTiles();
int idx = x + y * tiles->width;
if ( tiles->getBuildingID(idx) == -1 ) {
gContext->messages.report_error("There is no building at %d %d",x,y);
return false;
}
// FIXME: check if there is only a regular work item
if ( tiles->isActive(idx)) {
gContext->messages.report_error("The building is active - upgrade is not available");
return false;
}
if (island->checkRequirements(tiles->getBuildingID(idx), tiles->getLevel(idx) + 1)) {
tiles->set_state(x,y,TS_ACTIVE);
island->createWork(PT_UPGRADE,x,y,tiles->getBuildingID(idx),tiles->getLevel(idx)+1);
return true;
}
return false;
}
示例15: print_map
void print_map(Island* island, int centerX, int centerY, int size) {
Tiles* tiles = island->getTiles();
int xmin = centerX - size;
int xmax = centerX + size;
int ymin = centerY - size;
int ymax = centerY + size;
if (xmin < 0) {
xmin = 0;
xmax = 2 * size;
}
if (xmax >= tiles->width) {
xmin = tiles->width - 2 * size;
xmax = tiles->width;
}
if (ymin < 0) {
ymin = 0;
ymax = 2 * size;
}
if (ymax >= tiles->height) {
ymin = tiles->height - 2 * size;
ymax = tiles->height;
}
for ( int y = ymax - 1; y >= ymin; --y ) {
printf("%2d | ", y);
for ( int x = xmin; x < xmax; ++x ) {
int idx = x + y * tiles->width;
if ( tiles->has_state(x,y,TS_LOCKED)) {
printf("?? ");
}
else if ( tiles->has_state(x,y,TS_UNDEFINED)) {
printf(" ");
}
else {
if ( tiles->getBuildingID(idx) != -1 ) {
printf("%s", gContext->building_definitions.getSign(tiles->getBuildingID(idx)));
if ( tiles->isActive(idx)) {
printf("# ");
}
else if ( tiles->has_state(x,y,TS_COLLECTABLE)) {
printf("* ");
}
else {
printf(" ");
}
}
else if ( tiles->_tiles[idx].ref_id != -1 ) {
printf("xx ");
}
else {
printf("- ");
}
}
}
printf("\n");
}
printf(" -----------------------------------------------------------------\n");
printf(" ");
for (int i = xmin; i < xmax; ++i) {
printf("%2d ", i);
}
printf("\n");
}