"Ballerspiel" wie kann ich schiessen?

  • VB.NET

Es gibt 9 Antworten in diesem Thema. Der letzte Beitrag () ist von spearrow.

    "Ballerspiel" wie kann ich schiessen?

    Hallo
    hab ein 2D ballerspiel angefangen :)

    bin gerade soweit
    http://www.materialordner.de/a1ppJ5zEwxYAwbdZyzYOlRgdQE2jecGe.html

    (W,S,D ist steuerrung)


    wie kann ich jetzt machen das der scheisst?


    das ist mein source:

    Public Class Form1
    Dim key As Keys = Nothing
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    key = e.KeyCode
    If (key = Keys.W) Then
    PictureBox1.Top = PictureBox1.Top - 1
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 2
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 3
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 4
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 5
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 6
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 7
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 8
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 9
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 10
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 11
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 12
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 13
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 14
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top - 15
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 1
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 2
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 3
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 4
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 5
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 6
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 7
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 8
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 9
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 10
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 11
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 12
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 13
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 14
    Sleep(15)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Top = PictureBox1.Top + 15
    Sleep(100)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)
    PictureBox1.Left = PictureBox1.Left + 1
    Sleep(1)

    ElseIf (key = Keys.D) Then
    PictureBox1.Left = PictureBox1.Left + 3
    ElseIf (key = Keys.A) Then
    PictureBox1.Left = PictureBox1.Left - 3
    End If

    End Sub


    End Class




    das war gemeint, wegen dem scheisst.

    naja vielleicht auch mit ner picturebox, und nem timer, mit nem niedrigen intervall wo beim timer1_tick steht, das die picturebox wandern soll.

    so könnte man das machen.
    hoffe das es ned zu kompliziert war ^^
    habs hin bekommen:

    PictureBox2.Left = PictureBox1.Left + 100
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 120
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 140
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 160
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 180
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 200
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 220
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 240
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 260
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 280
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 300
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 320
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 340
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 360
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 380
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 400
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 420
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 440
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 460
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 480
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 500
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 520
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 540
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 560
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 580
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 600
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 620
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 640
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 660
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 680
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 700
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 720
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 740
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 760
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 780
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 800
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 820
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 840
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 860
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 880
    Sleep(2)
    PictureBox2.Left = PictureBox1.Left + 100


    jz will ich wenn die picturebox2 auf die picturebox3 trifft das picturebox3 verschwindet
    habe das so:


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If PictureBox3.Left = PictureBox2.Left Then
    PictureBox3.Hide()
    ElseIf PictureBox3.Top = PictureBox2.Top Then
    PictureBox3.Hide()
    ElseIf PictureBox3.Width = PictureBox2.Width Then
    PictureBox3.Hide()
    ElseIf PictureBox3.Height = PictureBox2.Height Then
    PictureBox3.Hide()
    ElseIf PictureBox2.Left = PictureBox3.Left Then
    PictureBox3.Hide()
    ElseIf PictureBox2.Top = PictureBox3.Top Then
    PictureBox3.Hide()
    ElseIf PictureBox2.Width = PictureBox3.Width Then
    PictureBox3.Hide()
    ElseIf PictureBox2.Height = PictureBox3.Height Then
    PictureBox3.Hide()
    End If
    End Sub




    was ist daran jz falsch?
    der schuss geht zwar net durch die picturebox3 hindurch , aber sie verschwindet auch nicht :(