예제 #1
0
파일: bomb.c 프로젝트: RainbowLyte/ProjetC
void bomb_event(struct game* game, struct map* map, struct bomb* bomb, int x, int y) {
	struct player** players = game_get_players(game);
	struct player* player = NULL;
	struct bomb* sbomb = NULL;

	for(int i = 0; i < game_get_nb_player(game); i++) {
		player = players[i];
		if((x == player_get_x(player) && y == player_get_y(player)))
			player_hit(player, 3*DEFAULT_GAME_FPS);
	}

	int cellType = map_get_cell_type(map, x, y);
	switch(cellType & 15){
	case CELL_BONUS : // Case
		map_set_cell_type(map, x, y, CELL_EMPTY);
		break;
	case CELL_MONSTER : // Monster
		map_set_monsters( map, monster_hit(map_get_monsters(map), x, y, game) );
		break;
	case CELL_CASE : // Case
		if(bomb->anim >= DEFAULT_GAME_FPS)
			map_case_destroyed(game, map, x, y);
		break;
	case CELL_BOMB : // Bomb
		if((sbomb = search_bomb(map, x, y, 0)) != NULL)
				sbomb->anim = 4 * DEFAULT_GAME_FPS;
		break;
	default: // Everything else
		break;
	}
}
예제 #2
0
파일: test.c 프로젝트: ssyp-ru/ssyp16-ws04
void test_cycle() {
	monster_descr * rat_test = malloc(sizeof(monster_descr));
	rat_test->pic = '$';
	rat_test->name = "Rat";
	rat_test->max_hp = 10;
	rat_test->dodge = 20;
	rat_test->max_roll = 100;
	rat_test->max_dmg = 10;
	rat_test->min_dmg = 1;
	
	//TEST//fix
	player_descr * player = malloc(sizeof(player_descr));
	player->max_hp = 20;
	player->hp = 20;		
	player->dodge = 20;
	player->max_roll = 100;
	player->max_dmg = 20;
	player->min_dmg = 5;	

	monster * rat1;
	rat1 = make_monster(rat_test);
		
	player_hit(player, rat1);
	monster_hit(rat1, player);
	// TODO: add test
}