本文整理汇总了C++中posy函数的典型用法代码示例。如果您正苦于以下问题:C++ posy函数的具体用法?C++ posy怎么用?C++ posy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了posy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: has_flag
/* Random walking even when we've moved
* To simulate zombie stumbling and ineffective movement
* Note that this is sub-optimal; stumbling may INCREASE a zombie's speed.
* Most of the time (out in the open) this effect is insignificant compared to
* the negative effects, but in a hallway it's perfectly even
*/
void monster::stumble( bool moved )
{
// don't stumble every turn. every 3rd turn, or 8th when walking.
if( ( moved && !one_in( 8 ) ) || !one_in( 3 ) ) {
return;
}
std::vector<tripoint> valid_stumbles;
const bool avoid_water = has_flag( MF_NO_BREATHE ) && !has_flag( MF_SWIMS ) && !has_flag( MF_AQUATIC );
for( int i = -1; i <= 1; i++ ) {
for( int j = -1; j <= 1; j++ ) {
tripoint dest( posx() + i, posy() + j, posz() );
if( ( i || j ) && can_move_to( dest ) &&
//Stop zombies and other non-breathing monsters wandering INTO water
//(Unless they can swim/are aquatic)
//But let them wander OUT of water if they are there.
!( avoid_water &&
g->m.has_flag( "SWIMMABLE", dest ) &&
!g->m.has_flag( "SWIMMABLE", pos3() ) ) &&
g->critter_at( dest ) == nullptr ) {
valid_stumbles.push_back( dest );
}
}
}
if( g->m.has_zlevels() ) {
tripoint below( posx(), posy(), posz() - 1 );
tripoint above( posx(), posy(), posz() + 1 );
if( g->m.valid_move( pos(), below, false, true ) && can_move_to( below ) ) {
valid_stumbles.push_back( below );
}
// More restrictions for moving up
// It should happen during "shambling around", but not as actual stumbling
if( !moved && one_in( 5 ) && has_flag( MF_FLIES ) &&
g->m.valid_move( pos(), above, false, true ) && can_move_to( above ) ) {
valid_stumbles.push_back( above );
}
}
if( valid_stumbles.empty() ) { //nowhere to stumble?
return;
}
move_to( random_entry( valid_stumbles ), false );
// Here we have to fix our plans[] list,
// acquiring a new path to the previous target.
// target == either end of current plan, or the player.
int bresenham_slope, junk;
if( !plans.empty() ) {
if( g->m.sees( pos3(), plans.back(), -1, bresenham_slope, junk ) ) {
set_dest( plans.back(), bresenham_slope );
} else if( sees( g->u, bresenham_slope ) ) {
set_dest( g->u.pos(), bresenham_slope );
} else { //durr, i'm suddenly calm. what was i doing?
plans.clear();
}
}
}
开发者ID:MushroomWobbit,项目名称:Cataclysm-DDA,代码行数:65,代码来源:monmove.cpp
示例2: posx
/* Random walking even when we've moved
* To simulate zombie stumbling and ineffective movement
* Note that this is sub-optimal; stumbling may INCREASE a zombie's speed.
* Most of the time (out in the open) this effect is insignificant compared to
* the negative effects, but in a hallway it's perfectly even
*/
void monster::stumble(bool moved)
{
// don't stumble every turn. every 3rd turn, or 8th when walking.
if((moved && !one_in(8)) || !one_in(3))
{
return;
}
std::vector <point> valid_stumbles;
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
const int nx = posx() + i;
const int ny = posy() + j;
if ((i || j) && can_move_to(nx, ny) &&
/* Don't ever stumble into impassable terrain, even if we normally could
* smash it, as this is uncoordinated movement (and is forced). */
g->m.move_cost(nx, ny) != 0 &&
//Stop zombies and other non-breathing monsters wandering INTO water
//(Unless they can swim/are aquatic)
//But let them wander OUT of water if they are there.
!(has_flag(MF_NO_BREATHE) && !has_flag(MF_SWIMS) && !has_flag(MF_AQUATIC)
&& g->m.has_flag("SWIMMABLE", nx, ny)
&& !g->m.has_flag("SWIMMABLE", posx(), posy())) &&
(g->u.posx != nx || g->u.posy != ny) &&
(g->mon_at(nx, ny) == -1)) {
point tmp(nx, ny);
valid_stumbles.push_back(tmp);
}
}
}
if (valid_stumbles.size() == 0) //nowhere to stumble?
{
return;
}
int choice = rng(0, valid_stumbles.size() - 1);
int cx = valid_stumbles[choice].x;
int cy = valid_stumbles[choice].y;
moves -= calc_movecost(posx(), posy(), cx, cy);
setpos(cx, cy);
// Here we have to fix our plans[] list,
// acquiring a new path to the previous target.
// target == either end of current plan, or the player.
int tc;
if (plans.size() > 0) {
if (g->m.sees(posx(), posy(), plans.back().x, plans.back().y, -1, tc))
set_dest(plans.back().x, plans.back().y, tc);
else if (sees_player( tc ))
set_dest(g->u.posx, g->u.posy, tc);
else //durr, i'm suddenly calm. what was i doing?
plans.clear();
}
}
开发者ID:Oddzball,项目名称:Cataclysm-DDA,代码行数:61,代码来源:monmove.cpp
示例3: switch
int monster::trigger_sum(std::set<monster_trigger> *triggers) const
{
int ret = 0;
bool check_terrain = false, check_meat = false, check_fire = false;
for( const auto &trigger : *triggers ) {
switch( trigger ) {
case MTRIG_STALK:
if (anger > 0 && one_in(20)) {
ret++;
}
break;
case MTRIG_MEAT:
check_terrain = true;
check_meat = true;
break;
case MTRIG_FIRE:
check_terrain = true;
check_fire = true;
break;
default:
break; // The rest are handled when the impetus occurs
}
}
if (check_terrain) {
for (int x = posx() - 3; x <= posx() + 3; x++) {
for (int y = posy() - 3; y <= posy() + 3; y++) {
if (check_meat) {
auto items = g->m.i_at(x, y);
for( auto &item : items ) {
if( item.is_corpse() || item.type->id == "meat" ||
item.type->id == "meat_cooked" || item.type->id == "human_flesh" ) {
ret += 3;
check_meat = false;
}
}
}
if (check_fire) {
ret += ( 5 * g->m.get_field_strength( point(x, y), fd_fire) );
}
}
}
if (check_fire) {
if (g->u.has_amount("torch_lit", 1)) {
ret += 49;
}
}
}
return ret;
}
开发者ID:reverieAlice,项目名称:Cataclysm-DDA,代码行数:54,代码来源:monster.cpp
示例4: posx
/* Random walking even when we've moved
* To simulate zombie stumbling and ineffective movement
* Note that this is sub-optimal; stumbling may INCREASE a zombie's speed.
* Most of the time (out in the open) this effect is insignificant compared to
* the negative effects, but in a hallway it's perfectly even
*/
void monster::stumble(bool moved)
{
// don't stumble every turn. every 3rd turn, or 8th when walking.
if((moved && !one_in(8)) || !one_in(3))
{
return;
}
std::vector <point> valid_stumbles;
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
const int nx = posx() + i;
const int ny = posy() + j;
if ((i || j) && can_move_to(nx, ny) &&
//Stop zombies and other non-breathing monsters wandering INTO water
//(Unless they can swim/are aquatic)
//But let them wander OUT of water if they are there.
!(has_flag(MF_NO_BREATHE) && !has_flag(MF_SWIMS) && !has_flag(MF_AQUATIC)
&& g->m.has_flag("SWIMMABLE", nx, ny)
&& !g->m.has_flag("SWIMMABLE", posx(), posy())) &&
(g->u.posx() != nx || g->u.posy() != ny) &&
(g->mon_at(nx, ny) == -1) &&
(g->npc_at(nx, ny) == -1) ) {
point tmp(nx, ny);
valid_stumbles.push_back(tmp);
}
}
}
if (valid_stumbles.empty()) //nowhere to stumble?
{
return;
}
int choice = rng(0, valid_stumbles.size() - 1);
int cx = valid_stumbles[choice].x;
int cy = valid_stumbles[choice].y;
move_to( cx, cy, false );
// Here we have to fix our plans[] list,
// acquiring a new path to the previous target.
// target == either end of current plan, or the player.
int bresenham_slope;
if (!plans.empty()) {
if (g->m.sees( pos(), plans.back(), -1, bresenham_slope))
set_dest(plans.back().x, plans.back().y, bresenham_slope);
else if (sees( g->u, bresenham_slope ))
set_dest(g->u.posx(), g->u.posy(), bresenham_slope);
else //durr, i'm suddenly calm. what was i doing?
plans.clear();
}
}
开发者ID:fuchs87,项目名称:Cataclysm-DDA,代码行数:58,代码来源:monmove.cpp
示例5: next
point monster::scent_move()
{
std::vector<point> smoves;
int maxsmell = 10; // Squares with smell 0 are not eligible targets.
int smell_threshold = 200; // Squares at or above this level are ineligible.
if (has_flag(MF_KEENNOSE)) {
maxsmell = 1;
smell_threshold = 400;
}
int minsmell = 9999;
point pbuff, next(-1, -1);
unsigned int smell;
const bool fleeing = is_fleeing(g->u);
if( !fleeing && g->scent( posx(), posy() ) > smell_threshold ) {
return next;
}
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
const int nx = posx() + x;
const int ny = posy() + y;
smell = g->scent(nx, ny);
int mon = g->mon_at(nx, ny);
if ((mon == -1 || g->zombie(mon).friendly != 0 || has_flag(MF_ATTACKMON)) &&
(can_move_to(nx, ny) ||
(nx == g->u.posx && ny == g->u.posy) ||
(g->m.has_flag("BASHABLE", nx, ny) && has_flag(MF_BASHES)))) {
if ((!fleeing && smell > maxsmell ) ||
( fleeing && smell < minsmell ) ) {
smoves.clear();
pbuff.x = nx;
pbuff.y = ny;
smoves.push_back(pbuff);
maxsmell = smell;
minsmell = smell;
} else if ((!fleeing && smell == maxsmell ) ||
( fleeing && smell == minsmell ) ) {
pbuff.x = nx;
pbuff.y = ny;
smoves.push_back(pbuff);
}
}
}
}
if (smoves.size() > 0) {
int nextsq = rng(0, smoves.size() - 1);
next = smoves[nextsq];
}
return next;
}
开发者ID:Oddzball,项目名称:Cataclysm-DDA,代码行数:50,代码来源:monmove.cpp
示例6: GetMap
void Enemy::Process()
{
auto obj = GetMap()->GetNearest(pixel_x(), pixel_y());
if (obj != nullptr)
ProcessSpeed(obj->posx() * 32, obj->posy() * 32);
ProcessMove();
ProcessHealth();
}
开发者ID:kremius,项目名称:space-dworf-strategy,代码行数:8,代码来源:enemy.cpp
示例7: posy
int monster::turns_to_reach(int x, int y)
{
std::vector<point> path = g->m.route(posx(), posy(), x, y, has_flag(MF_BASHES));
if (path.size() == 0)
return 999;
double turns = 0.;
for (int i = 0; i < path.size(); i++) {
if (g->m.move_cost(path[i].x, path[i].y) == 0) // We have to bash through
turns += 5;
else if (i == 0)
turns += double(calc_movecost(posx(), posy(), path[i].x, path[i].y)) / speed;
else
turns += double(calc_movecost(path[i-1].x, path[i-1].y, path[i].x, path[i].y)) / speed;
}
return int(turns + .9); // Round up
}
开发者ID:Oddzball,项目名称:Cataclysm-DDA,代码行数:17,代码来源:monmove.cpp
示例8: has_flag
/**
* Stumble in a random direction, but with some caveats.
*/
void monster::stumble( )
{
// Only move every 3rd turn.
if( !one_in( 3 ) ) {
return;
}
std::vector<tripoint> valid_stumbles;
const bool avoid_water = has_flag( MF_NO_BREATHE ) &&
!has_flag( MF_SWIMS ) && !has_flag( MF_AQUATIC );
for( int i = -1; i <= 1; i++ ) {
for( int j = -1; j <= 1; j++ ) {
tripoint dest( posx() + i, posy() + j, posz() );
if( ( i || j ) && can_move_to( dest ) &&
//Stop zombies and other non-breathing monsters wandering INTO water
//(Unless they can swim/are aquatic)
//But let them wander OUT of water if they are there.
!( avoid_water &&
g->m.has_flag( TFLAG_SWIMMABLE, dest ) &&
!g->m.has_flag( TFLAG_SWIMMABLE, pos3() ) ) &&
( g->critter_at( dest, is_hallucination() ) == nullptr ) ) {
valid_stumbles.push_back( dest );
}
}
}
if( g->m.has_zlevels() ) {
tripoint below( posx(), posy(), posz() - 1 );
tripoint above( posx(), posy(), posz() + 1 );
if( g->m.valid_move( pos(), below, false, true ) && can_move_to( below ) ) {
valid_stumbles.push_back( below );
}
// More restrictions for moving up
if( one_in( 5 ) && has_flag( MF_FLIES ) &&
g->m.valid_move( pos(), above, false, true ) && can_move_to( above ) ) {
valid_stumbles.push_back( above );
}
}
if( valid_stumbles.empty() ) { //nowhere to stumble?
return;
}
move_to( random_entry( valid_stumbles ), false );
}
开发者ID:CliffsDover,项目名称:Cataclysm-DDA,代码行数:48,代码来源:monmove.cpp
示例9: posy
int monster::turns_to_reach(int x, int y)
{
std::vector<point> path = g->m.route(posx(), posy(), x, y, false);
if (path.empty())
return 999;
double turns = 0.;
for (size_t i = 0; i < path.size(); i++) {
if (g->m.move_cost(path[i].x, path[i].y) == 0) {
// We have to bash through
turns += 5;
} else if (i == 0) {
turns += double(calc_movecost(posx(), posy(), path[i].x, path[i].y)) / get_speed();
} else {
turns += double(calc_movecost(path[i-1].x, path[i-1].y, path[i].x, path[i].y)) / get_speed();
}
}
return int(turns + .9); // Round up
}
开发者ID:fuchs87,项目名称:Cataclysm-DDA,代码行数:19,代码来源:monmove.cpp
示例10: posx
void monster::drop_items_on_death()
{
if(is_hallucination()) {
return;
}
if (type->death_drops.empty()) {
return;
}
g->m.put_items_from_loc( type->death_drops, posx(), posy(), calendar::turn );
}
开发者ID:reverieAlice,项目名称:Cataclysm-DDA,代码行数:10,代码来源:monster.cpp
示例11: setpos
bool monster::setpos(const int x, const int y, const bool level_change)
{
if (!level_change && x == posx() && y == posy()) {
return true;
}
bool ret = level_change ? true : g->update_zombie_pos(*this, x, y);
position.x = x;
position.y = y;
return ret;
}
开发者ID:reverieAlice,项目名称:Cataclysm-DDA,代码行数:11,代码来源:monster.cpp
示例12: getmaxx
/*
* Drawing-related functions
*/
void Creature::draw(WINDOW *w, int player_x, int player_y, bool inverted) const
{
int draw_x = getmaxx(w) / 2 + posx() - player_x;
int draw_y = getmaxy(w) / 2 + posy() - player_y;
if(inverted) {
mvwputch_inv(w, draw_y, draw_x, basic_symbol_color(), symbol());
} else if(is_symbol_highlighted()) {
mvwputch_hi(w, draw_y, draw_x, basic_symbol_color(), symbol());
} else {
mvwputch(w, draw_y, draw_x, symbol_color(), symbol() );
}
}
开发者ID:grimoire,项目名称:Cataclysm-DDA,代码行数:15,代码来源:creature.cpp
示例13: attitude
/* will_reach() is used for determining whether we'll get to stairs (and
* potentially other locations of interest). It is generally permissive.
* TODO: Pathfinding;
Make sure that non-smashing monsters won't "teleport" through windows
Injure monsters if they're gonna be walking through pits or whatevs
*/
bool monster::will_reach(int x, int y)
{
monster_attitude att = attitude(&(g->u));
if (att != MATT_FOLLOW && att != MATT_ATTACK && att != MATT_FRIEND)
return false;
if (has_flag(MF_DIGS))
return false;
if (has_flag(MF_IMMOBILE) && (posx() != x || posy() != y))
return false;
std::vector<point> path = g->m.route(posx(), posy(), x, y, has_flag(MF_BASHES));
if (path.size() == 0)
return false;
if (has_flag(MF_SMELLS) && g->scent(posx(), posy()) > 0 &&
g->scent(x, y) > g->scent(posx(), posy()))
return true;
if (can_hear() && wandf > 0 && rl_dist(wandx, wandy, x, y) <= 2 &&
rl_dist(posx(), posy(), wandx, wandy) <= wandf)
return true;
int t;
if (can_see() && g->m.sees(posx(), posy(), x, y, g->light_level(), t))
return true;
return false;
}
开发者ID:Oddzball,项目名称:Cataclysm-DDA,代码行数:36,代码来源:monmove.cpp
示例14: getmaxx
void monster::draw(WINDOW *w, int plx, int ply, bool inv)
{
int x = getmaxx(w)/2 + posx() - plx;
int y = getmaxy(w)/2 + posy() - ply;
nc_color color = type->color;
if (friendly != 0 && !inv)
mvwputch_hi(w, y, x, color, type->sym);
else if (inv)
mvwputch_inv(w, y, x, color, type->sym);
else {
color = color_with_effects();
mvwputch(w, y, x, color, type->sym);
}
}
开发者ID:Doffeh,项目名称:Cataclysm-DDA,代码行数:14,代码来源:monster.cpp
示例15: attitude
/* will_reach() is used for determining whether we'll get to stairs (and
* potentially other locations of interest). It is generally permissive.
* TODO: Pathfinding;
Make sure that non-smashing monsters won't "teleport" through windows
Injure monsters if they're gonna be walking through pits or whatevs
*/
bool monster::will_reach( int x, int y )
{
monster_attitude att = attitude( &( g->u ) );
if( att != MATT_FOLLOW && att != MATT_ATTACK && att != MATT_FRIEND && att != MATT_ZLAVE ) {
return false;
}
if( has_flag( MF_DIGS ) || has_flag( MF_AQUATIC ) ) {
return false;
}
if( has_flag( MF_IMMOBILE ) && ( posx() != x || posy() != y ) ) {
return false;
}
std::vector<tripoint> path = g->m.route( pos(), tripoint(x, y, posz()), 0, 100 );
if( path.empty() ) {
return false;
}
if( has_flag( MF_SMELLS ) && g->scent( pos3() ) > 0 &&
g->scent( { x, y, posz() } ) > g->scent( pos3() ) ) {
return true;
}
if( can_hear() && wandf > 0 && rl_dist( wander_pos.x, wander_pos.y, x, y ) <= 2 &&
rl_dist( posx(), posy(), wander_pos.x, wander_pos.y ) <= wandf ) {
return true;
}
int t;
if( can_see() && g->m.sees( posx(), posy(), x, y, g->light_level(), t ) ) {
return true;
}
return false;
}
开发者ID:MushroomWobbit,项目名称:Cataclysm-DDA,代码行数:43,代码来源:monmove.cpp
示例16: attitude
/* will_reach() is used for determining whether we'll get to stairs (and
* potentially other locations of interest). It is generally permissive.
* TODO: Pathfinding;
Make sure that non-smashing monsters won't "teleport" through windows
Injure monsters if they're gonna be walking through pits or whatevs
*/
bool monster::will_reach( int x, int y )
{
monster_attitude att = attitude( &( g->u ) );
if( att != MATT_FOLLOW && att != MATT_ATTACK && att != MATT_FRIEND && att != MATT_ZLAVE ) {
return false;
}
if( has_flag( MF_DIGS ) || has_flag( MF_AQUATIC ) ) {
return false;
}
if( has_flag( MF_IMMOBILE ) && ( posx() != x || posy() != y ) ) {
return false;
}
auto path = g->m.route( pos(), tripoint( x, y, posz() ), get_pathfinding_settings() );
if( path.empty() ) {
return false;
}
if( has_flag( MF_SMELLS ) && g->scent.get( pos() ) > 0 &&
g->scent.get( { x, y, posz() } ) > g->scent.get( pos() ) ) {
return true;
}
if( can_hear() && wandf > 0 && rl_dist( wander_pos.x, wander_pos.y, x, y ) <= 2 &&
rl_dist( posx(), posy(), wander_pos.x, wander_pos.y ) <= wandf ) {
return true;
}
if( can_see() && sees( tripoint( x, y, posz() ) ) ) {
return true;
}
return false;
}
开发者ID:AlecWhite,项目名称:Cataclysm-DDA,代码行数:42,代码来源:monmove.cpp
示例17: getmaxx
void Creature::draw( const catacurses::window &w, const tripoint &p, bool inverted ) const
{
if (is_draw_tiles_mode()) {
return;
}
int draw_x = getmaxx(w) / 2 + posx() - p.x;
int draw_y = getmaxy(w) / 2 + posy() - p.y;
if(inverted) {
mvwputch_inv(w, draw_y, draw_x, basic_symbol_color(), symbol());
} else if(is_symbol_highlighted()) {
mvwputch_hi(w, draw_y, draw_x, basic_symbol_color(), symbol());
} else {
mvwputch(w, draw_y, draw_x, symbol_color(), symbol() );
}
}
开发者ID:ProfoundDarkness,项目名称:Cataclysm-DDA,代码行数:16,代码来源:creature.cpp
示例18: posy
bool Character::i_add_or_drop(item& it, int qty) {
bool retval = true;
bool drop = false;
inv.assign_empty_invlet(it);
for (int i = 0; i < qty; ++i) {
if (!drop && (!can_pickWeight(it.weight(), !OPTIONS["DANGEROUS_PICKUPS"])
|| !can_pickVolume(it.volume()))) {
drop = true;
}
if (drop) {
retval &= g->m.add_item_or_charges(posx(), posy(), it);
} else {
i_add(it);
}
}
return retval;
}
开发者ID:alanpost,项目名称:Cataclysm-DDA,代码行数:17,代码来源:character.cpp
示例19: print_counter
void print_counter()
{
UBYTE cnt;
/* Ensure mutual exclusion (not really necessary in this example)... */
disable_interrupts();
cnt = tim_cnt;
enable_interrupts();
printf(" TIM %u", cnt);
gotoxy(9, posy());
/* Ensure mutual exclusion (not really necessary in this example)... */
disable_interrupts();
cnt = vbl_cnt;
enable_interrupts();
printf("- VBL %u\n", cnt);
}
开发者ID:UraKn0x,项目名称:gbdk,代码行数:19,代码来源:irq.c
示例20: get
/** Create or adjust "pos" parameter for a component
* Assumed that name either equals "x", "y" or "z" otherwise this
* method will not add or modify "pos" parameter
* @param comp :: Component
* @param name :: name of the parameter
* @param value :: value
* @param pDescription :: a pointer (may be NULL) to a string, containing
* parameter's
* description. If provided, the contents of the string is copied to the
* parameters
* memory
*/
void ParameterMap::addPositionCoordinate(
const IComponent *comp, const std::string &name, const double value,
const std::string *const pDescription) {
Parameter_sptr param = get(comp, pos());
V3D position;
if (param) {
// so "pos" already defined
position = param->value<V3D>();
} else {
// so "pos" is not defined - therefore get position from component
position = comp->getPos();
}
// adjust position
if (name.compare(posx()) == 0)
position.setX(value);
else if (name.compare(posy()) == 0)
position.setY(value);
else if (name.compare(posz()) == 0)
position.setZ(value);
else {
g_log.warning() << "addPositionCoordinate() called with unrecognized "
"coordinate symbol: " << name;
// set description if one is provided
if (pDescription) {
param->setDescription(*pDescription);
}
return;
}
// clear the position cache
clearPositionSensitiveCaches();
// finally add or update "pos" parameter
addV3D(comp, pos(), position, pDescription);
}
开发者ID:spaceyatom,项目名称:mantid,代码行数:48,代码来源:ParameterMap.cpp
注:本文中的posy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论