void Painter::DrawLineStroke(int width, Color color) { if(IsNull(width) || IsNull(color)) return; Begin(); LineCap(LINECAP_ROUND); switch(width) { case PEN_NULL: Stroke(0, color); End(); return; case PEN_SOLID: Stroke(1, color); break; case PEN_DASH: Dash("18 6"); break; case PEN_DOT: Dash("3 3"); break; case PEN_DASHDOT: Dash("9 6 3 6"); break; case PEN_DASHDOTDOT: Dash("9 3 3 3 3 3"); break; default: Stroke(width == 0 ? 1 : width, color); End(); return; } Stroke(1, color); End(); }
void Game::FingerUp() { if (CheckHadokenRelease()) { } else if (touchCounter < DASH_LIMIT) { //Jump left or right float temp; if (player[PLAYER_ONE]->getPrevMovement() == 1) { temp = (float)(player[PLAYER_ONE]->m_Y + (ScreenHeight / 20)); if (temp > player[PLAYER_TWO]->m_Y) { temp = player[PLAYER_TWO]->m_Y; } } else if (player[PLAYER_ONE]->getPrevMovement() == 0) { temp = (float)(player[PLAYER_ONE]->m_Y - (ScreenHeight / 20)); if (temp < 0) { temp = 0; } } Dash(PLAYER_ONE, temp); } player[PLAYER_ONE]->setPrevMovement(-1); }
Painter& Painter::Dash(const char *dash, double start) { Vector<double> d; CParser p(dash); try { while(!p.IsEof()) if(p.Char(':')) start = p.ReadDouble(); else d.Add(p.ReadDouble()); } catch(CParser::Error) {} Dash(d, start); return *this; }
void ON_HatchLine::Dump( ON_TextLog& dump) const { dump.Print( "ON_HatchLine: angle = %lf radians ( %lf degrees) ", Angle(), ON_RADIANS_TO_DEGREES * Angle()); dump.Print( " base = "); dump.Print( m_base); dump.Print( " offset = "); dump.Print( m_offset); int count = m_dashes.Count(); dump.Print( "\nDash count = %d: ", count); for( int i = 0; i < count; i++) { dump.Print( "%lf", Dash( i)); if( i < count-1) dump.Print( ", "); } dump.Print( "\n"); }
void Game::CheckAINextMove() { // if we should left dash int distance = player[PLAYER_TWO]->m_Y - player[PLAYER_ONE]->m_Y; if (!(player[PLAYER_TWO]->getPrevHit())) { // check if we should kick if (distance == 0) { if (player[PLAYER_ONE]->m_Y > ScreenHeight / 15) { Kick(PLAYER_TWO, 1.0f); player[PLAYER_TWO]->setPrevMovement(2); } // check if we should punch else { Punch(PLAYER_TWO, 1.0f); player[PLAYER_TWO]->setPrevMovement(3); } } else { //check if we should dash left if (player[PLAYER_ONE]->getPrevMovement() != 4) { if (ScreenHeight / 6 < distance) { float temp = CheckPlayer1Collision((float)(player[PLAYER_TWO]->m_Y - (ScreenHeight / 15))); Dash(PLAYER_TWO, temp); player[PLAYER_TWO]->setPrevMovement(0); } else if (projectiles[PLAYER_ONE].size() > 0) { MakeHadoken(PLAYER_TWO); player[PLAYER_TWO]->setPrevMovement(4); } // check if we should move left else { float temp = CheckPlayer1Collision(player[PLAYER_TWO]->m_Y - (ScreenHeight / 160)); player[PLAYER_TWO]->m_Y = temp; player[PLAYER_TWO]->setPrevMovement(0); } } else { if (projectiles[PLAYER_ONE].size() > 0) { if (projectiles[PLAYER_ONE].at(0)->m_Y - player[PLAYER_TWO]->m_Y < ScreenHeight / 10) { Block(PLAYER_TWO); player[PLAYER_TWO]->setPrevMovement(5); } } } } } else { // check if we should right dash if (player[PLAYER_TWO]->getPrevHit()) { player[PLAYER_TWO]->setPrevMovement(1); } // check if we should move right else if (0) { player[PLAYER_TWO]->setPrevMovement(1); } } player[PLAYER_TWO]->setPrevHit(false); }
VIRTUAL void PlayerEnt::Update(const sf::Time& dt) { if (m_bRespawn) { m_bRespawn = false; DestroyChain(); m_pBody->SetTransform(m_spawnPos, 0); } for (int i = 0; i < EButton::EB_COUNT; ++i) { m_vButtons[i].Flush(dt.asSeconds()); } if (m_vButtons[EB_SHOOT].Pull()) { Shoot(); } if (m_vButtons[EB_DASH].Pull()) { Dash(); } if (m_fFlipTime > 0) { float desiredAngle = 0; m_fFlipTime -= dt.asSeconds(); if (m_fFlipTime <= 0) { float desiredAngle = 0; m_pBody->SetTransform(m_pBody->GetPosition(), 0); m_pBody->SetFixedRotation(true); } else { desiredAngle = 180 * DEG_RAD;// Lerp(0, 360, 1.0f - (m_fFlipTime / m_tValue.m_fFlipTime)); float bodyAngle = m_pBody->GetAngle(); float nextAngle = bodyAngle + m_pBody->GetAngularVelocity() / 60.0; float totalRotation = desiredAngle - nextAngle; while (totalRotation < -180 * DEG_RAD) totalRotation += 360 * DEG_RAD; while (totalRotation > 180 * DEG_RAD) totalRotation -= 360 * DEG_RAD; float desiredAngularVelocity = totalRotation * 60; float change = 10 * DEG_RAD; //allow 1 degree rotation per time step desiredAngularVelocity = Min(change, Max(-change, desiredAngularVelocity)); float impulse = m_pBody->GetInertia() * desiredAngularVelocity; m_pBody->SetFixedRotation(false); m_pBody->ApplyAngularImpulse(impulse, true); } } if (m_vButtons[EB_JUMP].Push() && m_bGrounded) { m_fJumpTime = m_tValue.m_fJumpTime; //m_pBody->ApplyLinearImpulse(b2Vec2(0, m_tValue.m_fJumpImpulse), m_pBody->GetLocalCenter(), true); m_sound.setBuffer(m_soundBufferJump); m_sound.play(); m_pDrawable->state->setAnimationByName(0, "jump", false); float jIpulse = m_pBody->GetMass() * m_tValue.m_fInitialJumpSpeed; m_pBody->ApplyLinearImpulse(b2Vec2(0, jIpulse), m_pBody->GetLocalCenter(), true); b2Vec2 jumpImpulse(0, -jIpulse * 0.5f); for (int i = 0; i < m_vGroundContacts.size(); ++i) { b2Fixture* pFixA = m_vGroundContacts[i]->GetFixtureA(); b2Fixture* pFixB = m_vGroundContacts[i]->GetFixtureB(); if (pFixA == m_pGroundSensor) { pFixB->GetBody()->ApplyLinearImpulse(jumpImpulse, pFixB->GetBody()->GetWorldCenter(), true); } else { pFixA->GetBody()->ApplyLinearImpulse(jumpImpulse, pFixA->GetBody()->GetWorldCenter(), true); } } } else if (m_vButtons[EB_JUMP].Pull()) { m_fJumpTime = -1.0f; } if (m_vButtons[EB_JUMP].Held() && m_fJumpTime > 0.0f) { m_fJumpTime -= dt.asSeconds(); float jIpulse = m_pBody->GetMass() * m_tValue.m_fTerminalJumpSpeed; m_pBody->ApplyLinearImpulse(b2Vec2(0, jIpulse), m_pBody->GetLocalCenter(), true); } m_pDrawable->update(dt.asSeconds()); m_pDrawable->setPosition(m_pBody->GetPosition().x, -m_pBody->GetPosition().y); // m_pDrawable->setRotation(m_pBody->GetAngle() * -RAD_DEG); b2Vec2 vel = m_pBody->GetLinearVelocity(); float desiredVel = 0; bool hasInput = false; if (m_vButtons[EB_RIGHT].Held()) { hasInput = true; if (m_bGrounded) desiredVel = b2Min(vel.x + m_tValue.m_fGroundAcceleration, m_tValue.m_fMaxSpeed); else desiredVel = b2Min(vel.x + m_tValue.m_fAirAcceleration, m_tValue.m_fMaxSpeed); } if (m_vButtons[EB_LEFT].Held()) { hasInput = true; if (m_bGrounded) desiredVel = b2Max(vel.x - m_tValue.m_fGroundAcceleration, -m_tValue.m_fMaxSpeed); else desiredVel = b2Max(vel.x - m_tValue.m_fAirAcceleration, -m_tValue.m_fMaxSpeed); } bool skip = false; if (!hasInput) //apply deceleration { if (m_bGrounded) desiredVel = vel.x * m_tValue.m_fGroundDeceleration; else desiredVel = vel.x * m_tValue.m_fAirDeceleration; } else if((m_vButtons[EB_LEFT].Held() && vel.x < -m_tValue.m_fMaxSpeed) || (m_vButtons[EB_RIGHT].Held() && vel.x > m_tValue.m_fMaxSpeed)) { skip = true; } if (!skip) { float velChange = desiredVel - vel.x; float impulse = m_pBody->GetMass() * velChange; //disregard time factor m_pBody->ApplyLinearImpulse(b2Vec2(impulse, 0), m_pBody->GetWorldCenter(), true); } if (m_vButtons[EB_RIGHT].Held()) m_pDrawable->skeleton->flipX = false; else if (m_vButtons[EB_LEFT].Held()) m_pDrawable->skeleton->flipX = true; //do animation state changes if (m_bGrounded) { if ((m_vButtons[EB_RIGHT].Push() && !m_vButtons[EB_LEFT].Held()) || (m_vButtons[EB_LEFT].Push() && !m_vButtons[EB_RIGHT].Held())) { //m_pStateData->setMixByName("idle", "run", 0.25); m_pDrawable->state->setAnimationByName(0, "run", true); } if ((m_vButtons[EB_RIGHT].Pull() && !m_vButtons[EB_LEFT].Held()) || (m_vButtons[EB_LEFT].Pull() && !m_vButtons[EB_RIGHT].Held())) { //m_pStateData->setMixByName("run", "idle", 0.25); m_pDrawable->state->setAnimationByName(0, "idle", true); } } if (m_pTongueContactUse) { //b2Vec2 vel = m_pTongueTip->GetLinearVelocity(); //b2Vec2 pnt = m_pTongueTip->GetPosition();// +vel.Normalize() * m_tValue.m_fTongueTipRadius; b2Vec2 pnt; b2WorldManifold mani; m_pTongueContactUse->GetWorldManifold(&mani); b2Body* otherBody; if (m_pTongueContactUse->GetFixtureA()->GetBody() == m_pTongueTip) { otherBody = m_pTongueContactUse->GetFixtureB()->GetBody(); pnt = otherBody->GetWorldPoint(m_TongueLocalCoords);// mani.points[0]; } else { otherBody = m_pTongueContactUse->GetFixtureA()->GetBody(); pnt = otherBody->GetWorldPoint(m_TongueLocalCoords);// mani.points[0]; } MakeRopeJoint(otherBody, pnt); m_pBody->GetWorld()->DestroyBody(m_pTongueTip); m_pTongueTip = null; m_pTongueContactUse = null; } if (m_pTongueTip && (m_pTongueTip->GetPosition() - m_pBody->GetPosition()).Length() > m_tValue.m_fTetherLength) { m_pTongueTip->GetWorld()->DestroyBody(m_pTongueTip); m_pTongueTip = null; } b2Vec2 dir = CalcShootDirection(); b2Vec2 pos = m_pBody->GetPosition() + b2Vec2(aimX, aimY) + b2Vec2(dir.x * aimLenX, dir.y * aimLenY); if (dir.x < 0) pos = m_pBody->GetPosition() + b2Vec2(-aimX, aimY) + b2Vec2(dir.x * aimLenX, dir.y * aimLenY); if (m_pTongueTip) { pos = m_pTongueTip->GetPosition(); pos.x -= m_pCircleDraw->getRadius(); pos.y += m_pCircleDraw->getRadius(); } pos.y *= -1; m_pCircleDraw->setPosition(pos.x, pos.y); }
void dash(PlayerObject obj){ if (!obj.skill_level[DASH]) return; if (obj.skill_cd[DASH]) return; Dash(obj.id); }
/** * Literal for dash (dash/dashes) * * @param long double d * @return Dash */ constexpr Dash operator "" _dash(long double d) { return Dash(d); }