void Sprite3DWithSkinTest::addNewSpriteWithCoords(Vec2 p) { std::string fileName = "Sprite3DTest/orc.c3b"; auto sprite = EffectSprite3D::create(fileName); sprite->setScale(3); sprite->setRotation3D(Vec3(0,180,0)); addChild(sprite); sprite->setPosition( Vec2( p.x, p.y) ); auto animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation); bool inverse = (std::rand() % 3 == 0); int rand2 = std::rand(); float speed = 1.0f; if(rand2 % 3 == 1) { speed = animate->getSpeed() + CCRANDOM_0_1(); } else if(rand2 % 3 == 2) { speed = animate->getSpeed() - 0.5 * CCRANDOM_0_1(); } animate->setSpeed(inverse ? -speed : speed); sprite->runAction(RepeatForever::create(animate)); } }
void SBBTA252::sendSpeedCommand(int thruster, int speed) { // Declare variables. char cmd[10]; Serial::buf_send = cmd; // Send command. if (Serial::fd > 0) { cmd[0] = SBBTA252_SC; cmd[1] = getAddress(1, thruster); cmd[2] = getAddress(2, thruster); cmd[3] = getSpeed(1, speed); cmd[4] = getSpeed(2, speed); cmd[5] = '0'; cmd[6] = '0'; cmd[7] = getChecksum(1, cmd, 10); cmd[8] = getChecksum(2, cmd, 10); cmd[9] = SBBTA252_EC; Serial::length_send = 10; send(); usleep(SBBTA252_SERIAL_DELAY); ROS_DEBUG("Send Speed Command (%d): %s.", thruster, cmd); } } // end sendSpeedCommand()
std::string Player::toString() { std::stringstream ss ; ss << " name: " << m_playername ; ss << " pos: [" << getPosition().x << ", " << getPosition().y << "]" ; ss << " speed: [" << getSpeed().x << ", " << getSpeed().y << "]"; return ss.str(); }
void PlayerShip::accelerate() { if (getSpeed() < 5.0F) setSpeed(getSpeed() + 1.0F); writeVelocity().x_ += cos(deg2rad(getAngle())) * getSpeed(); writeVelocity().y_ += sin(deg2rad(getAngle())) * getSpeed(); }
// Implements steps according to the current speed // You must call this at least once per step // returns true if a step occurred boolean EightAccelStepper::runSpeed() { unsigned long time = millis(); if (time > getLastStepTime() + getStepInterval()) { if (getSpeed() > 0) { // Clockwise setCurrentPos(getCurrentPos() + 1); } else if (getSpeed() < 0) { // Anticlockwise setCurrentPos(getCurrentPos() - 1); } if (getPins() == 8) { step(getCurrentPos() & 0x7); // Bottom 3 bits (same as mod 8, but works with + and - numbers) } else { step(getCurrentPos() & 0x3); // Bottom 2 bits (same as mod 4, but works with + and - numbers) } setLastStepTime(time); return true; } else return false; }
void Ball::update(double aDelta) { //Calculate the ball's x and y position setX(getX() + (getDirectionX() * getSpeed() * aDelta)); setY(getY() + (getDirectionY() * getSpeed() * aDelta)); //Vertical bounds check if(getY() - getRadius() < 0.0f) { //There was a collision at the top, reverse the y-direction setY(getRadius()); setDirectionY(getDirectionY() * -1.0f); } else if(getY() > ScreenManager::getInstance()->getScreenHeight() - getRadius()) { //There was a collision at the bottom, reverse the y-direction setY(ScreenManager::getInstance()->getScreenHeight() - getRadius()); setDirectionY(getDirectionY() * -1.0f); } //Horizontal bounds check if(getX() + getRadius() < 0.0f) { //The ball went off the left side of the screen, that means the right side scored Game* game = (Game*)ScreenManager::getInstance()->getScreenForName(GAME_SCREEN_NAME); game->rightGoal(); } else if(getX() > ScreenManager::getInstance()->getScreenWidth() + getRadius()) { //The ball went off the right side of the screen, that means the left side scored Game* game = (Game*)ScreenManager::getInstance()->getScreenForName(GAME_SCREEN_NAME); game->leftGoal(); } }
void OpenSteer::SimpleVehicle::regenerateLocalSpaceForBanking (const Vector3& newVelocity, const float elapsedTime) { // the length of this global-upward-pointing vector controls the vehicle's // tendency to right itself as it is rolled over from turning acceleration const Vector3 globalUp (0, 0.2f, 0); // acceleration points toward the center of local path curvature, the // length determines how much the vehicle will roll while turning const Vector3 accelUp = _smoothedAcceleration * 0.05f; // combined banking, sum of UP due to turning and global UP const Vector3 bankUp = accelUp + globalUp; // blend bankUp into vehicle's UP basis vector const float smoothRate = elapsedTime * 3; Vector3 tempUp = getUp(); blendIntoAccumulator (smoothRate, bankUp, tempUp); setUp (tempUp.normalisedCopy()); // annotationLine (getPosition(), getPosition() + (globalUp * 4), gWhite); // XXX // annotationLine (getPosition(), getPosition() + (bankUp * 4), gOrange); // XXX // annotationLine (getPosition(), getPosition() + (accelUp * 4), gRed); // XXX // annotationLine (getPosition(), getPosition() + (getUp() * 1), gYellow); // XXX // adjust orthonormal basis vectors to be aligned with new velocity if (getSpeed() > 0) regenerateOrthonormalBasisUF (newVelocity / getSpeed()); }
void Projectile::moveProjectile(sf::Time dt) { sf::Vector2f pos = getPosition(); if (bHasTarget) { if (!reachedTarget) { fDistance = sqrt(pow(targetPos.x - pos.x,2) + pow(targetPos.y - pos.y,2)); //Calculate new velocity velocity.x = getSpeed() * (targetPos.x - pos.x) / fDistance; velocity.y = getSpeed() * (targetPos.y - pos.y) / fDistance; if (fDistance > -1 && fDistance < 1) { reachedTarget = true; resetVelocity(); } } } //Rotate to face the target float dx = targetPos.x - pos.x; float dy = targetPos.y - pos.y; const float Pi = 3.141; setRotation(atan2(dy,dx) * (180 / Pi) + 90); //Calculates rotation move(getVelocity() * dt.asSeconds()); }
void OpenSteer::SimpleVehicle::regenerateLocalSpace (const Vector3& newVelocity, const float /* elapsedTime */) { // adjust orthonormal basis vectors to be aligned with new velocity if (getSpeed() > 0) regenerateOrthonormalBasisUF (newVelocity / getSpeed()); }
BcmPortGroup::LaneMode BcmPortGroup::calculateDesiredLaneMode( const std::vector<Port*>& ports, LaneSpeeds laneSpeeds) { auto desiredMode = LaneMode::QUAD; for (int lane = 0; lane < ports.size(); ++lane) { auto port = ports[lane]; if (!port->isDisabled()) { auto neededMode = neededLaneModeForSpeed(port->getSpeed(), laneSpeeds); if (neededMode < desiredMode) { desiredMode = neededMode; } // Check that the lane is expected for SINGLE/DUAL modes if (desiredMode == LaneMode::SINGLE) { if (lane != 0) { throw FbossError("Only lane 0 can be enabled in SINGLE mode"); } } else if (desiredMode == LaneMode::DUAL) { if (lane != 0 && lane != 2) { throw FbossError("Only lanes 0 or 2 can be enabled in DUAL mode"); } } VLOG(3) << "Port " << port->getID() << " enabled with speed " << static_cast<int>(port->getSpeed()); } } return desiredMode; }
void ProjectileWeapon::fireBurst() { if(getAmmoType()!=ammo_unlimited) { if(ammo==0) return; ammo--; owner->weapons.updateWeapons(); } Position ownerPos(owner->getPosition()); const Position *shotOffsets = owner->type->getWeaponMounts(numProjectiles()); doSound(); for(unsigned ii=0; ii<numProjectiles(); ii++) if(linkedFire() || ii==fireOrder) { Position shotPosition(ownerPos); shotPosition.setX(ownerPos.getX() + shotOffsets[ii].getX()*cos(ownerPos.getR()) + shotOffsets[ii].getY()*sin(ownerPos.getR())); shotPosition.setY(ownerPos.getY() - shotOffsets[ii].getX()*sin(ownerPos.getR()) + shotOffsets[ii].getY()*cos(ownerPos.getR())); shotPosition.setR_vel(0); if(!shotsGetShipVel) { shotPosition.setX_vel(0); shotPosition.setY_vel(0); } shotPosition.impulse( getSpeed()*cos(shotPosition.getR()), -getSpeed()*sin(shotPosition.getR()) ); createProjectile(&shotPosition); } fireOrder++; if(fireOrder >= numProjectiles()) fireOrder = 0; }
void OpenSteer::SimpleVehicle::applyBrakingForce (const float rate, const float deltaTime) { const float rawBraking = getSpeed() * rate; const float clipBraking = ((rawBraking < getMaxForce()) ? rawBraking : getMaxForce()); setSpeed (getSpeed() - (clipBraking * deltaTime)); }
bool StrategyDown::init(void) { this->setSpeed(Point(10, -1.2f)); float angleRadians = atanf(getSpeed().y / getSpeed().x); float angleDegrees = CC_RADIANS_TO_DEGREES(angleRadians); this->setRotation(-angleDegrees); return true; }
void AObject::updateStat(Map::status status) { if (status == Map::SPEED) if (getSpeed() > 0.5f) setSpeed(getSpeed() - 0.01f); if (status == Map::SIMULT) setSimult(getSimult() + 1); if (status == Map::RANGE) setRange(getRange() + 1); }
/** This function is called each timestep, and it collects most of the * statistics for this kart. * \param dt Time step size. */ void KartWithStats::update(int ticks) { Kart::update(ticks); if(getSpeed()>m_top_speed ) m_top_speed = getSpeed(); float dt = stk_config->ticks2Time(ticks); if(getControls().getSkidControl()) m_skidding_time += dt; if(getControls().getBrake() ) m_brake_count ++; LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld()); if(world && !world->isOnRoad(getWorldKartId())) m_off_track_count ++; } // update
void Hanger::setMovePostion(GameControl * _gameControl) { //unsigned char res = 0; #ifdef GOLDEN_MINER_2_VERSION_TIME double speed = getSpeed() / HANGER_SPEED_CONTROL * Global::getInstance()->getTimeRatio(); #else double speed = getSpeed() / HANGER_SPEED_CONTROL; #endif double speedX = 0; double speedY = 0; if((status == HANGER_STATUS_PULL_UNHAVING) || (status == HANGER_STATUS_PULL_HAVING)) { speedX = speed * cos((angle - angleChange) / angleChange * pi); speedY = speed * sin((angle - angleChange) / angleChange * pi); currX += speedX; currY += speedY; if(currY >= y) { // 收回 //setStatus(HANGER_STATUS_SWAYING_STOP_THROW); //Global::getInstance()->setHangerCanThrow(canThrow); currX = x; currY = y; if (status == HANGER_STATUS_PULL_HAVING) { _gameControl->addExplode(HANGER_GOT_AWARD, currX, currY); } tmpStatusTimeCount = HANGER_SWAP_STOP_THROW_TIME; setStatus(HANGER_STATUS_SWAYING); } } else { speedX = speed * cos(angle / angleChange * pi); speedY = speed * sin(angle / angleChange * pi); currX += speedX; currY += speedY; if((currY < 0) || (currX < 0) || (currX > CCDirector::sharedDirector()->getWinSize().width)) { // 放空 Player::getInstance()->getMusicControl()->stopEffect(MUSICCONTROL_EFFECT_ID_THROW); setStatus(HANGER_STATUS_PULL_UNHAVING); } } setPosition(CCPoint(currX, currY)); //Global::getInstance()->setHangerCurrX(currX); //Global::getInstance()->setHangerCurrY(currY); //return res; }
/** This function is called each timestep, and it collects most of the * statistics for this kart. * \param dt Time step size. */ void KartWithStats::update(float dt) { Kart::update(dt); if(getSpeed()>m_top_speed) m_top_speed = getSpeed(); if(getControls().m_skid) m_skidding_time += dt; if(getControls().m_brake) m_brake_count ++; LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld()); if(world && !world->isOnRoad(getWorldKartId())) m_off_track_count ++; } // update
void DynamicObject::update(double time) { float deltaX, deltaY, deltaZ; deltaX = getPosition()->getX(); deltaY = getPosition()->getY(); deltaZ = getPosition()->getZ(); deltaX = (deltaX + cos(getAngle()* PI / 180)* getSpeed() * time + 0.5 * getAcelaration() * time *time); deltaY = (deltaY + sin(getAngle()* PI / 180)* getSpeed() * time + 0.5 * getAcelaration() * time *time); setPosition(deltaX, deltaY, deltaZ); getHitBox()->setPosition(deltaX, deltaY, deltaZ); }
void adjustSpeed(short leftEnc, short rightEnc, int targetSpeed, uint8_t firstCall){ #define getSpeed(old,del) (((old)>64)?((old) + (delta)):( ((old)==64)?(64):((old)-(delta)) )) //Increase magnitude of old if not 64 static int oldDelta = 0; if( firstCall ) oldDelta = 0; //Reset Delta //Get speed int curSpeed = enc2Speed(leftEnc,rightEnc); int diff = curSpeed - targetSpeed; int delta = 0; uint8_t left, right; int newLeft, newRight; //Calculate delta if( diff > 0 || diff < -1 ){ //If outside of tolerance of -1 to 0 //Speed Up delta = diff*diff * SPD_DELTA; if( delta > MAX_SPD_DELTA ) delta = MAX_SPD_DELTA; //Slow Down if( targetSpeed < curSpeed ) delta = -delta; //printw("delta = %d\ttarget = %d\t current = %f\n",delta,targetSpeed,curSpeed); } //else do nothing; //Get motor values getMotorData(&motorData, &left, &right); newLeft = getSpeed(left,oldDelat+delta); newRight = getSpeed(right,oldDelta+delta); //Contrain values if( newLeft > 127 || newLeft < 1 || \ newRight > 127 || newLeft < 1){ //Delta is too large, adjust it if( delta > 0 ){ uint8_t maxMotor = max( newLeft, newRight); delta -= maxMotor-127; } else{ uint8_t minMotor = min( newLeft, newRight ); delta += 1-minMotor; } //Set new motor values newLeft = getSpeed(left,oldDelta+delta); newRight = getSpeed(right,oldDelta+delta); } oldDelta += delta; //apply motor values setMotorData(&motorData, newLeft, newRight); }
int main() { // Handle CTLR + C struct sigaction sigIntHandler; sigIntHandler.sa_handler = handleSignal; sigemptyset(&sigIntHandler.sa_mask); sigaction(SIGINT, &sigIntHandler, NULL); quit = false; auto lead = new car("lead"); auto follower = new car("follower"); auto controller = new pidController(); follower->setSpeed(0); lead->setSpeed(0); controller->setSetPoint(lead->getSpeed()); controller->setKi(1); controller->setKd(1); controller->setKp(.2); auto pvThread = std::thread(runPv, controller); auto pidThread = std::thread(runPid, controller); auto simThread = std::thread(runSim, lead, follower, controller); std::random_device rd; // only used once to initialise (seed) engine std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case) std::uniform_int_distribution<int> uni(0,4); // guaranteed unbiased while (!quit) { int randomSpeed = uni(rng); lead->setSpeed(randomSpeed); controller->setSetPoint(lead->getSpeed()); sleepSim(2); } pvThread.join(); simThread.join(); pidThread.join(); delete lead; delete follower; delete controller; return 0; }
BcmPortGroup::LaneMode BcmPortGroup::getDesiredLaneMode( const std::shared_ptr<SwitchState>& state) const { std::vector<Port*> ports; for (auto bcmPort : allPorts_) { auto swPort = bcmPort->getSwitchStatePort(state).get(); // Make sure the ports support the configured speed. // We check this even if the port is disabled. if (!bcmPort->supportsSpeed(swPort->getSpeed())) { throw FbossError("Port ", swPort->getID(), " does not support speed ", static_cast<int>(swPort->getSpeed())); } ports.push_back(swPort); } return calculateDesiredLaneMode(ports, controllingPort_->maxLaneSpeed()); }
void BcmPort::init(bool warmBoot) { bool up = false; if (warmBoot) { // Get port status from HW on warm boot. // All ports are initially down on a cold boot. int linkStatus; opennsl_port_link_status_get(unit_, port_, &linkStatus); up = (linkStatus == OPENNSL_PORT_LINK_STATUS_UP); } else { // In open source code, we don't have any guarantees for the // state of the port at startup. Bringing them down guarantees // that things are in a known state. // // We should only be doing this on cold boot, since warm booting // should be initializing the state for us. auto rv = opennsl_port_enable_set(unit_, port_, false); bcmCheckError(rv, "failed to set port to known state: ", port_); } // Notify platform port of initial state/speed getPlatformPort()->linkSpeedChanged(getSpeed()); getPlatformPort()->linkStatusChanged(up, isEnabled()); enableLinkscan(); }
void Ship :: update (WorldInterface& r_world) { if (isUnitAiSet()) { if (!desired_velocity.isZero()) { double theta = max_rotation_rate * TimeSystem::getFrameDuration(); if(theta > 0.0) { rotateTowards(desired_velocity.getNormalized(), theta); } double delta = max_acceleration * TimeSystem::getFrameDuration(); if(delta > 0.0) { double currentSpeed = getSpeed(); double desiredSpeed = desired_velocity.getNorm(); if (currentSpeed < desiredSpeed) { currentSpeed += delta; if (currentSpeed > desiredSpeed) currentSpeed = desiredSpeed; setSpeed(currentSpeed); } else if (currentSpeed > desiredSpeed) { currentSpeed -= delta; if (currentSpeed < desiredSpeed) currentSpeed = desiredSpeed; setSpeed(currentSpeed); } } } if (wantsToFire && isReloaded()) { r_world.addBullet(getPosition(), getForward(), getId()); wantsToFire = false; markReloading(); } } if(isAlive() && isDying()) { r_world.addExplosion(getPositionPrevious(), getRadius() * EXPLOSION_SIZE_FACTOR, 0); m_is_dead = true; // no further updates assert(invariant()); return; } if(isAlive()) { updateBasic(); // moves the Ship m_reload_timer += TimeSystem::getFrameDuration(); } assert(invariant()); }
void SingleCardata::update() { trackangle = RtTrackSideTgAngleL(const_cast<tTrkLocPos*>(&(car->_trkPos))); speed = getSpeed(car, trackangle); angle = trackangle - car->_yaw; NORM_PI_PI(angle); width = MAX(car->_dimension_y, fabs(car->_dimension_x * sin(angle) + car->_dimension_y * cos(angle))) + 0.1; length = MAX(car->_dimension_x, fabs(car->_dimension_y * sin(angle) + car->_dimension_x * cos(angle))) + 0.1; for (int i = 0; i < 4; i++) { corner2[i].ax = corner1[i].ax; corner2[i].ay = corner1[i].ay; corner1[i].ax = car->_corner_x(i); corner1[i].ay = car->_corner_y(i); } // for i lastspeed[2].ax = lastspeed[1].ax; lastspeed[2].ay = lastspeed[1].ay; lastspeed[1].ax = lastspeed[0].ax; lastspeed[1].ay = lastspeed[0].ay; lastspeed[0].ax = car->_speed_X; lastspeed[0].ay = car->_speed_Y; } // update
bool Actuator::setTargetTVP(double qInit,double q_target,int signMovement,double timeInit,double timeFinal,double ta, double _time) { double val; if(getTypeTrajectoryTVP()=="MaximumSpeedAcceleration") { //Acceleration phase if (_time<(timeInit+ta) && _time>=timeInit) val=qInit+signMovement*((getAcceleration()*0.5)*square(_time-timeInit)); //Velocity constant phase if (_time>=(timeInit+ta) && _time<=(timeFinal-ta)) val=qInit+signMovement*(getSpeed()*(_time-timeInit-ta*0.5)); //Deceleration phase if (_time>(timeFinal-ta) && _time<=timeFinal) val=q_target-signMovement*((getAcceleration()*0.5)*square(timeFinal-_time)); } else if(getTypeTrajectoryTVP()=="BangBang") { //Acceleration phase if (_time<(timeFinal*0.5) && _time>=timeInit) val=qInit+signMovement*((getMaxAcceleration()*0.5)*square(_time-timeInit)); //Deceleration phase if (_time>=(timeFinal*0.5) && _time<=timeFinal) val=q_target-signMovement*((getMaxAcceleration()*0.5)*square(timeFinal-_time)); } return setTarget(val); }
void FlightDataPrint::__printPositionData( QPainter* painter, FlightPoint* cPoint, int yPos, QString text, bool printVario, bool printSpeed ) { QString temp; painter->drawText(50, yPos, text); painter->drawText(145, yPos, WGSPoint::printPos(cPoint->origP.lat(), true)); painter->drawText(220, yPos, "/"); painter->drawText(230, yPos, WGSPoint::printPos(cPoint->origP.lon(), false)); painter->drawText(300, yPos - 18, 55, 20, Qt::AlignBottom | Qt::AlignRight, printTime(cPoint->time, true, true)); temp.sprintf("%d m", cPoint->height); painter->drawText(360, yPos - 18, 45, 20, Qt::AlignBottom | Qt::AlignRight, temp); if(printVario) { temp.sprintf("%.1f m/s", getVario(*cPoint)); painter->drawText(405, yPos - 18, 60, 20, Qt::AlignBottom | Qt::AlignRight, temp); } if(printSpeed) { temp.sprintf("%.1f km/h", getSpeed(*cPoint)); painter->drawText(470, yPos - 18, 65, 20, Qt::AlignBottom | Qt::AlignRight, temp); } }
void Scene::onPlayerInstruction(ServiceID avatarID, ReadStream & rs) { if (avatarID == InvalidAvatarID) { return; } if (rs.getProtoID() == MoveReq::getProtoID()) { MoveReq req; rs >> req; LOGD("MoveReq avatarID[" << avatarID << "] req=" << req); auto entity = getEntity(req.eid); if (!entity || entity->_state.avatarID != avatarID || entity->_state.etype != ENTITY_PLAYER || (req.action != MOVE_ACTION_IDLE && req.action == MOVE_ACTION_FOLLOW && req.action == MOVE_ACTION_PATH) || entity->_state.state != ENTITY_STATE_ACTIVE ) { sendToClient(avatarID, MoveResp(EC_ERROR, req.eid, req.action)); return; } if (!_move->doMove(req.eid, (MOVE_ACTION)req.action, entity->getSpeed(), req.follow, req.waypoints)) { sendToClient(avatarID, MoveResp(EC_ERROR, req.eid, req.action)); return; } if (entity->_skillSys.combating) { entity->_skillSys.combating = false; } }
void opponent::update(carData *myCar){ //TODO there we compute the path followed by the car if(car->_state & RM_CAR_STATE_NO_SIMU) return; /* we don't need to compute if we are the car of the car is no longer in the simulation */ pos.x = car->_pos_X; pos.y = car->_pos_Y; currentSeg = car->_trkPos.seg; trackAngle = RtTrackSideTgAngleL(&(car->_trkPos)); if(car == myCar->getCarPnt()) distToStart = car->_distFromStartLine; else distToStart = currentSeg->lgfromstart + getDistToSegStart(); /* update speed in track direction */ speed = getSpeed(); float cosa = speed/sqrt(car->_speed_X*car->_speed_X + car->_speed_Y*car->_speed_Y); float alpha = acos(cosa); width = car->_dimension_x*sin(alpha) + car->_dimension_y*cosa; }
//Optimized to use pointers by Ryan Davis void player::checkMovement(world *map, int x, int y) { unsigned int posOne[2]; unsigned int posTwo[2]; unsigned int posThree[2]; unsigned int posFour[2]; int speed = getSpeed(); x = (x >= 1) ? speed : x; x = (x <= -1) ? -speed : x; y = (y >= 1) ? speed : y; y = (y <= -1) ? -speed : y; speed = map -> getResolution() - speed; //This is a check of the lower bound of movement posOne[0] = (x + position[0] + 16)/map -> getResolution(), posOne[1] = (y + position[1] + 14)/map -> getResolution(); //This is a check of the upper bound of movement posTwo[0] = (x + speed + position[0] - 16)/map -> getResolution(), posTwo[1] = (y + speed + position[1] - 32)/map -> getResolution(); //This is a check of the lower bound of movement posThree[0] = (x + position[0] + 16)/map -> getResolution(), posThree[1] = (y + speed + position[1] - 32)/map -> getResolution(); //This is a check of the upper bound of movement posFour[0] = (x + speed + position[0] - 16)/map -> getResolution(), posFour[1] = (y + position[1] + 14)/map -> getResolution(); if(map -> getTileCollision(map -> checkTileMap(posOne)) && map -> getTileCollision(map -> checkTileMap(posTwo)) && map -> getTileCollision(map -> checkTileMap(posThree)) && map -> getTileCollision(map -> checkTileMap(posFour))) { //position[0] = x + position[0], position[1] = y + position[1]; posOne[0] = x + getPosition()[0], posOne[1] = y + getPosition()[1]; changePosition(posOne); } updatePosition(); }
void StrategyBack::move(void) { // log("StrategyBack::update"); // log("StrategyBack, speedX=%f, speedY=%f, rotation=%f", getSpeed().x, getSpeed().y, getRotation()); Bullet *bullet = this->getBullet(); if (bullet) { bullet->setRotation(getRotation()); bullet->setPosition(bullet->getPosition() + Point(getSpeed().x, getSpeed().y)); if (bullet->getPositionX() < 0) { _bullet->stop(); } } }