Example #1
0
/**
* Move all enemies in the dungeon one space
*
* @param dungeon A pointer to the dungeon
* @param moveNum The number of moves the player has made
*
* @return RESULT_DIE if the player has died in the game
*         else 0
*/
int moveEnemies(Dungeon* dungeon, unsigned int moveNum) {
    int result = 0;

    for(Room* room=dungeon->start; room!=NULL; room=room->next) {
        for(int i=0; i<ROOM_HEIGHT; i++) {
            for(int j=0; j<ROOM_WIDTH; j++) {

                switch(room->contents[i][j]->id) {
                case BAT_NUM:
                    if((result = moveBat(dungeon, room->contents[i][j], moveNum))) {
                        sendKillMessage(BAT_KILL_MSG);
                        return result;
                    }
                    break;
                case ZOMBIE_NUM:
                    if((result = moveZombie(dungeon, room->contents[i][j], moveNum))) {
                        sendKillMessage(ZOMBIE_KILL_MSG);
                        return result;
                    }
                    break;
                default:
                    continue;
                }

            }
        }
    }

    return 0;
}
Example #2
0
void endTurn(){
	unsigned int i, j;
	for(i = 0; i < GRID_WIDTH; i++){
		for(j=0; j<GRID_HEIGHT;j++){
			if(grid[i][j] != NULL){
				if(grid[i][j]->type == ET_ZOMBIE){
					moveZombie(grid[i][j]);

				}
				grid[i][j]->remainingPoints = MAX_ACTION_POINTS[grid[i][j]->type];
			}
		}
	}
	unsigned int spawns = (score * .5);
	for(i = 0; i < 1+spawns ; i++){
		addNewZombie();
	}
	if(rand()%100 > 90){
		addNewSurvivor();
	}
	if(NumSurvivors == 0) {
		CurState = GAME_OVER;
	}
}