本文整理汇总了C++中ActionList::checkAction方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionList::checkAction方法的具体用法?C++ ActionList::checkAction怎么用?C++ ActionList::checkAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionList
的用法示例。
在下文中一共展示了ActionList::checkAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Player::update(ActionList _actionList)
{
if (!canShootBullet && cooldownClock.getElapsedTime().asSeconds() > 0.1) {
canShootBullet = true;
cooldownClock.restart();
}
bool onGround = false;
if ((GameScreen::gameMap->getMapPos(((x+13)/32), ((y+16)/32)) == 1 || GameScreen::gameMap->getMapPos(((x-13)/32), ((y+16)/32)) == 1) && (((int)y-5)/32 != ((int)y+5)/32))
onGround = true;
// Move right
if (_actionList.checkAction('r')) {
if (!_actionList.checkAction('~')) {
if (direction != 1) {
direction = 1;
tileChunk.left = 0;
myTexture.loadFromImage(spriteSheet, tileChunk);
}
}
if (xVelocity < 6)
xVelocity++;
}
else if (xVelocity > 0 && !(_actionList.checkAction('l') || _actionList.checkAction('r')))
xVelocity -= xVelocity/3;
// Move left
if (_actionList.checkAction('l')) {
if (!_actionList.checkAction('~')) {
if (direction != -1) {
direction = -1;
tileChunk.left = 32;
myTexture.loadFromImage(spriteSheet, tileChunk);
}
}
if (xVelocity > -6)
xVelocity--;
}
else if (xVelocity < 0 && !(_actionList.checkAction('l') || _actionList.checkAction('r')))
xVelocity -= xVelocity/3;
// Jump
if (_actionList.checkAction(' ') && onGround && yVelocity >= 0) {
tileChunk.top = 0;
myTexture.loadFromImage(spriteSheet, tileChunk);
if (_actionList.checkAction('d')/* && !_actionList.checkAction('~')*/) {
yVelocity = 9;
onGround = false;
}
else {
yVelocity = -8;
onGround = false;
tileChunk.top = 32;
myTexture.loadFromImage(spriteSheet, tileChunk);
}
} else if (_actionList.checkAction(' ') && !onGround && yVelocity < -6) {
gravity = 0.12;
}
// Shoot
if (_actionList.checkAction('~') && canShootBullet) {
shootBullet = true;
canShootBullet = false;
cooldownClock.restart();
/*if (_actionList.checkAction('d')) {
if (!onGround)
y -= 4;
shootdir = 2;
} else if (_actionList.checkAction('u')) {
if (!onGround)
y += 4;
shootdir = -2;
} else {*/
shootdir = direction;
if (direction == 1)
x -= 4;
if (direction == -1)
x += 4;
//}
}
// Gravity
if (!onGround && yVelocity < 9) {
yVelocity += gravity;
gravity = 1;
} else if (onGround && yVelocity > 0){
yVelocity = 0;
if (GameScreen::gameMap->getMapPos((x/32), ((y)/32)) == 1 && (int)y % 32 != 0 && (int)y % 32 < 9) {
y -= ((int)y % 32);
}
else if ((int)y % 32 != 0)
y += (32 - ((int)y % 32));
} if (GameScreen::gameMap->getMapPos(((x)/32), ((y)/32)) == -1) {
dead = true;
}
if (!hitCheck)
mySprite.setColor(sf::Color::White);
if (hitCheck)
hitCheck = false;
//.........这里部分代码省略.........