void Init() { //Serial.println("initial"); movement[0].push_back(Movement(15, 1.0f, 0)); movement[1].push_back(Movement(60, 1.0f, 0)); movement[2].push_back(Movement(90, 1.0f, 0)); }
Stepper_Control::Stepper_Control(Stepper* top_stepper, Stepper* bottom_stepper) { this->top = top_stepper; this->bottom = bottom_stepper; this->idle_move = Movement(); this->move = &idle_move; }
//update the game void GameWindow::Update() { //if in game if(m_bInGame){ //Spawn Enemies Spawn(); //check for damage Damage(); //run enemy ai for(int i = 0; i < 7; i++){ if(m_eAllEnemies[i].m_bOnScreen){ m_eAllEnemies[i].AI(m_pPlatformList, m_PlatformCount, m_wPlayer); } } //move all entities Movement(); //check players displayed image m_wPlayer.SwapImage(); m_wPlayer.Tick(); //apply gravity to all entities Gravity(); //reset player velocity m_wPlayer.m_xVelocity = 0; } //handle key input HandleInput(); //draw all images and sprites Draw(); //check if game over EndGame(); }
void Mob::updatemovement() { MoveMobPacket( oid, 1, 0, 0, 0, 0, 0, 0, getposition(), Movement(phobj, valueof(stance, flip)) ).dispatch(); }
void Enemy::Update() { Movement(); Collision(); if (m_timer > m_duration) Destroy(); m_timer += Time::DeltaTime(); }
void Player::FixedUpdate(const float aDelta) { if( myState == PLAYERSTATE_PLAYING ) { Movement(aDelta); } else if( myState == PLAYERSTATE_INVENTORY ) { } }
void player::Update( float deltaTime ) { physicsentity::Update( deltaTime ); m_Triangle.setPosition( position ); Movement( deltaTime ); m_HitBox.setPosition( position ); position = m_Triangle.getPosition(); m_Triangle.rotate( deltaTime * 100 ); }
Point2F SwipeGestureRecognizer::MovementOnDirection() const { Point2F movement = Movement(); if (!mDirection.HasHorizontal()) { movement.X = 0.f; } if (!mDirection.HasVertical()) { movement.Y = 0.f; } return movement; }
void cPlayer::ApplyFoodExhaustionFromMovement() { if (IsGameModeCreative()) { return; } // If we have just teleported, apply no exhaustion if (m_bIsTeleporting) { m_bIsTeleporting = false; return; } // If riding anything, apply no food exhaustion if (m_AttachedTo != NULL) { return; } // Process exhaustion every two ticks as that is how frequently m_LastPos is updated // Otherwise, we apply exhaustion for a 'movement' every tick, one of which is an already processed value if (GetWorld()->GetWorldAge() % 2 != 0) { return; } // Calculate the distance travelled, update the last pos: Vector3d Movement(GetPosition() - m_LastPos); Movement.y = 0; // Only take XZ movement into account // Apply the exhaustion based on distance travelled: double BaseExhaustion = Movement.Length(); if (IsSprinting()) { // 0.1 pt per meter sprinted BaseExhaustion = BaseExhaustion * 0.1; } else if (IsSwimming()) { // 0.015 pt per meter swum BaseExhaustion = BaseExhaustion * 0.015; } else { // 0.01 pt per meter walked / sneaked BaseExhaustion = BaseExhaustion * 0.01; } m_FoodExhaustionLevel += BaseExhaustion; }
//----------------------------------------------------------------------------- // Exports mstudioanimdesc_t. //----------------------------------------------------------------------------- void export_movement(scope _studio) { class_<mstudiomovement_t, mstudiomovement_t *, boost::noncopyable> Movement("Movement"); // Properties... Movement.def_readwrite("end_frame", &mstudiomovement_t::endframe); Movement.def_readwrite("motion_flags", &mstudiomovement_t::motionflags); Movement.def_readwrite("velocity_start", &mstudiomovement_t::v0); Movement.def_readwrite("velocity_end", &mstudiomovement_t::v1); Movement.def_readwrite("angle", &mstudiomovement_t::angle); Movement.add_property("vector", make_getter(&mstudiomovement_t::vector, reference_existing_object_policy())); Movement.add_property("position", make_getter(&mstudiomovement_t::position, reference_existing_object_policy())); // Add memory tools... Movement ADD_MEM_TOOLS(mstudiomovement_t); }
list<Movement> Knight::generateMoves(GameStatus& currentStatus, int dirX, int dirY) { list<Movement> moves; int x = location.getX(); int y = location.getY(); int checkedX = x + dirX; int checkedY = y + dirY; if (currentStatus.canPlace(checkedX, checkedY, this->color)) { moves.push_back(Movement(location, Point(checkedX, checkedY))); if (currentStatus.isOccupied(checkedX, checkedY)) { moves.back().setCapturing(); } } return moves; }
int Search::seek(int lastPositionXY[2],int currentPositionXY[2]) { Movement move = Movement(myRobot); double range = mySonar->currentReadingPolar(-70, 70) - myRobot->getRobotRadius(); ArTime start; //using timeSet to start the counting the first time we enter Search if (timeSet == 0) timeSet = start.getSec(); //if searching for more thatn 1o secs switch to goTo if(start.getSec() - timeSet > 10) { timeSet = 0; return 3; } //if we have found a target if( currentPositionXY[0] != -1 ) { timeSet = 0; std::cout << "Found target " << currentPositionXY[0] << std::endl; return 1; } // if we are safe if(range > stopDistance) { //if the target was last seen on the right if( lastPositionXY[0] > width/2 ) move.turn(-36); //if the target was last seen on the left if( lastPositionXY[0] =< width/2 ) move.turn(36); return 2; } //if we are not safe else { move.stop();
void cPlayer::ApplyFoodExhaustionFromMovement() { if (IsGameModeCreative()) { return; } // Calculate the distance travelled, update the last pos: Vector3d Movement(GetPosition() - m_LastFoodPos); Movement.y = 0; // Only take XZ movement into account m_LastFoodPos = GetPosition(); // If riding anything, apply no food exhaustion if (m_AttachedTo != NULL) { return; } // Apply the exhaustion based on distance travelled: double BaseExhaustion = Movement.Length(); if (IsSprinting()) { // 0.1 pt per meter sprinted BaseExhaustion = BaseExhaustion * 0.1; } else if (IsSwimming()) { // 0.015 pt per meter swum BaseExhaustion = BaseExhaustion * 0.015; } else { // 0.01 pt per meter walked / sneaked BaseExhaustion = BaseExhaustion * 0.01; } m_FoodExhaustionLevel += BaseExhaustion; }
Point2F SwipeGestureRecognizer::CurrentVelocity() const { return Movement() / Duration(); }
void PlayerObject::Update(float deltatime) { changed_element = false; destroy_fire = 0; destroy_water = 0; destroy_wood = 0; add_fire = 0; add_water = 0; add_wood = 0; add_element = false; current_animation->Update(deltatime); add_element = false; if(!dead) { //collision timer if(!can_collide) { collision_refresh_timer += deltatime; position.x += deltatime * knockback_speed * collision_direction.x; position.y += deltatime * knockback_speed * collision_direction.y; //can collide again if(collision_refresh_timer > knockback_time) { can_collide = true; collision_refresh_timer = 0.0f; } } else { //Shooting if(created_projectile) { shooting_delay += deltatime; } if(shooting_delay == 0.001f || shooting_delay > 0.2) { //If you are not shooting, then you are able to move Movement(deltatime); //If you are not shooting, then you are able to use souls Souls(); //Elemental swap if(sf::Keyboard::isKeyPressed(sf::Keyboard::R) && !element_changed && CanChangeElement()) { element_changed = true; NextElement(); } if(element_changed) { element_changed_delay += deltatime; if(element_changed_delay > 0.5f) { element_changed = false; element_changed_delay = 0.0f; } } } if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && !created_projectile) { create_projectile = true; created_projectile = true; if(direction.x == 1) { SetCurrentAnimation(ATTACKRIGHT); } else { SetCurrentAnimation(ATTACKLEFT); } } else { create_projectile = false; } if(shooting_delay > delay) { shooting_delay = 0.001f; created_projectile = false; } //end of shooting //timern till lost souls if(used_lost_souls) { lost_souls_counter += deltatime; if(lost_souls_counter > 0.3) { used_lost_souls = false; lost_souls_counter = 0.0f; } } } } //death else { if(collider != nullptr) { delete collider; collider = nullptr; } death_animation_time += deltatime; if(death_animation_time > current_animation->GetNumberOfFrames() * current_animation->GetFrameDuration()) { flagged_for_death = true; } } //Lastly update the collider and the sprites position if(hasCollider()) { collider->position.x = position.x + entity_offset_x; collider->position.y = position.y + entity_offset_y; hitbox.setPosition(sf::Vector2f(collider->position.x, collider->position.y)); } current_animation->getSprite()->setPosition(position.x, position.y); }
MovementProvider::MovementProvider(QObject *parent) : QObject(parent) { m_movements.append(Movement(0.0, 0.0)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(-M_PI / 4.0, 0.0)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(M_PI / 4.0, 0.0)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(-M_PI / 4.0, 0.0)); m_movements.append(Movement(0.0, 0.2)); m_movements.append(Movement(-M_PI / 4.0, 0.0)); }
void Enemy::Update(float delta) { Movement(delta); m_render_rect->x = xPosition; m_render_rect->y =yPosition; }
void Basket::Update() { Movement(); }
void WoodEnemyObject::Update(float deltatime) { //Firstly update the animation current_animation->Update(deltatime); //Secondly update the sprites position if there is a collider if(hasCollider()) { current_animation->getSprite()->setPosition(position.x, position.y); collider->position.x = position.x + entity_offset_x; collider->position.y = position.y + entity_offset_y; } if(!dead) { if(!can_collide) { collision_refresh_timer += deltatime; //can collide again if(collision_refresh_timer > knockback_time) { can_collide = true; collision_refresh_timer = 0.0f; } } else { //Attacking if(created_projectile) { shooting_delay += deltatime; if(current_animation->GetCurrentFrame() == 4 && direction.x == 1) { float extension = 0.0f; extension = collider->extension.x; collider->position.x = (position.x + extension) + extension; } else if(current_animation->GetCurrentFrame() == 4 && direction.x == -1) { if(direction.x == -1) collider->position.x = collider->position.x - collider->extension.x; else if(direction.x == 1) collider->position.x = collider->position.x + collider->extension.x; } } Attack(); if(shooting_delay > current_animation->GetNumberOfFrames() * current_animation->GetFrameDuration()) { shooting_delay = 0.001f; created_projectile = false; } //end of attacking //Movement if(!created_projectile) Movement(deltatime); } } else { death_animation_time += deltatime; if(death_animation_time > current_animation->GetNumberOfFrames() * current_animation->GetFrameDuration()) { flagged_for_death = true; } //drop lost soul delay if(dropped_lostsoul == true) { lostsouldrop_delay += deltatime; } if(lostsouldrop_delay == 0.001f && !dropped_lostsoul && random_number<=2) { drop_lostsoul = true; dropped_lostsoul = true; } else { drop_lostsoul = false; } if(lostsouldrop_delay > lostsoulgoahead_delay) { lostsouldrop_delay = 0.001f; dropped_lostsoul = false; } } if(hasCollider()) { //Change the position of the hitbox hitbox.setPosition(collider->position.x, collider->position.y); } }