CPHSynchronize* CCharacterPhysicsSupport::PHGetSyncItem (u16 item) { if(movement()->CharacterExist()) return movement()->GetSyncItem(); else return m_EntityAlife.CPhysicsShellHolder::PHGetSyncItem(item); }
void CALifeMonsterBrain::process_task () { CALifeSmartTerrainTask *task = smart_terrain().task(&object()); THROW3 (task,"smart terrain returned nil task, while npc is registered in it",smart_terrain().name_replace()); movement().path_type (MovementManager::ePathTypeGamePath); movement().detail().target (*task); }
void CCharacterPhysicsSupport::set_movement_position( const Fvector &pos) { VERIFY( movement() ); CollisionCorrectObjPos( pos, true ); movement()->SetPosition( m_EntityAlife.Position() ); }
void CAI_Rat::set_rew_cur_position() { Fvector tTemp; tTemp.setHP(-movement().m_body.current.yaw,-movement().m_body.current.pitch); tTemp.normalize_safe(); tTemp.mul(m_fUnderFireDistance); m_tSpawnPosition.add(Position(),tTemp); }
void CAI_Rat::SelectAnimation(const Fvector& /**_view/**/, const Fvector& /**_move/**/, float /**speed/**/) { IKinematicsAnimated *tpVisualObject = smart_cast<IKinematicsAnimated*>(Visual()); MotionID tpGlobalAnimation; if (!g_Alive()) { for (int i=0 ;i<2; ++i) { if (m_tRatAnimations.tNormal.tGlobal.tpaDeath[i] == m_tpCurrentGlobalAnimation) { tpGlobalAnimation = m_tpCurrentGlobalAnimation; break; } } if (!tpGlobalAnimation) { if (m_tpCurrentGlobalAnimation == m_tRatAnimations.tNormal.tGlobal.tpaIdle[1]) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaDeath[0]; else tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaDeath[::Random.randI(0,2)]; } } else { if (m_bFiring) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaAttack[2]; else if (angle_difference(movement().m_body.target.yaw,movement().m_body.current.yaw) <= MIN_TURN_ANGLE) if (m_fSpeed < 0.2f) { if (m_bStanding) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[1]; else tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0]; } else if (_abs(m_fSpeed - m_fAttackSpeed) < EPS_L) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tRunAttack; else if (_abs(m_fSpeed - m_fMaxSpeed) < EPS_L) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tRun.fwd; else tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tWalk.fwd; else { if (left_angle(-movement().m_body.target.yaw,-movement().m_body.current.yaw)) // tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0]; tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpTurnLeft; else // tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0]; tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpTurnRight; } } if (tpGlobalAnimation != m_tpCurrentGlobalAnimation) m_tpCurrentGlobalBlend = tpVisualObject->PlayCycle(m_tpCurrentGlobalAnimation = tpGlobalAnimation); #ifdef DEBUG if (psAI_Flags.is(aiAnimation)) { IKinematicsAnimated *skeleton_animated = smart_cast<IKinematicsAnimated*>(Visual()); Msg ("%6d %s animation : %s (%f,%f)",Device.dwTimeGlobal,"Global",skeleton_animated->LL_MotionDefName_dbg(m_tpCurrentGlobalAnimation),movement().m_body.current.yaw,movement().m_body.target.yaw); } #endif }
void CAI_Rat::init_state_under_fire() { if (!switch_if_enemy()&&get_if_dw_time()&&m_tLastSound.dwTime >= m_dwLastUpdateTime) { Fvector tTemp; tTemp.setHP(-movement().m_body.current.yaw,-movement().m_body.current.pitch); tTemp.normalize_safe(); tTemp.mul(m_fUnderFireDistance); m_tSpawnPosition.add(Position(),tTemp); } m_tGoalDir = m_tSpawnPosition; }
void CCharacterPhysicsSupport::in_NetSpawn( CSE_Abstract* e ) { m_sv_hit = SHit(); if( m_EntityAlife.use_simplified_visual ( ) ) { m_flags.set( fl_death_anim_on, TRUE ); IKinematics* ka = smart_cast<IKinematics*>( m_EntityAlife.Visual( ) ); VERIFY( ka ); ka->CalculateBones_Invalidate( ); ka->CalculateBones( TRUE ); CollisionCorrectObjPos( m_EntityAlife.Position( ) ); m_pPhysicsShell = P_build_Shell( &m_EntityAlife, false ); ka->CalculateBones_Invalidate( ); ka->CalculateBones( TRUE ); return; } CPHDestroyable::Init();//this zerows colbacks !!; IRenderVisual *pVisual = m_EntityAlife.Visual(); IKinematicsAnimated*ka= smart_cast<IKinematicsAnimated*>( pVisual ); IKinematics*pK= smart_cast<IKinematics*>( pVisual ); VERIFY( &e->spawn_ini() ); m_death_anims.setup( ka, *e->s_name , pSettings ); if( !m_EntityAlife.g_Alive() ) { if( m_eType == etStalker ) ka->PlayCycle( "waunded_1_idle_0" ); else ka->PlayCycle( "death_init" ); }else if( !m_EntityAlife.animation_movement_controlled( ) ) ka->PlayCycle( "death_init" );///непонятно зачем это вообще надо запускать ///этот хак нужен, потому что некоторым монстрам ///анимация после спона, может быть вообще не назначена pK->CalculateBones_Invalidate( ); pK->CalculateBones( TRUE ); CPHSkeleton::Spawn( e ); movement( )->EnableCharacter(); movement( )->SetPosition(m_EntityAlife.Position( ) ); movement( )->SetVelocity ( 0, 0, 0 ); if(m_eType!=etActor) { m_flags.set( fl_specific_bonce_demager, TRUE ); m_BonceDamageFactor = 1.f; } if( Type( ) == etStalker ) { m_hit_animations.SetupHitMotions( *smart_cast<IKinematicsAnimated*>( m_EntityAlife.Visual( ) ) ); } anim_mov_state.init( ); anim_mov_state.active = m_EntityAlife.animation_movement_controlled( ); }
void CAI_Rat::init_free_recoil() { m_dwLostRecoilTime = Device.dwTimeGlobal; m_tRecoilPosition = m_tLastSound.tSavedPosition; if (!switch_if_enemy()&&!switch_if_time()) { Fvector tTemp; tTemp.setHP(-movement().m_body.current.yaw,-movement().m_body.current.pitch); tTemp.normalize_safe(); tTemp.mul(m_fUnderFireDistance); m_tSpawnPosition.add(Position(),tTemp); } }
/** ------------------------------------------------------------------------------------------------------------- * * @brief movement ** ------------------------------------------------------------------------------------------------------------- */ void CodeMotionPass::movement(PabloBlock * const block) { sink(block); for (Statement * stmt : *block) { if (isa<If>(stmt)) { movement(cast<If>(stmt)->getBody()); } else if (isa<While>(stmt)) { movement(cast<While>(stmt)->getBody()); // TODO: if we analyzed the probability of this loop being executed once, twice, or many times, we could // determine whether hoisting will helpful or harmful to the expected run time. hoistLoopInvariants(cast<While>(stmt)); } } reschedule(block); }
bool BounceColliderComponent::collision(ColliderComponent &c, float d, const CollisionData &data) { MMUNUSED(c); MMUNUSED(d); MMUNUSED(data); const Math::Vector2 &l_vel = movement()->velocity(); const float l_mag = l_vel.magnitude(); const Math::Vector2 l_normal = l_vel.normalized(l_mag); Math::Vector2 l_pvel = (l_normal * (2.f * l_normal.dot(l_vel * -1.f)) + l_vel); movement()->velocity() = l_pvel.normalize(l_pvel.magnitude()) * l_mag; return(true); }
void draw(roomGrid *room_grid, progress *puzzle, char *instructions_list[NUM_INSTRUCTIONS], Chicken *hen) { SDL_Surface *background, *sprite, *chicken; SDL_Texture *backtex, *spritetex, *chickentex; load_image(room_grid, &background, &backtex, "lab1sheet.png"); load_image(room_grid, &sprite, &spritetex, "prof2.png"); load_image(room_grid, &chicken, &chickentex, "chicken.png"); initialise_roomgrid_components(room_grid, puzzle); position_sprite(room_grid); Mix_PlayChannel(-1, room_grid -> mus, -1); while (room_grid -> gamerunning) { movement(room_grid, puzzle, instructions_list, hen); collision_detection(room_grid); SDL_RenderClear(room_grid -> renderer); draw_room(background, backtex, room_grid); /*RenderClear to wipe framebuffer, RenderCopy to compose final framebuffer, RenderPresent puts on screen*/ SDL_RenderCopy(room_grid -> renderer, spritetex, &room_grid -> rcObj, &room_grid -> rcSprite); SDL_RenderPresent(room_grid -> renderer); } // SDL_Delay(5000); SDL_DestroyTexture(backtex); SDL_DestroyTexture(spritetex); SDL_DestroyTexture(chickentex); SDL_DestroyRenderer(room_grid -> renderer); SDL_DestroyWindow(room_grid -> window); }
bool ChargeSystem::solve() { const double c_smallVelocitiesSq = 0.0001*0.0001; const int c_maxIters = 1000000; normalize(); int n = d_particles.size(); std::vector<PhasePoint> newPP( n ); int iter = 0; do { for( int i = 0; i < n; ++i) { PhasePoint& pp = d_particles[i]; PhasePoint& newpp = newPP[i]; newpp.d_p = pp.d_p + d_t * pp.d_v; makeUnit(newpp.d_p); newpp.d_v = pp.d_v + d_t * getForce(i); // unit mass newpp.d_v -= (newpp.d_p * newpp.d_v) * newpp.d_p; // dv * dp == 0 always } d_particles.swap(newPP); ++iter; } while( movement() > c_smallVelocitiesSq && iter < c_maxIters); return iter < c_maxIters; }
u16 CCharacterPhysicsSupport::PHGetSyncItemsNumber( ) { if(movement()->CharacterExist()) return 1; else return m_EntityAlife.CPhysicsShellHolder::PHGetSyncItemsNumber(); }
/** * \brief Check if the bottom of the "that" item was * lower than \a m_value, relative to the top of the "self" item. * \param info Informations on the collision. * \param self The first item in the collision. * \param that The other item in the collision. */ bool bear::universe::bottom_contact_is_lower::operator() ( const collision_info& info, physical_item& self, physical_item& that ) const { bear::universe::position_type origin( that.get_bottom_middle() ); claw::math::line_2d<bear::universe::coordinate_type> movement ( origin, info.other_previous_state().get_bottom_middle() - origin ); bear::universe::coordinate_type that_bottom; bear::universe::coordinate_type y_bound; switch ( info.get_collision_side() ) { case zone::middle_right_zone: that_bottom = movement.y_value( self.get_right() ); y_bound = m_line.y_value( self.get_width() ); break; case zone::middle_left_zone: that_bottom = movement.y_value( self.get_top_left().x ); y_bound = m_line.y_value( self.get_top_left().x ); break; case zone::middle_zone: that_bottom = info.other_previous_state().get_bottom(); y_bound = m_line.y_value ( info.other_previous_state().get_center_of_mass().x - self.get_top_left().x ); break; default: { CLAW_ASSERT( false, "This test is for left/middle/right collisions" ); } } return that_bottom - (int)self.get_top_left().y < y_bound; } // bottom_contact_is_lower::operator()()
void updatePackman(Packman &packman, float elapsedTime, Field &field) { const float step = PACKMAN_SPEED * elapsedTime; updatePackmanDirection(packman); sf::Vector2f movement(0.f, 0.f); switch (packman.direction) { case Direction::UP: movement.y -= step; break; case Direction::DOWN: movement.y += step; break; case Direction::LEFT: movement.x -= step; break; case Direction::RIGHT: movement.x += step; break; case Direction::NONE: break; } if (checkFieldWallsCollision(field, packman.shape.getGlobalBounds(), movement)) { // Останавливаем пакмана при столкновении packman.direction = Direction::NONE; } packman.eatenCookies += eatAllCookiesInBounds(field, packman.shape.getGlobalBounds()); packman.shape.move(movement); }
void FolderViewListView::dragMoveEvent(QDragMoveEvent* e) { if(movement() != Static) QListView::dragMoveEvent(e); else QAbstractItemView::dragMoveEvent(e); static_cast<FolderView*>(parent())->childDragMoveEvent(e); }
void EnemyLog::update(float deltaTime , Background *bg) { _aliveTimer += deltaTime; if(!_destroying && _aliveTimer > 5) { //_alive = false; _index = 0; _destroying = true; _animTimer.restart(); move(-31, -31); } if(_spawning){ updateSprite(true); return; } if(_destroying){ updateSprite(false); return; } setTexture(*_texture, true); if(getOrigin().x == 0){ setPosition(getPosition().x + getLocalBounds().width/2+32, getPosition().y + getLocalBounds().height/2+32); setOrigin( getLocalBounds().width/2, getLocalBounds().height/2); } movement(deltaTime, bg); }
void GameView::updateScreen(const EventManager& eventManager) { sf::Vector2f movement(0.f, 0.f); if(_moveUp) { movement.y =eventManager.getYPosition(); } if(_moveDown) { movement.y =eventManager.getYPosition(); } if(_moveLeft) { _playerID.setTexture(_playerTexture); _playerID.setRotation(0); movement.x =eventManager.getXPosition(); } if(_moveRight) { _playerID.setRotation(180); movement.x =eventManager.getXPosition(); } _playerID.move(movement); }
int main(void) { int done = 0; srand(time(NULL)); initXWindows(); init_opengl(); //declare game object Game game; game.n = 0; //declare a box shape //game.box.width = 100; //game.box.height = 10; //game.box.center.x = 120 + 5*65; //game.box.center.y = 500 - 5*60; //start animation while (!done) { while (XPending(dpy)) { XEvent e; XNextEvent(dpy, &e); check_mouse(&e, &game); done = check_keys(&e); } movement(&game); render(&game); bubbles(&game); glXSwapBuffers(dpy, win); } cleanupXWindows(); return 0; }
//Checks to see if there is an arc in the edge int getARC (Game g, path pathToEdge) { int arcCode = 0; char *path = pathToEdge; int xPtA = 0; int yPtA = 0; int zPtA = 0; int xPtB = 0; int yPtB = 0; int zPtB = 0; edge arc; //Edge to be checked arc.pointA = pathMovement (path); arc.pointB = movement (arc.pointA, BACK); xPtA = arc.pointA.x + 3; yPtA = arc.pointA.y + 3; zPtA = arc.pointA.z + 3; xPtB = arc.pointB.x + 3; yPtB = arc.pointB.y + 3; zPtB = arc.pointB.z + 3; arcCode = g->gameBoard.arc[xPtA][yPtA][zPtA][xPtB][yPtB][zPtB]; return arcCode; }
void pBack::MoveBack() { sf::Vector2f movement(0.f,0.f); movement.y +=speed; pSprite.move( movement * time.asSeconds() ); }
int main(void) { int done=0; srand(time(NULL)); initXWindows(); init_opengl(); //declare game object Game game; //start animation while(!done) { while(XPending(dpy)) { XEvent e; XNextEvent(dpy, &e); check_mouse(&e, &game); done = check_keys(&e, &game); } movement(&game); render(&game); glXSwapBuffers(dpy, win); } cleanupXWindows(); cleanup_fonts(); return 0; }
//Tests conditions for path, which needs 1 BPS and 1 BQN //Ensure paths are connected to other paths & are legal paths //Does not leave into the sea, and path is vacant int arcConditions (Game g, action a, int player) { int answer = TRUE; char *path = a.destination; edge arc; arc.pointA = pathMovement (path); arc.pointB = movement (arc.pointA, BACK); if ((getStudents (g, player, STUDENT_BPS) >= 1) && (getStudents (g, player, STUDENT_BQN) >= 1) && (a.destination[0] != BACK)) { //doesn't move back into the sea answer = TRUE; } else { answer = FALSE; } //check if they're inside the boundaries if (answer == TRUE && abs (arc.pointA.x) >= 3 && abs (arc.pointA.y) >= 3 && abs (arc.pointA.z) >= 3) { answer = FALSE; } //Checks to see that they are actual adjacent vertexes if (answer == TRUE && abs(arc.pointA.x+arc.pointA.y+arc.pointA.z) != 2 && (arc.pointA.x+arc.pointA.y+arc.pointA.z+arc.pointB.x+arc.pointB.y+arc.pointB.z != 0) && (getARC (g, a.destination) != VACANT_ARC)) { answer = FALSE; } return answer; }
void Stalfos::update(std::vector<std::shared_ptr<GameObject>>* worldMap) { if (isCollidingWithPlayer(worldMap)){ Player* temp = (Player*)findPlayer(worldMap).get(); temp->takeDamage(worldMap, this); } checkParalyzeStatus(); if (isCollidingWithBoomerang(worldMap)){ Sound::playSound(GameSound::EnemyHit); isParalyzed = true; ThrownBoomrang* boom = (ThrownBoomrang*)findBoomerang(worldMap).get(); if (!boom->isReturning) boom->isReturning = true; } if (pushbackStep == 0 && !isParalyzed){ movement(worldMap); tryToChangeDirection(); } else if(pushbackStep!=0 && !isParalyzed) pushbackUpdate(); for (int i = 0; i < 3; i++) walkingAnimation[i]->updateAnimationFrame(position); if (healthPoint <= 0) processDeath(worldMap); else checkInvincibility(); updateMasks(); }
int main(int argc, char **argv) { /** * The ros::init() function needs to see argc and argv so that it can perform * any ROS arguments and name remapping that were provided at the command line. For programmatic * remappings you can use a different version of init() which takes remappings * directly, but for most command-line programs, passing argc and argv is the easiest * way to do it. The third argument to init() is the name of the node. * * You must call one of the versions of ros::init() before using any other * part of the ROS system. */ ros::init(argc, argv, "movement_node"); /** * NodeHandle is the main access point to communications with the ROS system. * The first NodeHandle constructed will fully initialize this node, and the last * NodeHandle destructed will close down the node. */ ros::NodeHandle n; // create an instance of the subscriber class Movement movement(n); // initialize the class (for details see comments in class) movement.init(); // Do not use the ROS::Spin, but instead use own implementation movement.spin(); return 0; }
/** * Query if the auton will initiate an event. * This will call up the LUA autons initEvent function which will * either return a 'null' string or data to build an * external event. * @return EventQueue::eEvent pointer to an external event or * a null pointer in which case nothing happens. */ std::unique_ptr<EventQueue::eEvent> AgentLuaInterface::takeStep() { if(removed) return NULL; if(nofile) return NULL; lua_settop(L,0); try { lua_getglobal(L, "_TakeStep"); if(lua_pcall(L,0,0,0) !=LUA_OK) { Output::Inst()->kprintf("<b><font color=\"brown\">Lua error on takeStep. %s, %s</font></b></>", filename.c_str() ,lua_tostring(L,-1)); Output::RunSimulation.store(false); return NULL; } if(moving) { movement(); } getSyncData(); return NULL; } catch(std::exception &e) { Output::Inst()->kprintf("<b><font color=\"red\">Exception on takeStep. %s, %s</font></b></>", filename.c_str() ,e.what()); Output::RunSimulation.store(false); } return NULL; }
int main() { char userInput[100]; char *firstWord; char *secondWord; long numInput; int boundsCheck; myStruct * ptrName; ptrName = malloc(sizeof(myStruct)); initscr(); drawInterface(); ptrName->yPos = 13; //This is the center of the interface ptrName->xPos = 37; ptrName->angle = 0; ptrName->pd = 1; //Pen is down ptrName->tStatus = 1; //Turtle is not hidden mvaddch(ptrName->yPos,ptrName->xPos,'@'); do { mvwprintw(stdscr, 27, 47, "Message Board "); mvwprintw(stdscr, 27, 8, "Input? "); getstr(userInput); mvwprintw(stdscr, 30, 40,"You entered: %s",userInput); /*Splitting the user input*/ firstWord = strtok(userInput, " "); secondWord = strtok(NULL, " "); if (secondWord!=NULL) { numInput = atol(secondWord); //converting to integer } clearLine(27,8); boundsCheck = checkBounds(ptrName); //checking the bounds (DOES NOT WORK YET) if (boundsCheck == 1) { movement(firstWord, numInput, ptrName); } refresh(); }while (strcmp(userInput,"quit")!=0); refresh(); endwin(); free(ptrName); return 0; }
void CCharacterPhysicsSupport::UpdateCollisionActivatingDellay( ) { VERIFY( m_collision_activating_delay ); VERIFY( movement() ); m_collision_activating_delay->update(); if( !m_collision_activating_delay->active() ) xr_delete(m_collision_activating_delay); }
/* sec 0616 */ void synch_v (void) { if (cur_v != dvi_v) { movement(cur_v - dvi_v, down1); dvi_v = cur_v; } }
/* sec 0616 */ void synch_h (void) { if (cur_h != dvi_h) { movement(cur_h - dvi_h, right1); dvi_h = cur_h; } }