Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    [vb.net 2010] Rimbalzi sbagliati e flickering in gioco

    Salve a tutti ragazzi! . Stò cercando di programmare un gioco semplice (visto che sono ancora alle prime armi) con vb.net ovvero dxball. Dopo aver terminato la prima fase ho notato due problemi che non riesco a risolvere,saranno sicuro banali ma ,ripeto, essendo ancora alle prime armi ho bisogno d'aiuto. In primo luogo ho notato che sul mio pc il gioco funziona perfettamente ma sui pc della scuola la palla invece di rimbalzare esce dall'angolo desto della form e rimbalza "in aria" . Ho da subito pensato che dev'essere un problema di risoluzione ma io ho messo la form al massimo della grandezza (form1.WindowState = FormWindowState.Maximized) e ho fatto in modo che la palla rimbalza a me.width - palla.width . Il secondo problema invece è legato alla pallina: ho notato che "lampeggia" quando si muove e il prof mi ha detto che tale problema è legato al timer,e che mi serve qualcosa che "non si fermi" tipo il timer ma che "cammini sempre" ( so di non essermi espresso bene è difficile da spiegare) , fatto stà che il prof non ha voluto dirmi di cosa si tratta perchè non aveva tempo di spiegarmelo. Qualcuso mi dice come si chiama? imparerò seguendo qualche video su youtube. Ringrazio anticipatamente tutte le anime pie che decideranno di aiutarmi,grazie ragazzi!!

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Forse, dico forse, se mostri il codice e lo commenti, si può dire qualcosa ...
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  3. #3

  4. #4
    Scusate ragazzi volevo evitare di mettere il codice perchè è lunghissimo e molto confusionato,sono alle prime armi con visual basic ed inoltre questo proggetto devo ancora "ottimizzarlo" , ma se serve...



    codice:
     Dim toccosopra As Boolean = False
        Dim clickc As Boolean
        Dim infinito As Boolean = False
        Dim muoviti As Boolean = False
    Dim possbarra As Point
        Dim hottoppato As Boolean = False
        Dim a As Boolean = True
        Dim posizionedelmouse As New Point
        Dim intrappolami As Boolean = False
        Dim sfondami1 As Boolean = False
        Dim sfondami2 As Boolean = False
        Dim sfondami3 As Boolean = False
        Dim sfondami4 As Boolean = False
        Dim sfondami5 As Boolean = False
        Dim sfondami6 As Boolean = False
        Dim risultato As Integer = 0
    
    
        Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    
    
            If e.KeyCode = Keys.Escape Then
                Cursor.Show()
                Cursor.Clip = Nothing
                Dim uscire As MsgBoxStyle = MsgBox("Vuoi chiudere il gioco??", MsgBoxStyle.OkCancel, "Vuoi uscire dal gioco??")
                If uscire = vbOK Then
                    Me.Close()
                Else
                    Cursor.Hide()
                    Cursor.Clip = RectangleShape1.RectangleToScreen(RectangleShape1.ClientRectangle)
                End If
            End If
        End Sub
    
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Cursor.Hide()
            Me.WindowState = FormWindowState.Maximized
            pallina.Left = sbarra.Width
            Cursor.Clip = RectangleShape1.RectangleToScreen(RectangleShape1.ClientRectangle)
            RectangleShape1.Width = Me.Width
        End Sub
    
    
        Private Sub EsciToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Me.Close()
        End Sub
    
    
        Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
    
    
            If a = True Then
                clickc = True
                muoviti_Alto.Start()
                a = False
            Else
    
    
            End If
        End Sub
    
    
    
    
        Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
            Dim posizione As New Point
            posizione.Y = sbarra.Top
            posizione.X = sbarra.Left
            If Cursor.Position.Y > Me.Height Then
                Cursor.Position = posizione
            End If
            If Cursor.Position.X > Me.Width Then
                Cursor.Position = posizione
            End If
            sbarra.Left = Cursor.Position.X
            If sbarra.Left > Me.Width - sbarra.Width Then
                sbarra.Left = Me.Width - sbarra.Width
            End If
    
    
            If clickc = False Then
                pallina.Left = sbarra.Left + 40
            Else
    
    
            End If
          
    
    
        End Sub
        Private Sub pallina_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
           
    
    
    
    
            If clickc = True Then
                If pallina.Top <= 0 Then
                    muoviti_Basso.Start()
                    muoviti_Alto.Stop()
                End If
                'If pallina.Top >= 539 Then
                'If pallina.Left = sbarra.Left Or sbarra.Left + sbarra.Width Then
                'muoviti_Basso.Stop()
                '  muoviti_Alto.Start()
                ' Else
                'MsgBox("game over")
                ' muoviti_Basso.Stop()
                ' muoviti_Alto.Stop()
                '  sbarra.Left = possbarra.Y
            End If
    
    
            ' End If
            'da qui
    
    
        End Sub
    
    
        Private Sub muoviti_Alto_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles muoviti_Alto.Tick
    
    
    
    
            If pallina.Top > 0 Then
                pallina.Top = pallina.Top - 15
            Else
                muoviti_Alto.Stop()
                muoviti_Basso.Start()
            End If
            If pallina.Top <= sfonno1.Top + sfonno1.Height Then
    
    
                If pallina.Left <= sfonno1.Left Or pallina.Left >= sfonno1.Left + sfonno1.Width Then
    
    
                Else
    
    
                    If sfondami1 = False Then
                        muoviti_Alto.Stop()
                        muoviti_Basso.Start()
                        sfondami1 = True
                        sfonno1.Visible = False
                        risultato = risultato + 1
                        Label1.Text = "hai distrutto " & risultato & " mattonici su 6"
                    End If
                End If
            End If
            If pallina.Top <= sfonno2.Top + sfonno2.Height Then
                If pallina.Left <= sfonno2.Left Or pallina.Left >= sfonno2.Left + sfonno2.Width Then
    
    
                Else
    
    
                    If sfondami2 = False Then
                        muoviti_Alto.Stop()
                        muoviti_Basso.Start()
                        sfondami2 = True
                        sfonno2.Visible = False
                        risultato = risultato + 1
                        Label1.Text = "hai distrutto " & risultato & " mattonici su 6"
                    End If
                End If
            End If
            If pallina.Top <= sfonno3.Top + sfonno3.Height Then
                If pallina.Left <= sfonno3.Left Or pallina.Left >= sfonno3.Left + sfonno3.Width Then
    
    
                Else
    
    
                    If sfondami3 = False Then
                        muoviti_Alto.Stop()
                        muoviti_Basso.Start()
                        sfondami3 = True
                        sfonno3.Visible = False
                        risultato = risultato + 1
                        Label1.Text = "hai distrutto " & risultato & " mattonici su 6"
                    End If
                End If
            End If
            If pallina.Top <= sfonno4.Top + sfonno4.Height Then
                If pallina.Left <= sfonno4.Left Or pallina.Left >= sfonno4.Left + sfonno4.Width Then
    
    
                Else
    
    
                    If sfondami4 = False Then
                        muoviti_Alto.Stop()
                        muoviti_Basso.Start()
                        sfondami4 = True
                        sfonno4.Visible = False
                        risultato = risultato + 1
                        Label1.Text = "hai distrutto " & risultato & " mattonici su 6"
                    End If
                End If
            End If
            If pallina.Top <= sfonno5.Top + sfonno5.Height Then
                If pallina.Left <= sfonno5.Left Or pallina.Left >= sfonno5.Left + sfonno5.Width Then
    
    
                Else
    
    
                    If sfondami5 = False Then
                        muoviti_Alto.Stop()
                        muoviti_Basso.Start()
                        sfondami5 = True
                        sfonno5.Visible = False
                        risultato = risultato + 1
                        Label1.Text = "hai distrutto " & risultato & " mattonici su 6"
                    End If
                End If
            End If
            If pallina.Top <= sfonno6.Top + sfonno6.Height Then
                If pallina.Left <= sfonno6.Left Or pallina.Left >= sfonno6.Left + sfonno6.Width Then
    
    
                Else
    
    
                    If sfondami6 = False Then
                        muoviti_Alto.Stop()
                        muoviti_Basso.Start()
                        sfondami6 = True
                        sfonno6.Visible = False
                        risultato = risultato + 1
                        Label1.Text = "hai distrutto " & risultato & " mattonici su 6"
                    End If
                End If
            End If
            If sfondami1 = True And sfondami2 = True And sfondami3 = True And sfondami4 = True And sfondami5 = True And sfondami6 = True Then
                vai_destra.Stop()
                vai_sinistra.Stop()
                muoviti_Alto.Stop()
                muoviti_Basso.Stop()
                Cursor.Show()
                Cursor.Clip = Nothing
                Dim vedere As MsgBoxResult = MsgBox("hai vinto!,vuoi continuare?", MsgBoxStyle.OkCancel)
                If vedere = vbOK Then
                    Cursor.Clip = Nothing
                    Application.Restart()
                Else
                    Me.Close()
    
    
                End If
            End If
    
    
        End Sub
    
    
        Private Sub muoviti_Basso_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles muoviti_Basso.Tick
            If pallina.Top < 540 Then
                pallina.Top = pallina.Top + 15
            Else
                If pallina.Left > sbarra.Left - 60 And pallina.Left < sbarra.Left + sbarra.Width Then
                    If pallina.Left <= sbarra.Left + sbarra.Width * 1 / 5 Then
                        muoviti_Basso.Stop()
                        muoviti_Alto.Start()
                        vai_destra.Stop()
                        vai_sinistra.Start()
                    ElseIf pallina.Left <= sbarra.Left + sbarra.Width * 2 / 5 Then
                        muoviti_Basso.Stop()
                        muoviti_Alto.Start()
                        vai_destra.Stop()
                        vai_sinistra.Start()
                    ElseIf pallina.Left <= sbarra.Left + sbarra.Width * 3 / 5 Then
                        muoviti_Basso.Stop()
                        muoviti_Alto.Start()
                        vai_destra.Start()
                        vai_sinistra.Stop()
                    ElseIf pallina.Left <= sbarra.Left + sbarra.Width * 4 / 5 Then
                        muoviti_Basso.Stop()
                        muoviti_Alto.Start()
                        vai_destra.Start()
                        vai_sinistra.Stop()
                    ElseIf pallina.Left <= sbarra.Left + sbarra.Width * 5 / 5 Then
                        muoviti_Basso.Stop()
                        muoviti_Alto.Start()
                        vai_destra.Start()
                        vai_sinistra.Stop()
                    End If
                Else
                    Cursor.Clip = Nothing
                    Cursor.Show()
                    Timer1.Start()
                    muoviti_Basso.Stop()
                    muoviti_Alto.Stop()
                    Dim vedere As MsgBoxResult = MsgBox("game over,vuoi ricominciare??", MsgBoxStyle.OkCancel)
                    If vedere = vbOK Then
                        Cursor.Clip = Nothing
                        Application.Restart()
                    Else
                        Me.Close()
    
    
                    End If
    
    
                    clickc = False
                    muoviti = False
    
    
                End If
            End If
          
    
    
    
    
    
    
        End Sub
    
    
        Private Sub vai_destra_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles vai_destra.Tick
            vai_sinistra.Stop()
    
    
            If pallina.Left >= 1350 Then
                vai_sinistra.Start()
                vai_destra.Stop()
            Else
                pallina.Left = pallina.Left + 15
            End If
        End Sub
    
    
    
    
    
    
        Private Sub vai_sinistra_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles vai_sinistra.Tick
            vai_destra.Stop()
    
    
            If pallina.Left <= 0 Then
                vai_sinistra.Stop()
                vai_destra.Start()
            Else
                pallina.Left = pallina.Left - 15
            End If
        End Sub
    
    
        Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            pallina.Visible = False
            Timer1.Stop()
        End Sub
    
    
        Private Sub pallina_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pallina.Click
    
    
        End Sub
    End Class
    Ultima modifica di francesco98; 16-03-2015 a 21:07

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.