Results 1 to 8 of 8

Thread: Attacker running out of bombs DelphiX Starfighter Game

  1. #1

    Attacker running out of bombs DelphiX Starfighter Game

    Hi everyone. I did some tests and the code below generates bombs at the correct intervals. I played my game and realized that my attacker runs out of bombs for some reason after playing my game for a long period of time. Am I doing something wrong? I have the same code for the other attackers but they can get destroyed and this one not yet -- they seem to be fine.

    [pascal] if((FTamaCount<300) and (FCounter-FOldTamaTime>=150)) then
    begin
    Bomb := TBomb.create(FormGame.DXSpriteEngine.Engine);
    Bomb.OnCollision := formGame.BombCollision;
    FTamaCount := fTamaCount+1*updatespeed;
    FOldTamaTime := FCounter;
    end;
    FCounter := FCounter + UpdateSpeed; [/pascal]
    Any suggestions?
    Wake up from the dream and live your life to the full

  2. #2

    Attacker running out of bombs DelphiX Starfighter Game

    Hmm, if the problem is inside this piece of code, I'd say this
    Code:
    if&#40;FTamaCount 300>=150&#41; then
    part shouldn't be something like
    Code:
    if&#40;&#40;FTamaCount<300&#41; and &#40;FTamaCount>=150&#41;&#41; then
    If it's not that, then I think we need to see a bit more of the code

    (Edit: I see the pascal tags mess up the code a bit, so it could be that your code is already in the mentioned format)

  3. #3

    Attacker running out of bombs DelphiX Starfighter Game

    This is what I've got:

    if FTamaCount smaller than 300 and FCounter-FOldTamaTime greater or equal to 150 then

    Thanks Traveller. Yes the tags messed it up. Some code:
    Code:
    procedure TAttacker.DoMove&#40;MoveCount&#58; integer&#41;;
    begin
     inherited DoMove&#40;MoveCount&#41;;
      if &#40;fMode = 0&#41; then
      begin
        if &#40;Movement = 0&#41; Then
        Movement &#58;= Random&#40;2&#41;;
        if X > 1250  Then Movement &#58;= 1;
        if X < -500 Then Movement &#58;= 2;
    
    Case Movement of
    1&#58;
      X &#58;= X - &#40;1.5*UpdateSpeed&#41;;
    2&#58;
      X &#58;= X + &#40;1.5*UpdateSpeed&#41;;
    end;
      if&#40;&#40;FTamaCount<300&#41; and &#40;FCounter-FOldTamaTime>=150&#41;&#41; then
      begin
        Bomb &#58;= TBomb.create&#40;FormGame.DXSpriteEngine.Engine&#41;;
        Bomb.OnCollision &#58;= formGame.BombCollision;
        FTamaCount &#58;= fTamaCount+1*updatespeed;
        FOldTamaTime &#58;= FCounter;
      end;
    FCounter &#58;= FCounter + UpdateSpeed;
    end;
    end;
    
    constructor TBomb.create&#40;parent&#58; TSpriteEngine&#41;;
    begin
      inherited Create&#40;parent&#41;;
      self.Image &#58;= FormGame.DXImageList.Items&#91;formGame.FireBallImageIndex&#93;;
      self.X &#58;= attacker.X + 80;
      self.Y &#58;= attacker.Y + 100;
      self.Width &#58;= self.Image.Width;
      self.Height &#58;= self.Image.Height;
      self.PixelCheck &#58;= false;
    end;
    
    procedure TBomb.DoMove&#40;MoveCount&#58; integer&#41;;
    begin
      inherited DoMove&#40;MoveCount&#41;;
      Y &#58;= Y + &#40;4 * UpdateSpeed&#41;;
      if &#40;Player.hit&#41; then
      Dead;
      if &#40;Y >= FormGame.DXDrawGame.Height +20&#41; Then
      Dead;
      collision;
    end;
    Wake up from the dream and live your life to the full

  4. #4

    Attacker running out of bombs DelphiX Starfighter Game

    Hmm, it's still not easy to spot the error. What's FCounter used for? I see you are updating it every pass and then use it's value for FOldTamaTime. It's never being reset or initialized to a certain value though.
    I'm not sure, but that could be the problem.

  5. #5

    Attacker running out of bombs DelphiX Starfighter Game

    I think FCounter is used to calculate the intervals at which bombs are created...not too sure. It's used in the Delphix samples.

    Anyway, I set FCounter to 0 in the attacker.create and the bomb.create and now it generates bombs for about double the time it used to do and then it stops for some reason.

    I now changed the values to 600 and 300 and it seems to be working fine :-)
    Wake up from the dream and live your life to the full

  6. #6

    Attacker running out of bombs DelphiX Starfighter Game

    [pascal]if (FTamaCount<300 and (FTamaCount>=150) then[/pascal]

    Edit #12+: Where's option to delete posts? :twisted:

  7. #7

    Attacker running out of bombs DelphiX Starfighter Game

    Any time you have <> in your posts you need to check the "Disable HTML in this post" check box below the post editor. Then your stuff will come through just fine. The problem is that phpBB is trying to escape your >= and <'s and thus your getting garbage out. This is explained in many threads on this site, unfortunately searching for > and < return too many results (HINT HINT on a sticky about it guys).

  8. #8

    Attacker running out of bombs DelphiX Starfighter Game

    [pascal] if((FTamaCount<600) and (FCounter-FOldTamaTime>=300)) then
    begin
    Bomb := TBomb.create(FormGame.DXSpriteEngine.Engine);
    Bomb.OnCollision := formGame.BombCollision;
    FTamaCount := fTamaCount+1*updatespeed;
    FOldTamaTime := FCounter;
    end;
    FCounter := FCounter + UpdateSpeed;[/pascal]

    This is what I got, it seems to be working fine now.
    Wake up from the dream and live your life to the full

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •