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


C++ Shot::active方法代码示例

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


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

示例1: buttonDown

        void buttonDown(Gosu::Button btn) 
        { 
		  if (onStartScreen)
		  {
			  onStartScreen = false;
			  level = 1;
			  player.resetPlayer();
			  loadLevel(level, true);
		  }
		  else if (player.isDead())
		  {
			  onStartScreen = true;
			  level = 0;
			  round = 1;
			  loadLevel(level, true);
		  }
		  else
		  {			
			  if (btn == Gosu::kbEscape)
				close();
			  else if ((btn == Gosu::kbReturn || btn == Gosu::kbEnter) && !transitioning)
			  {
				  if (paused)
					paused = false;
				  else
					paused = true;
			  }

			  if (!paused && !shot.active() && !player.isOnFire())
			  {
				  if (btn == Gosu::kbSpace && player.isStandingStill())
				  {
					  player.shoot(shot, enemies, environment);
				  }
				  else if (btn == Gosu::kbW)
				  {
					  player.moveGunUp();
					  player.moveGunUp();
				  }
				  else if (btn == Gosu::kbS)
				  {
					  player.moveGunDown();
					  player.moveGunDown();
				  }
				  else if (btn == Gosu::kbA)
				  {
					  player.moveGunUp();
					  player.moveGunUp();
					  player.moveGunDown();
					  player.turnLeft();
				  }
				  else if (btn == Gosu::kbD)
				  {
					  player.moveGunUp();
					  player.moveGunUp();
					  player.moveGunDown();
					  player.turnRight();
				  }
			  }
		  }
        }
开发者ID:JJKB599,项目名称:RetroGame,代码行数:61,代码来源:GameWindow.cpp

示例2: update

        void update() {
        
          if (transitioning) {
            if (difftime(time(NULL), startTime) >= 5) {
              transitioning = false;
              player.setAscending(true);
			  player.setStandingStill();
              round += 1;
              level = 1;
              loadLevel(1, true);
            }
          }
          else if (!onStartScreen && !paused) {
            player.songUpdate();
            std::list<Enemy>::iterator cur;

            // Check if the player is on a set of stairs
            if (playerOnStairs(player, up) && player.isAscending()) {
              if (level < 3)
			  {
                level += 1;
				player.setScore(player.getScore() + 5);
			  }
              loadLevel(level, true);
            }

            if (playerOnStairs(player, down) && (player.isAscending() == false)) {
              if (level > 1)
			  {
                level -= 1;
				player.setScore(player.getScore() + 5);
			  }
              else {
                time(&startTime);
                transitioning = true;
                level = -1;
              }
              
              loadLevel(level, false);
            }


            // Check for collisions
            player.checkForEnemyCollisions(enemies);
            player.checkForItemCollisions(items);
            
            if (!shot.active() && !player.isOnFire())
            {
              // Move the player
              if (input().down(Gosu::kbUp) || input().down(Gosu::gpUp))
              {
                if (canMoveDirection(player.x(), player.y(), environment, UP))
                player.moveUp();
              }
              else if (input().down(Gosu::kbDown) || input().down(Gosu::gpDown))
              {
                if (canMoveDirection(player.x(), player.y(), environment, DOWN))
                player.moveDown();
              }
              else if (input().down(Gosu::kbLeft) || input().down(Gosu::gpLeft))
              {
                if (canMoveDirection(player.x(), player.y(), environment, LEFT) && player.getCurrentWalkCycleDirection() == LEFT)
                player.moveLeft();
                else
                player.turnLeft();
              }
              else if (input().down(Gosu::kbRight) || input().down(Gosu::gpRight))
              {
                if (canMoveDirection(player.x(), player.y(), environment, RIGHT) && player.getCurrentWalkCycleDirection() == RIGHT)
                player.moveRight();
                else
                player.turnRight();
              }
            }

            // Move the player
            player.move();
            
            // Move the enemy
            cur = enemies.begin();
            while (cur != enemies.end())
            {
              cur->move(environment);
              ++cur;
            }
          }
        }
开发者ID:JJKB599,项目名称:RetroGame,代码行数:87,代码来源:GameWindow.cpp


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