本文整理汇总了C++中Tiles类的典型用法代码示例。如果您正苦于以下问题:C++ Tiles类的具体用法?C++ Tiles怎么用?C++ Tiles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tiles类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:woodne,项目名称:SimpleRPG,代码行数:7,代码来源:WorldState.cpp
示例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;
}
开发者ID:stastaj,项目名称:Svit,代码行数:28,代码来源:parallel.cpp
示例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;
}
开发者ID:stastaj,项目名称:Svit,代码行数:33,代码来源:parallel.cpp
示例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;
}
开发者ID:idaviden,项目名称:Handheld-Color-Console,代码行数:31,代码来源:ball.cpp
示例5: make_tiles
static Tiles make_tiles(void)
{
Tiles t;
t.init(WIN_SIZEVI);
return t;
}
开发者ID:Ngoguey42,项目名称:proj16_algo_N-puzzle,代码行数:7,代码来源:PickState.cpp
示例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());
}
开发者ID:coleminor,项目名称:el-misc-tools,代码行数:8,代码来源:path.cpp
示例7: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Tiles w;
w.readPositionSettings();
w.show();
return a.exec();
}
开发者ID:aliakseis,项目名称:color-tiles,代码行数:8,代码来源:main.cpp
示例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;
}
开发者ID:stephengold,项目名称:gold-tiles,代码行数:12,代码来源:tiles.cpp
示例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;
}
开发者ID:stephengold,项目名称:gold-tiles,代码行数:13,代码来源:tiles.cpp
示例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);
}
}
开发者ID:amecky,项目名称:space,代码行数:14,代码来源:UpgradeWork.cpp
示例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;
}
开发者ID:Ngoguey42,项目名称:proj16_algo_N-puzzle,代码行数:15,代码来源:ResultState.cpp
示例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);
}
}
}
开发者ID:stephengold,项目名称:gold-tiles,代码行数:21,代码来源:tiles.cpp
示例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;
}
开发者ID:amecky,项目名称:space,代码行数:40,代码来源:vis.cpp
示例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;
}
开发者ID:amecky,项目名称:space,代码行数:24,代码来源:UpgradeWork.cpp
示例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");
}
开发者ID:amecky,项目名称:space,代码行数:62,代码来源:vis.cpp
示例16: ofSetVerticalSync
//--------------------------------------------------------------
void testApp::setup(){
ofSetVerticalSync(true);
ofSetFrameRate(60);
ofEnableSmoothing();
ofBackground(0);
/*------------------ SYPHON ------------------*/
// syphon.setName("ciel_etoile");
individualTextureSyphonServer.setName("Texture Output");
mClient.setup();
mClient.set("","Simple Server");
/*--------------------------------------------*/
/*-------------------- FBO -------------------*/
fbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA);
fbo.begin();
ofClear(0);
fbo.end();
/*---------------------------------------------*/
/*------------------- WI-FLY ------------------*/
//create the socket and bind to port 11999
udpConnection.Create();
udpConnection.Bind(11999);
udpConnection.SetNonBlocking(true);
/*---------------------------------------------*/
/*-------------------- FOG --------------------*/
// fogMovie.loadMovie("movies/fog.mov");
fogMovie.loadMovie("movies/smoke_duck.mp4");
fogMovie.play();
// fogMovie.setLoopState();
videoAlpha = 100;
/*---------------------------------------------*/
/*------------------- SOUND -------------------*/
soundStream.listDevices();
soundStream.setDeviceID(2);
//soundstream setup
soundStream.setup(this, 0, 2, 44100, BUFFER_SIZE, 4);
FFTanalyzer.setup(44100, BUFFER_SIZE/2, 2);
FFTanalyzer.peakHoldTime = 15; // hold longer
FFTanalyzer.peakDecayRate = 0.95f; // decay slower
FFTanalyzer.linearEQIntercept = 0.9f; // reduced gain at lowest frequency
FFTanalyzer.linearEQSlope = 0.01f; // increasing gain at higher frequencies
/*---------------------------------------------*/
/*----------------- PARTICLES -----------------*/
modes.push_back("static");
modes.push_back("walk");
modes.push_back("fuzz");
selectedMode = modes[2];
shapes.push_back("circle");
shapes.push_back("spiral");
shapes.push_back("star");
shapes.push_back("grid");
selectedShape = shapes[0];
expansion = 0;
rotation = 0;
shapeSize = ofGetHeight()/2 - 100;
particleSize = 1;
nVertices = 1;
particleGUImode = true;
for(int i=0; i < NUM_PARTICLES; i++){
Particle thisParticle;
thisParticle.init(NUM_PARTICLES, i, shapeSize, particleSize, selectedShape);
myParticles.push_back(thisParticle);
}
/*---------------------------------------------*/
/*---------------- BACKGROUND -----------------*/
tileModes.push_back("3D");
tileModes.push_back("fragments");
tileModes.push_back("rotation");
selectedTileMode = tileModes[0];
int nTiles = int(ofGetWidth()/40) * int(ofGetHeight()/40);
int i = 0;
for (int gridY=0; gridY <= ofGetHeight(); gridY += 40) {
for (int gridX=0; gridX <= ofGetWidth(); gridX+= 40) {
Tiles thisTile;
thisTile.setup(nTiles, i, selectedTileMode, gridX, gridY);
myTiles.push_back(thisTile);
// cout << gridX << endl;
i++;
}
}
/*---------------------------------------------*/
//.........这里部分代码省略.........
开发者ID:Stewartm91,项目名称:NWS_Collabs,代码行数:101,代码来源:testApp.cpp
示例17: Tiles
namespace game {
// the Tile Matrix
template<typename T, int w, int h>
class Tiles {
protected:
std::array<std::array<T, h>, w> tile_matrix;
public:
Tiles() { loadTiles("tiles.txt"); }
T operator()(int x, int y) {
return tileAt(x,y);
}
T tileAt(int x, int y) {
return tile_matrix[x][y];
}
// load tile matrix
void loadTiles(std::string fileName) {
for(int x = 0; x < w; ++x) {
for(int y = 0; y < h; ++y)
tile_matrix[x][y] = 1+rand()%255;
}
}
};
class Position {
protected:
Position() = default;
Position(int cx, int cy, int cw, int ch) : x{cx}, y{cy}, w{cw}, h{ch}, cur_frame{0} {}
int x,y,w,h;
int cur_frame;
};
const int width = 640;
const int height = 480;
Tiles<int, width, height> matrix;
enum {DIRECTION_LEFT=0, DIRECTION_RIGHT, DIRECTION_UP, DIRECTION_DOWN};
class Hero : protected Position {
public:
Hero();
Hero(int x, int y, int w, int h) : Position(x,y,w,h) , speed{1}, direction{DIRECTION_RIGHT} {}
Hero(int x, int y) : Position(x,y,0,0), speed{1}, direction{DIRECTION_RIGHT} {}
void move(int dir) {
switch(dir) {
case DIRECTION_LEFT:
if(x > 0 && matrix.tileAt(x-1, y) >= 1) x -= speed;
break;
case DIRECTION_RIGHT:
if(x+1 < width && matrix.tileAt(x+1,y) >= 1)
x += speed;
break;
case DIRECTION_UP:
if(y > 0 && matrix.tileAt(x,y-1) >= 1) y -= speed;
break;
case DIRECTION_DOWN:
if(y+1 < height && matrix.tileAt(x,y+1) >= 1)
y += speed;
break;
}
}
std::string toString() {
std::ostringstream stream;
stream << "Hero is at: " << x << ", " << y << ", " << w << ", " << h << "\n";
stream << "Hero speed: " << speed << "\n";
return stream.str();
}
protected:
int speed, direction;
};
}
开发者ID:lostjared,项目名称:cplusplus11.Examples,代码行数:77,代码来源:hero.hpp
示例18: move
void move(int dir) {
switch(dir) {
case DIRECTION_LEFT:
if(x > 0 && matrix.tileAt(x-1, y) >= 1) x -= speed;
break;
case DIRECTION_RIGHT:
if(x+1 < width && matrix.tileAt(x+1,y) >= 1)
x += speed;
break;
case DIRECTION_UP:
if(y > 0 && matrix.tileAt(x,y-1) >= 1) y -= speed;
break;
case DIRECTION_DOWN:
if(y+1 < height && matrix.tileAt(x,y+1) >= 1)
y += speed;
break;
}
}
开发者ID:lostjared,项目名称:cplusplus11.Examples,代码行数:18,代码来源:hero.hpp
示例19: get
const Tile* get(uint32_t id) const
{
//FIXME: Commenting out tiles in sprites.strf makes tiles.size() fail - it's being set to the first tile commented out.
assert(id < tiles.size());
Tile* tile = tiles[id];
if(!tile) {
log_warning << "Invalid tile: " << id << std::endl;
return tiles[0];
}
if(tile->images.size() == 0 && tile->imagespecs.size() != 0)
tile->load_images(tiles_path);
return tile;
}
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:15,代码来源:tile_manager.hpp
示例20: GetRandomTile
inline Tile* Map::GetRandomTile(){
int randomTileIndex = GetRandomIntInRange(1, m_tiles.size()-1);
return &(m_tiles[randomTileIndex]);
}
开发者ID:achen889,项目名称:Warlockery_Engine,代码行数:6,代码来源:Map.hpp
注:本文中的Tiles类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论