当前位置: 首页>>代码示例>>C++>>正文


C++ Tank::setSize方法代码示例

本文整理汇总了C++中Tank::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Tank::setSize方法的具体用法?C++ Tank::setSize怎么用?C++ Tank::setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tank的用法示例。


在下文中一共展示了Tank::setSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: moveBullets

void World::moveBullets()
{
	for (int q = 0; q < _bulletList.size(); q++) {
		if (_bulletList[q]->getKillAnimation() != 0) {
			if (_bulletList[q]->getKillAnimation() == 10) {
				delete _bulletList[q];
				_bulletList.remove(q);
			} else {
				_bulletList[q]->animation();
			}
		} else {
			QPoint pos = _bulletList[q]->getPos();
			bool withTank;
			void *status = testCollision(_bulletList[q]->getSpeed(), _bulletList[q], false, &withTank);
			if (status == nullptr) {
				switch (_bulletList[q]->getAngle()) {
					case 0: {
						_bulletList[q]->setPos(QPoint(pos.x(), pos.y() - _bulletList[q]->getSpeed()));
						break;
					}
					case 1: {
						_bulletList[q]->setPos(QPoint(pos.x() + _bulletList[q]->getSpeed(), pos.y()));
						break;
					}
					case 2: {
						_bulletList[q]->setPos(QPoint(pos.x(), pos.y() + _bulletList[q]->getSpeed()));
						break;
					}
					case 3: {
						_bulletList[q]->setPos(QPoint(pos.x() - _bulletList[q]->getSpeed(), pos.y()));
						break;
					}
				}
			} else {
				if (withTank) {
					Tank *tank = ((Tank*)status);
					tank->hit();
					if (tank->getHp() == 0) {
						tank->setSize(0);
					}
				} else {
					Wall *wall = ((Wall*)status);
					wall->hit();
					if (wall->getHp() == 0) {
						for (int i = 0; i < _wallList.size(); i++) {
							if (_wallList[i] == wall) {
								if (_wallList[i] == _playerBase) {
									_playerBase = nullptr;
								}
								delete _wallList[i];
								_wallList.remove(i);
							}
						}
					}
				}
				_bulletList[q]->animation();
			}
		}
	}
}
开发者ID:antonikon,项目名称:BattleCity,代码行数:60,代码来源:world.cpp

示例2: playVideo

void World::playVideo()
{
	if (_tankList.size() == 3) {
		_other++;
		if (_other % 30 == 0) {
			fire(_tankList[1]);
		} else if (_other % 51 == 0) {
			fire(_tankList[2]);
		}
	} else if (_tankList.size() == 2 & _other > 0 & _other < 1000) {
		_tankList[0]->move(false);
		_tankList[1]->move(false);
		_tankList[0]->rotate(3);
		_tankList[1]->rotate(1);
		_other = 0;

	} else if (_tankList.size() == 2 &_other == 0) {
		_other = -1;
		for (int q = 0; q < 8; q ++) {
			Tank *tank = new Tank;
			tank->setPos(QPoint(q * 50 + 12 * q + 6,-50));
			tank->setTeam(0);
			tank->setAngle(2);
			tank->setSpeed(1);
			tank->move(true);
			_tankList.append(tank);
		}
	} else if (_other <= -1 & _other > -50) {
		_other--;
	} else if (_other == -50) {
		_other--;
		_tankList[0]->setAngle(2);
		_tankList[1]->setAngle(2);
		_tankList[0]->move(true);
		_tankList[1]->move(true);
	}
	else if (_other <= -51 & _tankList.size() == 10) {
		_other--;
		if (_other % 50 == 0) {
			for (int q = 0 ; q < 8; q ++) {
				fire(_tankList[q + 2]);
			}
		}
	} else if ( _tankList.size() == 8 & _other < 0) {
		Tank *tank = new Tank;
		tank->setTeam(2);
		tank->setPos(QPoint(156, - 70));
		tank->setAngle(2);
		tank->setSpeed(1);
		tank->setSize(0);
		tank->move(true);
		_tankList.append(tank);
	} else if (_tankList.size() == 9 & _other < 0) {
		if (_tankList[8]->getPos().y() == 216) {
			_tankList[8]->move(false);
			_other = 0;
		}
	} else if (_tankList.size() == 9 & _other >= 0) {
		_other++;
		if (_other == 625) {
			for (int q = 0; q < _tankList.size() - 1; q++) {
				delete _tankList[0];
			}
			_tankList.remove(0,8);
			for (int q = 0; q < 8; q ++) {
				Tank *tank = new Tank;
				tank->setPos(QPoint(-50,q * 50 + 12 * q + 6));
				tank->setTeam(0);
				tank->setAngle(1);
				tank->setSpeed(rand() % 4 + 1);
				tank->move(true);
				_tankList.append(tank);
			}
			for (int q = 0; q < 8; q ++) {
				Tank *tank = new Tank;
				tank->setPos(QPoint(550,q * 50 + 12 * q + 6));
				tank->setTeam(1);
				tank->setAngle(3);
				tank->setSpeed(rand() % 4 + 1);
				tank->move(true);
				_tankList.append(tank);
			}
			_other = 1000;
		}
	} else if (_other == 1000 & _tankList.size() != 1) {
		for (int q = 1; q < _tankList.size(); q ++) {
			int f = rand() % 2;
			if (f == 1) {
				fire(_tankList[q]);
			}
		}
	} else if (_other >= 1000 & _tankList.size() == 1){
		_other++;
		if (_other == 1100) {
			delete _playerBase;
			delete _playerTank;
			gameOver();
			loadMission(0);
			_isVideo = false;
		}
//.........这里部分代码省略.........
开发者ID:antonikon,项目名称:BattleCity,代码行数:101,代码来源:world.cpp


注:本文中的Tank::setSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。