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


C++ Monster::_方法代码示例

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


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

示例1: Room_attack

int Room_attack(void *self, int damage) {
  Room *room = self;
  Monster *monster = room->bad_guy;

  if(monster) {
    monster->_(attack)(monster, damage);
    return 1;
  } else {
    printf("You flail in the air at nothing. Idiot.\n");
    return 0;
  }
}
开发者ID:bluurn,项目名称:learn-c-the-hard-way,代码行数:12,代码来源:ex19.c

示例2: Room_attack

int Room_attack(void *self, int damage)
{
    Room *room = self;
    Monster *monster = room->bad_guy;
    
    if(monster) {
        monster->_(attack)(monster, damage);
        return 1;
    } else {
        printf("You run in screaming for no reason. Good job.\n");
        return 0;
    }
}
开发者ID:aewens,项目名称:learnc,代码行数:13,代码来源:fourteen.c

示例3: Monster_attack

int Monster_attack(void *self, int damage){
	Monster* monster = self;
	printf("You attack %s!\n", monster->_(description));
	monster->hit_points -=damage;

	if(monster->hit_points > 0){
		printf("It is still alive.\n");
		return 0;
	}else{
		printf("It is dead!\n");
		return 1;
	}
}
开发者ID:jadan,项目名称:LCTHW,代码行数:13,代码来源:ex19.c

示例4: Room_attack

int Room_attack(void *self, int damage){
	assert(self != NULL);

	Room *room = self;
	Monster *monster = room->bad_guy;

	if(monster){
		monster->_(attack)(monster, damage);
		return 1;
	} else {
		assert(! (printf("You flail in the air at nothing.\n") < 0));
		return 0;
	}
}
开发者ID:flsafe,项目名称:learn-c-the-hard-way,代码行数:14,代码来源:game_core.c

示例5: Room_attack

bool Room_attack(void *self, int damage) {
	assert(self != NULL);
	assert(damage >= 0);

	Room *room = self;
	Monster *monster = room->bad_guy;

	if (monster) {
		monster->_(attack)(monster, damage);
		return true;
	} else {
		printf("You flail in the air at nothing.\n");
		return false;
	}
}
开发者ID:wolverian,项目名称:lcthw,代码行数:15,代码来源:game.c

示例6: Monster_attack

int Monster_attack(void *self, int damage) {
    Monster *monster = self;

    // obj->_(func) == obj->proto.func
    printf("You attack %s!\n", monster->_(description));

    monster->hit_points -= damage;

    if (monster->hit_points > 0) {
        puts("It is still alive.");
        return 0;
    }
    else {
        puts("It is dead.");
        return 1;
    }
}
开发者ID:edek437,项目名称:LCTHW-Exercises,代码行数:17,代码来源:ex19.c

示例7: Monster_attack

int Monster_attack(void *self, int damage)
{
	assert(damage > 0);
	Monster *monster = self;
	
	printf("You attack %s! You inflict %d damage!\n", monster->_(description), damage);

	monster->hit_points -= damage;

	if(monster->hit_points > 0) {
		printf("It is still alive, it has %d hp left.\n", monster->hit_points);
		return 0;
	} else {
		printf("It is dead!\n");
		return 1;
	}
}
开发者ID:osynetskyi,项目名称:hardc,代码行数:17,代码来源:ex19.c

示例8: Room_attack

/*
 * Asserts:
 *     'damage' is not null.
 *     'damage' is not negative.
 */
int Room_attack(void *self, int damage)
{
    Room *room = self;
    Monster *monster = room->bad_guy;

    // Error Catching
    assert(damage != NULL);
    assert(damage >= 0);

    if(monster) {
        monster->_(attack)(monster, damage);
        return 1;
    } else {
        printf("You flail in the air at nothing. Idiot.\n");
        return 0;
    }
}
开发者ID:kylegalloway,项目名称:LCTHW,代码行数:22,代码来源:ex19.c

示例9: Monster_attack

bool Monster_attack(void *self, int damage) {
	assert(self != NULL);
	assert(damage >= 0);

	Monster *monster = self;

	printf("You attack %s!\n", monster->_(description));

	monster->hit_points -= damage;

	if (monster->hit_points > 0) {
		printf("It is still alive.\n");
		return false;
	} else {
		printf("It is dead!\n");
		return true;
	}
}
开发者ID:wolverian,项目名称:lcthw,代码行数:18,代码来源:game.c

示例10: Monster_attack

int Monster_attack(void *self, int damage)
{
	assert(self != NULL);

	Monster *monster = self;

	assert(! (printf("You attack %s!\n", monster->_(description)) < 0));

	monster->hit_points -= damage;

	if(monster->hit_points > 0){
		assert(! (printf("It is still alive.\n") < 0));
		return 0;
	} else {
		assert(! (printf("It is dead!\n") < 0));
		return 1;
	}
}
开发者ID:flsafe,项目名称:learn-c-the-hard-way,代码行数:18,代码来源:game_core.c

示例11: Room_attack

int Room_attack(void *self, int damage)
{
	Room *room = self;
	Monster *monster = room->bad_guy;

	if(monster) {
		// monster->proto.attack which is a 
		// function pointer to Monster_attack
		// (or Object_attack if not overriden)
		// which we call with monster and damage
		// as args.
		monster->_(attack) (monster, damage);
		return 1;
	} else {
		printf("You flail in the air at nothin. Idiot.\n");
		return 0;
	}
}
开发者ID:toonketels,项目名称:Learncthehardway,代码行数:18,代码来源:ex19.c

示例12: Monster_attack

int Monster_attack(void *self, int damage)
{
    Monster *monster = self;

    printf("You attack %s for %dhp of damage\n", monster->_(description), damage);

    monster->hit_points -= damage;

    if(monster->hit_points > 0) {
        printf("It is still alive and has %dhp remaining\n.",
                monster->hit_points);
        return 0;
    } else {
        printf("It is dead! it drops %d gold coins\n",
                monster->loot);
        return 1;
    }
}
开发者ID:paulosborne,项目名称:learning-c,代码行数:18,代码来源:ex19.c

示例13: Monster_attack

int Monster_attack(void *self, int damage)
{
	// Store a pointer to our object on the stack
	Monster *monster = self;

	// monster->_(description) macros into
	// monster->proto.description
	printf("You attack %s!\n", monster->_(description));

	monster->hit_points -= damage;

	if(monster->hit_points > 0) {
		printf("It is still alive.\n");
		return 0;
	} else {
		printf("It is dead!\n");
		return 1;
	}
}
开发者ID:toonketels,项目名称:Learncthehardway,代码行数:19,代码来源:ex19.c


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