本文整理汇总了C++中BadGuy类的典型用法代码示例。如果您正苦于以下问题:C++ BadGuy类的具体用法?C++ BadGuy怎么用?C++ BadGuy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BadGuy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
FlipLevelTransformer::transform_badguy(float height, BadGuy& badguy)
{
Vector pos = badguy.get_start_position();
pos.y = height - pos.y;
badguy.set_start_position(pos);
}
示例2: hit
HitResponse
Block::collision(GameObject& other, const CollisionHit& )
{
Player* player = dynamic_cast<Player*> (&other);
if(player) {
if(player->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) {
hit(*player);
}
}
// only interact with other objects if...
// 1) we are bouncing
// and
// 2) the object is not portable (either never or not currently)
Portable* portable = dynamic_cast<Portable*> (&other);
if(bouncing && (portable == 0 || (!portable->is_portable()))) {
// Badguys get killed
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
badguy->kill_fall();
}
// Coins get collected
Coin* coin = dynamic_cast<Coin*> (&other);
if(coin) {
coin->collect();
}
}
return SOLID;
}
示例3: try_drop
HitResponse
BonusBlock::collision(GameObject& other, const CollisionHit& hit_){
Player* player = dynamic_cast<Player*> (&other);
if (player) {
if (player->does_buttjump)
try_drop(player);
}
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
// hit contains no information for collisions with blocks.
// Badguy's bottom has to be below the top of the block
// SHIFT_DELTA is required to slide over one tile gaps.
if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > bbox.get_top() + SHIFT_DELTA ) ){
try_open(player);
}
}
Portable* portable = dynamic_cast<Portable*> (&other);
if(portable) {
MovingObject* moving = dynamic_cast<MovingObject*> (&other);
if(moving->get_bbox().get_top() > bbox.get_bottom() - SHIFT_DELTA) {
try_open(player);
}
}
return Block::collision(other, hit_);
}
示例4: collision
HitResponse
Brick::collision(GameObject& other, const CollisionHit& hit_){
Player* player = dynamic_cast<Player*> (&other);
if (player) {
if (player->does_buttjump) try_break(player);
if (player->is_stone() && player->get_velocity().y >= 280) try_break(player); // stoneform breaks through bricks
}
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
// hit contains no information for collisions with blocks.
// Badguy's bottom has to be below the top of the brick
// SHIFT_DELTA is required to slide over one tile gaps.
if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > bbox.get_top() + SHIFT_DELTA ) ){
try_break(player);
}
}
Portable* portable = dynamic_cast<Portable*> (&other);
if(portable) {
MovingObject* moving = dynamic_cast<MovingObject*> (&other);
if(moving->get_bbox().get_top() > bbox.get_bottom() - SHIFT_DELTA) {
try_break(player);
}
}
Explosion* explosion = dynamic_cast<Explosion*> (&other);
if(explosion && explosion->hurts()) {
try_break(player);
}
IceCrusher* icecrusher = dynamic_cast<IceCrusher*> (&other);
if(icecrusher && coin_counter == 0)
try_break(player);
return Block::collision(other, hit_);
}
示例5: kill_fall
bool
MrIceBlock::collision_squished(GameObject& object)
{
Player* player = dynamic_cast<Player*>(&object);
if(player && (player->does_buttjump || player->is_invincible())) {
player->bounce(*this);
kill_fall();
return true;
}
switch(ice_state) {
case ICESTATE_KICKED:
{
BadGuy* badguy = dynamic_cast<BadGuy*>(&object);
if (badguy) {
badguy->kill_fall();
break;
}
}
// fall through
case ICESTATE_NORMAL:
{
squishcount++;
if (squishcount >= MAXSQUISHES) {
kill_fall();
return true;
}
}
set_state(ICESTATE_FLAT);
nokick_timer.start(NOKICK_TIME);
break;
case ICESTATE_FLAT:
{
MovingObject* movingobject = dynamic_cast<MovingObject*>(&object);
if (movingobject && (movingobject->get_pos().x < get_pos().x)) {
dir = RIGHT;
} else {
dir = LEFT;
}
}
if (nokick_timer.check()) set_state(ICESTATE_KICKED);
break;
case ICESTATE_GRABBED:
assert(false);
break;
}
if (player) player->bounce(*this);
return true;
}
示例6: collision
HitResponse
Brick::collision(GameObject& other, const CollisionHit& hit){
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
// hit contains no information for collisions with blocks.
// Badguy's bottom has to be below the top of the brick
// +7 is required to slide over one tile gaps.
if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > get_bbox().get_top() + 7.0 ) ){
try_break(false);
}
}
return Block::collision(other, hit);
}
示例7:
HitResponse
HurtingPlatform::collision(GameObject& other, const CollisionHit& )
{
Player* player = dynamic_cast<Player*>(&other);
if (player) {
player->kill(false);
}
BadGuy* badguy = dynamic_cast<BadGuy*>(&other);
if (badguy) {
badguy->kill_fall();
}
return FORCE_MOVE;
}
示例8: collision_badguy
HitResponse
BadGuy::collision(GameObject& other, const CollisionHit& hit)
{
if (!is_active()) return ABORT_MOVE;
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy && badguy->is_active() && badguy->get_group() == COLGROUP_MOVING) {
/* Badguys don't let badguys squish other badguys. It's bad. */
#if 0
// hit from above?
if (badguy->get_bbox().p2.y < (bbox.p1.y + 16)) {
if(collision_squished(*badguy)) {
return ABORT_MOVE;
}
}
#endif
return collision_badguy(*badguy, hit);
}
Player* player = dynamic_cast<Player*> (&other);
if(player) {
// hit from above?
if (player->get_bbox().p2.y < (bbox.p1.y + 16)) {
if(player->is_stone()) {
kill_fall();
return FORCE_MOVE;
}
if(collision_squished(*player)) {
return FORCE_MOVE;
}
}
if(player->is_stone()) {
collision_solid(hit);
return FORCE_MOVE;
}
return collision_player(*player, hit);
}
Bullet* bullet = dynamic_cast<Bullet*> (&other);
if(bullet)
return collision_bullet(*bullet, hit);
return FORCE_MOVE;
}
示例9: hit
HitResponse
Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit)
{
//Let the Kugelblitz explode, too? The problem with that is that
//two Kugelblitzes would cancel each other out on contact...
other.kill_fall();
return hit(chit);
}
示例10:
HitResponse
Stalactite::collision_badguy(BadGuy& other, const CollisionHit& hit)
{
if (state == STALACTITE_SQUISHED) return FORCE_MOVE;
// ignore other Stalactites
if (dynamic_cast<Stalactite*>(&other)) return FORCE_MOVE;
if (state != STALACTITE_FALLING) return BadGuy::collision_badguy(other, hit);
if (other.is_freezable()) {
other.freeze();
} else {
other.kill_fall();
}
return FORCE_MOVE;
}
示例11:
HitResponse
Explosion::collision(GameObject& other, const CollisionHit& )
{
if ((state != STATE_EXPLODING) || !hurt)
return ABORT_MOVE;
Player* player = dynamic_cast<Player*>(&other);
if(player != 0) {
player->kill(false);
}
BadGuy* badguy = dynamic_cast<BadGuy*>(&other);
if(badguy != 0) {
badguy->kill_fall();
}
return ABORT_MOVE;
}
示例12:
HitResponse
AngryStone::collision_badguy(BadGuy& badguy, const CollisionHit& )
{
if (state == ATTACKING) {
badguy.kill_fall();
return FORCE_MOVE;
}
return FORCE_MOVE;
}
示例13: hit
HitResponse
Block::collision(GameObject& other, const CollisionHit& )
{
Player* player = dynamic_cast<Player*> (&other);
if(player) {
if(player->get_bbox().get_top() > get_bbox().get_bottom() - SHIFT_DELTA) {
hit(*player);
}
}
// only interact with other objects if...
// 1) we are bouncing
// 2) the object is not portable (either never or not currently)
// 3) the object is being hit from below (baguys don't get killed for activating boxes)
Portable* portable = dynamic_cast<Portable*> (&other);
MovingObject* moving_object = dynamic_cast<MovingObject*> (&other);
bool is_portable = ((portable != 0) && portable->is_portable());
bool hit_mo_from_below = ((moving_object == 0) || (moving_object->get_bbox().get_bottom() < (get_bbox().get_top() + SHIFT_DELTA)));
if(bouncing && !is_portable && hit_mo_from_below) {
// Badguys get killed
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
badguy->kill_fall();
}
// Coins get collected
Coin* coin = dynamic_cast<Coin*> (&other);
if(coin) {
coin->collect();
}
//Eggs get jumped
GrowUp* growup = dynamic_cast<GrowUp*> (&other);
if(growup) {
growup->do_jump();
}
}
return FORCE_MOVE;
}
示例14: collision
HitResponse
BonusBlock::collision(GameObject& other, const CollisionHit& hit){
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
// hit contains no information for collisions with blocks.
// Badguy's bottom has to be below the top of the bonusblock
// +7 is required to slide over one tile gaps.
if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > get_bbox().get_top() + 7.0) ){
try_open();
}
}
Portable* portable = dynamic_cast<Portable*> (&other);
if(portable) {
MovingObject* moving = dynamic_cast<MovingObject*> (&other);
if(moving->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) {
try_open();
}
}
return Block::collision(other, hit);
}
示例15:
HitResponse
MoleRock::collision_badguy(BadGuy& badguy, const CollisionHit& )
{
// ignore collisions with parent
if (&badguy == parent) {
return FORCE_MOVE;
}
SoundManager::current()->play("sounds/stomp.wav", get_pos());
remove_me();
badguy.kill_fall();
return ABORT_MOVE;
}