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


C++ Assignment::setImage方法代码示例

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


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

示例1: studentAction

void TDefense::studentAction()
{
    QPoint *myTarget = myStudent->getTarget();
    studentShoot(myTarget);

    for (int i = 0; i < myStudentBullets.size(); i++)
    {
        Bullet *curBullet = myStudentBullets[i];
        double bX = curBullet->getX();
        double bY = curBullet->getY();
        double bVX = curBullet->getVX();
        double bVY = curBullet->getVY();
        int bHeight = curBullet->getImage().height();
        int bWidth = curBullet->getImage().width();

        curBullet->move();
        curBullet->setVX(bVX);
        curBullet->setVY(bVY);

        for (int j = 0; j < myProblems.size(); j++)
        {
            Problem *secondProblem = myProblems[j];
            if (curBullet->intersects(secondProblem))
            {
                secondProblem->health--;
                if (secondProblem->health == 0)
                {
                    funds += 10;
                    myProblems.remove(j);
                    numEnemiesShot++;
                }
                studentShotFired = false;
                studentBulletAdded = false;
            }
            else if ((bY <= 0 && bVY < 0) || (bX <= 0 && bVX < 0 || (gpHeight <= (bY + bHeight)) && bY > 0 && bVY > 0) || ((gpWidth == (bX + bWidth)) && bVX > 0 && bVX > 0))
            {
                studentShotFired = false;
                studentBulletAdded = false;
            } // end else if
            if (!studentShotFired && myStudentBullets.size() > 0)
            {
                myStudentBullets.remove(i);
            } // end if
        } // end inner for

        for (int j = 0; j < myAssignments.size(); j++)
        {
            Assignment *secondAssignment = myAssignments[j];
            if (curBullet->intersects(secondAssignment))
            {
                secondAssignment->health--;
                secondAssignment->setImage(assignment2);
                if (secondAssignment->health == 0)
                {
                    funds += 20;
                    myAssignments.remove(j);
                    numEnemiesShot++;
                }
                studentShotFired = false;
                studentBulletAdded = false;
            }
            else if ((bY <= 0 && bVY < 0) || (bX <= 0 && bVX < 0 || (gpHeight <= (bY + bHeight)) && bY > 0 && bVY > 0) || ((gpWidth == (bX + bWidth)) && bVX > 0 && bVX > 0))
            {
                studentShotFired = false;
                studentBulletAdded = false;
            } // end else if
            if (!studentShotFired && myStudentBullets.size() > 0)
            {
                myStudentBullets.remove(i);
            } // end if
        } // end inner for

        for (int j = 0; j < myPapers.size(); j++)
        {
            Paper *secondPaper = myPapers[j];
            if (curBullet->intersects(secondPaper))
            {
                secondPaper->health--;
                switch (secondPaper->health)
                {
                case 4:
                    secondPaper->setImage(paper2);
                    break;
                case 3:
                    secondPaper->setImage(paper3);
                    break;
                case 2:
                    secondPaper->setImage(paper4);
                    break;
                case 1:
                    secondPaper->setImage(paper5);
                    break;
                }
                if (secondPaper->health == 0)
                {
                    funds += 40;
                    myPapers.remove(j);
                    numEnemiesShot++;
                }
                studentShotFired = false;
//.........这里部分代码省略.........
开发者ID:usc-csci102-spring2012,项目名称:CS102_Spring2012_ImataSafo_Anta,代码行数:101,代码来源:tdefense.cpp


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