本文整理汇总了C++中Tower类的典型用法代码示例。如果您正苦于以下问题:C++ Tower类的具体用法?C++ Tower怎么用?C++ Tower使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tower类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Mob
void Game::levelDesign()
{
// For the moment this function is fully automated
// maybe in the future i'll need to add some features for level
// desiners
int num_mobs = 3;
int num_towers = 5;
grille->generatePath();
grille->print();
for( int i = 0; i < num_mobs; ++i )
{
Mob * nouvMob = new Mob(100,4,grille->getPath());
mobs.push_back(nouvMob);
}
for( int i = 0; i < num_towers; ++i )
{
Tower * nouvTower = new Tower(1, 2, 50, 1, 10, 35+i, grille->getSize());
gold_ -= nouvTower->howMuch();
towers.push_back(nouvTower);
}
}
开发者ID:Tarrke,项目名称:tbtd,代码行数:25,代码来源:game.cpp
示例2: QGraphicsView
Game::Game(): QGraphicsView(){
// create a scene
scene = new QGraphicsScene(this);
scene->setSceneRect(0,0,800,600);
// set the scene
setScene(scene);
// create a tower
Tower * t = new Tower();
t->setPos(250,250);
// add the tower to scene
scene->addItem(t);
// set curosr
cursor = nullptr;
build = nullptr;
setMouseTracking(true);
// alter window
setFixedSize(800,600);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// create enemy
Enemy * enemy = new Enemy();
scene->addItem(enemy);
// test code
BuildTowerIcon * ic = new BuildTowerIcon();
scene->addItem(ic);
}
开发者ID:Fader1997,项目名称:QtGameTutorial,代码行数:34,代码来源:Game.cpp
示例3: main
int main() {
Tower tower = Tower();
tower.display();
system("Pause");
return 0;
}
开发者ID:tinng95,项目名称:Hanoi,代码行数:7,代码来源:Tower.cpp
示例4: UpdateEnemyPathing
void MultiplayerMap::UpdateEnemyPathing()
{
for (int i = 0; i < towers.size(); i++)
{
Tower *t = towers.at(i);
int x = t->GetX() / 32;
int y = t->GetY() / 32;
pathingArr[TILES_X * y + x].type = 1;
pathingArr[TILES_X * (y + 1) + x].type = 1;
pathingArr[TILES_X * y + (x + 1)].type = 1;
pathingArr[TILES_X * (y + 1) + (x + 1)].type = 1;
}
for (int i = 0; i < enemies.size(); i++)
{
Enemy *en = enemies.at(i);
Vector2f pos = en->GetPos();
TileNode enemyPos = TileNode(pos.x / 32, pos.y / 32, nullptr);
TileNode destination;
if (en->GetOwnerID() == 1)
{
destination = endNode;
}
else
destination = startNode;
vector<TileNode> enemyPath = pathfinder->Search(enemyPos, destination);
enemyPath.insert(enemyPath.begin(), enemyPos);
en->UpdatePath(enemyPath);
}
}
开发者ID:stefan-j,项目名称:TowerDefenseSFML,代码行数:34,代码来源:MultiplayerMap.cpp
示例5: createRing
//-----------------------------------------------------------------------------
// create vertex and index buffers
void Wreck::createBuffers()
{
int sideSteps = 50;
int outSteps = 240;
int ringSteps = 30;
int circleSteps = 50;
int vertexCount = 3* (outSteps+1) * (sideSteps+1);
int indexCount = 3*6*outSteps*sideSteps;
vertexCount += 3* (circleSteps+1) * (ringSteps+1);
indexCount += 3*6*circleSteps*ringSteps;
m_vertexes = mgVertexTA::newBuffer(vertexCount);
m_indexes = mgDisplay->newIndexBuffer(indexCount, false, true);
for (int i = 0; i < 3; i++)
{
mgMatrix4 model;
model.translate(0, 0, 65+40*i);
createRing(model, ringSteps, circleSteps);
}
createSpine(sideSteps, outSteps);
for (int i = 0; i < m_towers.length(); i++)
{
Tower* tower = (Tower*) m_towers[i];
if (tower != NULL)
tower->createBuffers();
}
}
开发者ID:bond4u,项目名称:SeaOfMemes,代码行数:35,代码来源:Wreck.cpp
示例6:
void GeneticAlgorithmProfile1::RestoreState(cocos2d::Layer& _sc)
{
GameScene* gs = (GameScene*) & _sc;
///////////////////////////////////////////////////////
//restore the gamestate
gs->gameState = this->gamestateBK;
gs->playerHandler->SetCurrency(this->currencyBK);
gs->playerHandler->SetLifePoints(this->lifePointsBK);
gs->playerHandler->SetPlayerName(this->playerNameBK);
gs->creepDeploymentDelay = this->creepSpawnDelayBK;
gs->nextWaveStartingDelay = this->nextWaveStartingDelayBK;
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
//restore the wave state
this->speedMultiplier = this->speedMultiplierBK;
this->hpMultiplier = this->hpMultiplierBK;
this->numOfStartingCreeps = this->numOfStartingCreepsBK;
this->numOfCreepsMultiplier = this->numOfCreepsMultiplierBK;
this->numOfCreepsAddedPerWave = this->numOfCreepsAddedPerWaveBK;
this->specialCreepSet = this->specialCreepSetBK;
this->specialCreepSpeedMultiplier = this->specialCreepSpeedMultiplierBK;
this->specialCreepHPMultiplier = this->specialCreepHPMultiplierBK;
this->specialCreepSpawnFrequency = this->specialCreepSpawnFrequencyBK;
this->roundsAfterSpawn = this->roundsAfterSpawnBK;
this->multiplyCreepNumbersPerRound = this->multiplyCreepNumbersPerRoundBK;
this->round = this->roundBK;
///////////////////////////////////////////////////////
//remove speed boost of tower
for ( std::list<Tower*>::iterator tower = gs->towerslist.begin(); tower != gs->towerslist.end(); ++tower )
{
Tower* t = *tower;
t->SetInbetweenAttacksPeriod(t->GetInbetweenAttacksPeriod() * speedBoost);
}
}
开发者ID:geofl,项目名称:tdai,代码行数:34,代码来源:GeneticAlgorithmProfile1.cpp
示例7: getTower
void MultiBullet::nextFrame(){
Tower *temp = getTower();
if(temp != NULL){
SetPosition(temp->GetPosition().x, temp->GetPosition().y);
m_circ = sf::Shape::Circle(temp->GetPosition().x, temp->GetPosition().y, m_attack_radius, sf::Color::Red, 2, sf::Color::Blue);
}
}
开发者ID:andressbarajas,项目名称:Isla-Vista-Tower-Defense,代码行数:8,代码来源:cMultiBullet.cpp
示例8: tower_height
double tower_height(const Tower& t){
Tower::const_iterator it;
double res = 0;
for(it=t.begin(); it!=t.end(); it++){
res += it->height();
}
return res;
}
开发者ID:xdavidliu,项目名称:box-stacking,代码行数:8,代码来源:bottom.cpp
示例9: CCARRAY_FOREACH
void Enemy::getRemoved()
{
CCObject *pObject = NULL;
CCARRAY_FOREACH(attackedBy, pObject)
{
Tower *attacker = (Tower*)pObject;
attacker->targetKilled();
}
开发者ID:Kurukshetran,项目名称:Cocos2dxGame,代码行数:8,代码来源:Enemy.cpp
示例10: Tower
Tower *Tower::create(TowerType type, ControllerType controller) {
Tower *tower = new Tower();
if (tower && tower->initWithType(type, controller)) {
tower->autorelease();
return tower;
}
CC_SAFE_DELETE(tower);
return tower;
}
开发者ID:adahera222,项目名称:Samurai-TD,代码行数:9,代码来源:Tower.cpp
示例11: printJet
void printJet(Jet *jet)
{
GenParticle *particle;
Muon *muon;
Track *track;
Tower *tower;
TObject *object;
TLorentzVector momentum;
momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
//TRefArray constituentarray(jet->Constituents);
TRefArray particlearray(jet->Particles);
cout<<"Looping over jet constituents. Jet pt: "<<jet->PT<<", eta: "<<jet->Eta<<", phi: "<<jet->Phi<<endl;
// Loop over all jet's constituents
for(Int_t j = 0; j < jet->Constituents.GetEntriesFast(); ++j)
{
object = jet->Constituents.At(j);
// Check if the constituent is accessible
if(object == 0) continue;
if(object->IsA() == GenParticle::Class())
{
particle = (GenParticle*) object;
cout << " GenPart pt: " << particle->PT << ", eta: " << particle->Eta << ", phi: " << particle->Phi << endl;
momentum += particle->P4();
}
else if(object->IsA() == Track::Class())
{
track = (Track*) object;
cout << " Track pt: " << track->PT << ", eta: " << track->Eta << ", phi: " << track->Phi << endl;
momentum += track->P4();
}
else if(object->IsA() == Tower::Class())
{
tower = (Tower*) object;
cout << " Tower pt: " << tower->ET << ", eta: " << tower->Eta << ", phi: " << tower->Phi << endl;
momentum += tower->P4();
}
else if(object->IsA() == Muon::Class())
{
muon = (Muon*) object;
cout << " Muon pt: " << muon->PT << ", eta: " << muon->Eta << ", phi: " << muon->Phi << endl;
momentum += muon->P4();
}
}
cout << " constituent sum pt: " << momentum.Pt() <<" eta "<< momentum.Eta() <<" phi " << momentum.Phi() << std::endl;
for (Int_t j =0; j<jet->Particles.GetEntries(); j++){
GenParticle *p_tmp = (GenParticle*) particlearray.At(j);
printGenParticle(p_tmp);
}
}
开发者ID:tahuang1991,项目名称:oldDelphes,代码行数:56,代码来源:DiHiggs_h2tohh.C
示例12: FireTower
Float FireTower(Script * script)
{
Tower * tower = (Tower *)script->GetSource();
if ((tower != NULL) && (tower->GetState() == true) && (tower->CheckType(OBJ_TYPE_TOWER) == true))
{
AddProjectile(tower);
return true;
}
return false;
}
开发者ID:Dingf,项目名称:Paper-TD,代码行数:10,代码来源:scripttowerhandler.cpp
示例13: draw_all_views
void Game::build_mode_run() {
draw_all_views();
if( keyboard.isKeyPressed() ) {
coord xy = gs->cursor->get_coord(); //get current location of cursor
coord oldxy = xy;
switch( keyboard.getKeyPressed() ) {
case 'K': //left arrow
if( xy.x > 0 ) {
xy.x = xy.x - 1;
update_cursor( xy, oldxy );
m_change = true;
}
break;
case 'M': //right arrow
if( xy.x < 14 ) {
xy.x = xy.x + 1;
update_cursor( xy, oldxy );
m_change = true;
}
break;
case 'H': //up arrow
if( xy.y > 0 ) {
xy.y = xy.y - 1;
update_cursor( xy, oldxy );
m_change = true;
}
break;
case 'P': //down arrow
if( xy.y < 14 ) {
xy.y = xy.y + 1;
update_cursor( xy, oldxy );
m_change = true;
}
break;
case (int)13:
Tower *t = new Laser(); //TODO: menu to choose a tower
if (gs->player->get_money() >= t->get_cost() && gs->map->check_can_build(const_cast<coord &>(gs->cursor->get_coord()))) { //check if player has enough money, and if the tile can be built on top of(if it's empty and if just a "plain" tile, ie. not path or base)
coord tower_xy = gs->cursor->get_coord();
gs->player->set_money(gs->player->get_money() - t->get_cost()); //update player money
tower_xy.layer = 1; //makes sure that tower is displayed on proper layer
t->set_coord(tower_xy);
gs->map->update(t); //update with tower
}
else
delete t;
gs->map->clear_cursor(gs->cursor->get_coord()); //clear cursor at current location
switch_to_edit();
m_change = true;
}
}
}
开发者ID:rdelpilar,项目名称:Tower-Defense,代码行数:55,代码来源:Game.cpp
示例14: BuildTower
Float BuildTower(Script * script)
{
if (script->VerifyArguments(2) == true)
{
Word * targetWord = script->GetNextWord();
Word * posWord = script->GetNextWord();
Point2D position(0, 0);
Point2D * pos = (Point2D *)(uint32)posWord->value;
if (pos != NULL)
{
position.SetValues(pos->GetX(), pos->GetY());
}
else
{
return false;
}
if ((IntervalCheck(position.GetX(), 1, GRID_SIZE - 2) == true) && (IntervalCheck(position.GetY(), 1, GRID_SIZE - 2) == true))
{
if (targetWord->type == POINTER)
{
Object * target = script->GetTarget(targetWord);
if ((target != NULL) && (target->CheckType(OBJ_TYPE_TOWER) == true))
{
Grid * grid = WorldGame.GetGrid();
Tower * tower = (Tower *)target;
//To bypass grid auto-filling
tower->SetState(false);
Point2D towerCoords = tower->GetPosition();
towerCoords.SetValues((towerCoords.GetX() - 80)/32, (towerCoords.GetY() - 80)/32);
grid->SetPath(towerCoords, 0);
if (BuildTower(tower->GetTowerType(), position, true) == true)
{
Tower * newTower = grid->GetData(Point2D(position.GetX(), position.GetY()));
tower->SetState(true);
grid->FindPath(Origin);
newTower->Copy(*tower);
newTower->SetUInt32Value(TOWER_VAR_BUILD_TIME, GetGameTime());
return true;
}
else
{
tower->SetState(true);
grid->FindPath(Origin);
}
}
}
else if ((targetWord->type == NUMERIC) && (IntervalCheck(targetWord->value, 1, GetTowerDataSize()) == true))
{
return (BuildTower(targetWord->value, position, true));
}
}
}
return false;
}
开发者ID:Dingf,项目名称:Paper-TD,代码行数:59,代码来源:scripttowerhandler.cpp
示例15: main
// Function: main()
int main(int argc, char ** argv)
{
PA_Init(); // Initializes PA_Lib
PA_InitVBL(); // Initializes a standard VBL
PA_InitText(1,1);
Drawable cursor(0,0,0);
cursor.Load(0, 0, (void*)pal_cursor, (void*)gfx_cursor, OBJ_SIZE_16X16, 1);
setupRotations();
u8 c = 0;
u8 x = 0;
u8 y = 0;
for (y = 0; y != 8; ++y) {
for (x = 0; x != 8; ++x) {
u16 i = y*8+x;
if (grid[i] == 1) {
Tower tower = Tower(SPRITE_TOWER_BASE+c, x*16, y*16);
tower.Load(0, 1, (void*)pal_tower, (void*)gfx_tower, OBJ_SIZE_16X16, 1);
tower_list.push_back(tower);
PA_SetSpriteRotEnable(0, tower.sprite, c);
++c;
}
}
}
s16 angle = 0;
// Infinite loop to keep the program running
while (1)
{
u8 i = 0;
for (tlist_it it = tower_list.begin(); it != tower_list.end(); ++it) {
angle = (*it).GetAngleTo(cursor);
PA_SetRotsetNoZoom(0, i, angle);
++i;
}
PA_OutputText(1, 0, 0, "Angle: %03d", angle);
PA_OutputText(1, 0, 1, "Angle2: %03d", angle);
PA_OutputText(1, 0, 2, "Cursor: %03d,%03d", cursor.position.x, cursor.position.y);
if (Stylus.Held) {
cursor.position.x = Stylus.X;
cursor.position.y = Stylus.Y;
} else {
cursor.position.x += (Pad.Held.Right - Pad.Held.Left);
cursor.position.y += (Pad.Held.Down - Pad.Held.Up);
}
cursor.Draw();
PA_WaitForVBL();
}
return 0;
} // End of main()
开发者ID:bruntonspall,项目名称:dstowerdefense,代码行数:52,代码来源:main.cpp
示例16: best_tower
Tower best_tower(const Box& b, const list<Tower>& tows){
list<Tower>::const_iterator it;
double best_height = 0;
Tower res;
for(it=tows.begin(); it!=tows.end(); it++){
double new_height = b.height() + tower_height(*it);
if(can_stack(b, *it) && new_height > best_height){
best_height = new_height;
res = *it;
res.push_front(b);
}
}
return res;
}
开发者ID:xdavidliu,项目名称:box-stacking,代码行数:14,代码来源:bottom.cpp
示例17: deleteBuffers
//-----------------------------------------------------------------------------
// delete vertex and index buffers
void Wreck::deleteBuffers()
{
delete m_indexes;
m_indexes = NULL;
delete m_vertexes;
m_vertexes = NULL;
for (int i = 0; i < m_towers.length(); i++)
{
Tower* tower = (Tower*) m_towers[i];
if (tower != NULL)
tower->deleteBuffers();
}
}
开发者ID:bond4u,项目名称:SeaOfMemes,代码行数:16,代码来源:Wreck.cpp
示例18: UpgradeToEarth
bool TowerRules::UpgradeToEarth(Ref* p, Ref & u)
{
Tower *t = (Tower*)&u;
if( t->GetElement() == ElementalAffinity::None && ((Player*)p)->GetCurrency() >= this->earthUpgradeCost )
{
t->SetElement(ElementalAffinity::Earth);
((Player*)p)->RemoveCoins(this->earthUpgradeCost);
return true;
}
else
{
return false;
}
}
开发者ID:geofl,项目名称:tdai,代码行数:14,代码来源:TowerRules.cpp
示例19: Tower
Tower* Tower::create(ValueMap model)
{
Tower *ret = new Tower(model);
if (ret && ret->init())
{
ret->autorelease();
return ret;
}
else
{
CC_SAFE_DELETE(ret);
return nullptr;
}
}
开发者ID:cubemoon,项目名称:tower-skycity-one,代码行数:14,代码来源:Tower.cpp
示例20: UpgradeAttackSpeed
bool TowerRules::UpgradeAttackSpeed(Ref* p, Ref & u)
{
Tower *t = (Tower*)&u;
if( ((Player*)p)->GetCurrency() >= this->GetSpeedUpgradeCost(*t) )
{
((Player*)p)->RemoveCoins(this->GetSpeedUpgradeCost(*t));
t->inbetweenAttacksPeriod = t->inbetweenAttacksPeriod - this->attackSpeedSub;
t->IncreaseSpeedUpgradesDone();
return true;
}
else
{
return false;
}
}
开发者ID:geofl,项目名称:tdai,代码行数:15,代码来源:TowerRules.cpp
注:本文中的Tower类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论