Results 1 to 2 of 2

Thread: [2005] Acummulator going down, unkown reason.

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    2

    [2005] Acummulator going down, unkown reason.

    hey guys,
    I'm having this weird problem, its a ugly block of code but it works for what I need it to do, minus this one tiny problem... I'm making a sort of space invaders game and when one of the enemies hits the building I need the HP accumulator go down, but it seems to be going down if I click one of the other enemies, if I click the first it stays at five, but if I click any enemy after that no matter where they are the accumulator goes down... I think my problem is here, any help? (sorry its so bad, I'm a beginner)

    Code:
        Private Sub TimerEnemy1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TimerEnemy1.Tick
            Me.Enemy1.Top += 3
            If Me.Enemy1.Top > Me.btnBuilding.Top And Me.Enemy1.Left > Me.btnBuilding.Left And Me.Enemy1.Right < Me.btnBuilding.Right Then
                Me.Enemy1.Visible = False
                Me.TimerEnemy1.Stop()
                Me.intaccumulatorHP = intaccumulatorHP - 1
                Me.lblUserHP.Text = intaccumulatorHP
            End If
        End Sub

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] Acummulator going down, unkown reason.

    I don't see anything in that particular code that looks like it would cause the results you are reporting. It appears that the only part of that code that alters the accumulator runs only if the enemy is in a certain place relative to the building. That doesn't seem likely to produce the behavior you are seeing, but you can confirm that pretty easily by putting a breakpoint on the code that decreases the accumulator.

    If you reach the breakpoint, check the various pieces of the conditional statement by using Shift+F9 to see whether they are all what you expect them to be.

    However, I expect that when you do this, you will see the accumulator decreasing without reaching the breakpoint, which will tell you that the problem exists elsewhere.
    My usual boring signature: Nothing

Posting Permissions

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



Click Here to Expand Forum to Full Width