c++ - Using std::vector to create a bunch of projectiles, how to make them appear one after another? -
All codes except for the loop part work according to the purpose and only for your information
I do not know how to remove 1 button release objects from vector after each other on the mouse, click on each object, while the last object does not disappear. If I try to put them all on 1 button then they all are born at the same time. This is the only thing I need help, I'm sure it's a great way to do this.
class player {public: SF :: rectangular shape size; Player (SF :: Vector 2F status, SF :: Vector 2F size) {rect.setPosition (position); Rect.setSize (size); } ... this is projectile
player crystals (player (SF :: Vector 2F (100,100), SF :: Vector 2F ( 30, 30))); ... This vector is:
std :: vector & lt; Player & gt; Stars (5, crystalArrow); ...
float angle 2 = etan 2 (mousepage.i - bullet.a, mousepage.x - bullet.x); For ...
(int i = 0; i & lt; stars.) (I ++) {stars [i] SetTexture (& Astar); Window.draw (stars [i] .rect); } If (SF :: Keyboard :: Hiccube (SF :: Keyboard :: A)) stars [0] .rect.setPosition (300300); If (SF :: Keyboard :: HQ (SF :: Keyboard :: S)) stars [1] .rect.setPosition (300,300); If (SF :: Keyboard: :: BI (SF :: Keyboard :: D)) stars [2]. Correct.setPosition (300300); If (SF :: Keyboard: :: Binocular (SF :: Keyboard :: F) stars) [3]. Exact position (300,300); If (SF :: Keyboard :: :: Keyboard :: SF :: Keyboard :: G) stars [4] .rect.setPosition (300300); Stars [0] .ct.move (cos (angle2) * 10, sin (angle2) * 10); Stars [1] .ct.move (cos (angle2) * 10, sin (angle2) * 10); Stars [2] .ct.move (cos (angle2) * 10, sin (angle2) * 10); Stars [3] .ct.move (cos (angle2) * 10, sin (angle2) * 10); Stars [4] .ct.move (cos (angle2) * 10, sin (angle2) * 10); ; -)
New code:
for (int i = 0; i & lt; stars.size (); I ++) {stars [i] exact. Settucker (& amp; Astaar); Window.draw (stars [i] .rect); } If (SF :: Keyboard :: Hiccube (SF :: Keyboard :: A) and ClockGet allecededTime (.) ASCcand ()> 0.3 F & amp; ClockGet.EllepededTime (.) ASCCend () and Lt; 0.35 F) stars [0]. exact. Position (Haleef. Gatepoint ()); If (SF :: Keyboard :: is bilateral (SF :: Keyboard :: A) and clock. Gate allexed time (.) ASCcand ()> 0.6 F & Clock Gate Elapsed Time (.) ASCCand () & lt; 0.65 F) stars [1]. Precision. Position (Haleif. Correct. Gatcher ()); If (SF :: Keyboard :: HQ (SF :: Keyboard :: A) and Clock Gate Alleceded Time ()> 0.9 F & Clock Gate Applied Time (.) ASC Canned () 0.95 F) stars [2]. Malfunction PositionPosition (.help right .getPosition ()); If (SF :: Keyboard :: HQ (SF :: Keyboard :: A) and ClockGate alleusated time (.)> ASCEND ()> 1.2 F & amp; watch GATE ALLAPSADIME (.) ASC Canned () <1.25F Stars) [3] Form.setPosition (.help right .getPosition ()); If (SF :: Keyboard :: HQ (SF :: Keyboard :: A) and ClockGate allecededTime (.) ASCCand ()> 1.5 F & amp; clock.Get Elapsedtime (.) ASCCand () <1.55F ) Stars [4] Precision. Position (Haliffe correct. Gatepoint ()); If (clock.getElapsedTime (). AsSeconds ()> 1.56f) clock.restart (); Stars [0] .ct.move (cos (angle2) * 10, sin (angle2) * 10); Stars [1] .ct.move (cos (angle2) * 10, sin (angle2) * 10); Stars [2] .ct.move (cos (angle2) * 10, sin (angle2) * 10); Stars [3] .ct.move (cos (angle2) * 10, sin (angle2) * 10); Stars [4] Exact (cos (angle2) * 10; sin (angle2) * 10); ` and every time a button is pressed (angle) is calculated:
float angle 2 = etan 2 (mousepage.i - bullet. A, mousepage.x - bullet.x);
Comments
Post a Comment