Bug graphique de panel - VB 2010

Résolu
lesiteduhtml - 12 janv. 2013 à 21:16
 lesiteduhtml - 14 janv. 2013 à 18:34
Bonjour :),
Voici mon problème, j'ai commencé à faire un jeu (pour l'instant les graphismes sont nuls mais je fait surtout le code), J'ai donc un panel que je déplace de 20 en 20 pixel. J'ai rajouté un arrière-plan et j'ai un bug de texture, pour plus de détail, regardé la vidéo ci-dessous :
ICI

Comment pourrai-je enlever ses bugs (le fond du panel est transparent).
Merci d'avance
Amicalement :)
Jérôme

20 réponses

Utilisateur anonyme
13 janv. 2013 à 13:57
Bonjour,

Voici un petit exemple commenté qui montre comment se passer des contrôles. A tester dans un projet vierge.
Tu verras c'est pas si compliqué.

Option Strict On
Public Class Form1
    'image de fond
    Dim MonFond As Image = DessineMonFond()
    'image figure a déplacer
    Dim Monperso As Image = DessineMonPerso()
    'point de déplacement
    Dim MonPoint As Point

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'on applique au formulaire un buffer tampon pour réduire les scintillements
        Me.DoubleBuffered = True
        'on définit un point de départ
        MonPoint = New Point(100, 100)
        'on repeint le formulaire en entier
        Me.Invalidate(Me.ClientRectangle)
    End Sub

    Private Sub Form1_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        'en fonction des touches, on change les coordonnées du point
        Select Case e.KeyCode
            Case Keys.Right
                MonPoint.X += 2
            Case Keys.Left
                MonPoint.X -= 2
            Case Keys.Up
                MonPoint.Y -= 2
            Case Keys.Down
                MonPoint.Y += 2
        End Select
        'ici on ne repeint que la partie du formulaire dont le dessin change
        Me.Invalidate(New Rectangle(MonPoint.X - 2, MonPoint.Y - 2, 24, 24))
    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        'dessin du fond
        e.Graphics.DrawImage(MonFond, New Point(0, 0))
        'dessin du motif
        e.Graphics.DrawImage(Monperso, MonPoint)
    End Sub

    'fonction générant l'image du fond
    Private Function DessineMonFond() As Image
        Dim b As New Bitmap(300, 300)
        Dim g As Graphics = Graphics.FromImage(b)
        g.FillRectangle(Brushes.GreenYellow, 0, 0, b.Width, b.Height)
        g.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        Return CType(b.Clone, Image)
    End Function

    'fonction générant un motif à délacer
    Private Function DessineMonPerso() As Image
        Dim b As New Bitmap(20, 20)
        Dim g As Graphics = Graphics.FromImage(b)
        g.FillEllipse(Brushes.Red, New Rectangle(2, 2, 10, 10))
        g.FillEllipse(Brushes.Blue, New Rectangle(4, 12, 7, 7))
        Return CType(b.Clone, Image)
    End Function
End Class
3
Utilisateur anonyme
13 janv. 2013 à 18:17
Pense que si tu déplaces ton image de 2 pixels, tu dois invalider une zone élargie de 2 pixels de chaque côtés :
Exemple avec un déplacement vers la gauche
-----------
|    __    |
|   |  |xx |
|   |__|xx |
|          |
|__________

Donc, si tu déplaces de 2 pixels, pense à invalider une zone élargie de 2 pixels de chaque côtés. Dans ton cas et pour 2 pixels, ça serait :
Me.Invalidate(New Rectangle(MonPoint.X - 2, MonPoint.Y - 2, 35, 52))


Et ensuite comment donner un nom comme PN_MARIO à ce personnage ??

Puisque tu joues sur les coordonnées d'un point, tu n'as qu'a nommer ton point 'Mario'.
Dim Mario as Point


Tu peux aussi déplacer un rectangle figurant ton personnage au lieu d'un point. Ca te permettra de savoir si l'image sort du formulaire, si il rencontre un autre objet sur son passage, de savoir si la souris se trouve dessus etc...
Pour cela, sers toi de la classe Rectangle (voir msdn) et de ses fonctions.

Si tu veux déplacer une autre image, déplace un autre point (ou rectangle).
3
Utilisateur anonyme
13 janv. 2013 à 11:42
Bonjour,

Quel est le bug, celui du contour du personnage qui clignote ou celui du curseur qui laisse des traces ?
0
Utilisateur anonyme
13 janv. 2013 à 11:46
Pour résumer une autre discussion que nous avions eu il y a quelques mois, il faut éviter la transparence quand il s'agit de déplacement de contrôles. Il vaut mieux dessiner graphiquement sur le contrôle de devant, la partie qui se trouve dessous. Voire carrément se passer des contrôles en dessinant directement sur une image c'est encore mieux.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
lesiteduhtml
13 janv. 2013 à 12:16
Bonjour :),
"dessiner graphiquement sur le contrôle de devant" Comment faire ça ??
Merci d'avance :)
Amicalement
Jérôme
0
Utilisateur anonyme
13 janv. 2013 à 12:25
Grâce à la propriété Bounds du contrôle en déplacement, tu connais la position et la taille de la portion d'image du dessous. Il te suffit alors de récupérer et de dessiner cette image sur ton contrôle en déplacement. Ceci donne une impression de transparence et ne donne pas une impression de clignotement.
0
lesiteduhtml
13 janv. 2013 à 13:08
D'accord, j’essaie ...
Euh, la propriété Bounds est sur le panel ou sur le form (je ne la voie sur aucun)??
Merci d'avance
Jérôme
0
lesiteduhtml
13 janv. 2013 à 13:11
Si ça peut t'aider voici le code que j'utilise pour avancer :

If e.KeyValue Keys.Right And recuppos False Then 'droite
            If PN_MARIO.Location.X + 20 < 688 Then
                recuppos = True
                PN_MARIO.Location = New Point(PN_MARIO.Location.X + 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X + 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite2
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X + 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite3
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X + 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite4
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X + 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite
                hbwait(50)


                posX = PN_MARIO.Location.X
                posY = PN_MARIO.Location.Y
                'hbwait(100)
                recuppos = False
                Exit Sub
            Else
                Exit Sub
            End If
        ElseIf e.KeyValue Keys.Left And recuppos False Then 'gauche
            If PN_MARIO.Location.X - 20 > -1 Then
                recuppos = True
                PN_MARIO.Location = New Point(PN_MARIO.Location.X - 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X - 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche2
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X + 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche3
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X - 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche4
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X - 4, PN_MARIO.Location.Y)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche
                hbwait(50)


                posX = PN_MARIO.Location.X
                posY = PN_MARIO.Location.Y
                'hbwait(100)
                recuppos = False
                Exit Sub
            Else
                Exit Sub
            End If
        ElseIf e.KeyValue Keys.Up And recuppos False Then 'haut
            If PN_MARIO.Location.Y - 20 > -1 Then
                recuppos = True
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y - 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y - 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut2
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y - 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut3
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y - 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut4
                hbwait(50)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y - 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut
                hbwait(50)


                posX = PN_MARIO.Location.X
                posY = PN_MARIO.Location.Y
                'hbwait(100)
                recuppos = False
                Exit Sub
            Else
                Exit Sub
            End If
        ElseIf e.KeyValue Keys.Down And recuppos False Then 'bas
            If PN_MARIO.Location.Y + 20 < 686 Then
                recuppos = True
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y + 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas
                hbwait(100)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y + 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas2
                hbwait(100)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y + 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas3
                hbwait(100)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y + 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas4
                hbwait(100)
                '
                PN_MARIO.Location = New Point(PN_MARIO.Location.X, PN_MARIO.Location.Y + 4)
                PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas
                hbwait(100)


                posX = PN_MARIO.Location.X
                posY = PN_MARIO.Location.Y
                'hbwait(100)
                recuppos = False
                Exit Sub
            Else
                Exit Sub


            End If


Voilà
Merci d'avance
Jérôme
0
lesiteduhtml
13 janv. 2013 à 14:50
Re :),
Merci pou le code, j'ai essayé de l'adapté pour mon code mais on ne vois que la tête du monsieur ps le reste (sinon il n'y a plus de bug ^^).
Je te met une capture d'écran :
Ici

Voilà le code que j'ai mis :
    Private Sub map_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        'dessin du fond
        e.Graphics.DrawImage(MonFond, New Point(0, 0))
        'dessin du motif
        e.Graphics.DrawImage(Monperso, MonPoint)
    End Sub

    Private Function DessineMonFond() As Image
        Dim b As New Bitmap(700, 700)
        Dim g As Graphics = Graphics.FromImage(b)
        'g.FillRectangle(Brushes.AliceBlue, 0, 0, 700, 700)
        g.DrawImage(WindowsApplication1.My.Resources.Resources.carré, 0, 0, 20, 20)
        'g.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        Return CType(b.Clone, Image)
    End Function

    'fonction générant un motif à délacer
    Private Function DessineMonPerso() As Image
        Dim b As New Bitmap(20, 20)
        Dim g As Graphics = Graphics.FromImage(b)
        g.DrawImage(WindowsApplication1.My.Resources.Resources.droite, 0, 0, 31, 48)
        'g.FillEllipse(Brushes.Red, New Rectangle(2, 2, 10, 10))
        'g.FillEllipse(Brushes.Blue, New Rectangle(4, 12, 7, 7))
        Return CType(b.Clone, Image)
    End Function


Voilà,
Merci beaucouop de prendre du temps pour moi :)
Amicalement
Jérôme
0
Utilisateur anonyme
13 janv. 2013 à 15:09
Agrandis un peu la taille du bitmap de manière à ce que ton image perso soit affichée en entier :
Dim b As New Bitmap( 'ici la hauteur , 'ici la largeur)
0
Utilisateur anonyme
13 janv. 2013 à 15:10
Plutot l'inverse largeur,hauteur
0
lesiteduhtml
13 janv. 2013 à 15:21
Merci :),
Je suis pas content, le bug ne marche que d'un seul côté, au moins sa aurait pu marcher de tous les côtés, sa aurait été classe :) ).
J'ai un bug marrant quand je monte, sa laisse une trainée de pixel :) .
Voir vidéo ci-dessous :
Ici
Voilà,
Merci d'avance
Amicalement
Jérôme
0
Utilisateur anonyme
13 janv. 2013 à 15:29
Il faut invalider une taille plus importante (correspobndant à la taille de ton image) sur cette ligne :
 Me.Invalidate(New Rectangle(MonPoint.X - 2, MonPoint.Y - 2, 24, 24))

Agrandis les chiffres -2, 24 selon la taille de ton image.
0
lesiteduhtml
13 janv. 2013 à 15:30
Après en plus, il y a autre chose qui ne marche pas a cause du "Option Strict On".
Au début je récupère des chauses sur une base mySQL, je le fait dans des Function dans un Module, mais depuis ça ne marche plus :
Voici le code concerné
posX = Module2.posXF(posX)
        posY = Module2.posYF(posY)
        niveauheros = Module2.niveauherosF(niveauheros)
        mapheros = Module2.mapherosF(mapheros)
        attaque_main_min = Module2.attaque_main_minF(attaque_main_min)
        attaque_main_max = Module2.attaque_main_maxF(attaque_main_max)
        vieheros = Module2.vieherosF(vieheros)
        vieherosmax = Module2.vieherosmaxF(vieherosmax)
        PN_MARIO.Location = New Point(posXF(posX), posYF(posY))


L'erreur c'est : "Option Strict interdit le conversations implicaites de 'Object' en 'Integer'.

Voilçà :)
Merci d'avance
Amicalement
Jérôme
0
Utilisateur anonyme
13 janv. 2013 à 15:35
Tu ne montres pas le code de tes déclarations.
Ces variables sont-elles déclarées dans le bon type 'As Integer' ?
0
lesiteduhtml
13 janv. 2013 à 17:44
C'est bon, j'ai réussi a faire marché mon ode en mettant :
posX = CInt(Module2.posXF(CStr(posX)))
        posY = CInt(Module2.posYF(CStr(posY)))
        niveauheros = CInt(Module2.niveauherosF(niveauheros))
        mapheros = Module2.mapherosF(mapheros)
        attaque_main_min = Module2.attaque_main_minF(attaque_main_min)
        attaque_main_max = Module2.attaque_main_maxF(attaque_main_max)
        vieheros = Module2.vieherosF(vieheros)
        vieherosmax = Module2.vieherosmaxF(vieherosmax)


Merci encore :) (j'étais en train de révisé mon brevet blanc de demain) :)

Maintenant j'ai plusieurs questions :
-Voici ma ligne, mon personnage fait 31 sur 48 pixels :
Me.Invalidate(New Rectangle(MonPoint.X - 2, MonPoint.Y - 2, 31, 48))


Et ensuite comment donner un nom comme PN_MARIO à ce personnage ??

Merci d'avance ^^
Amicalement
Jérôme
0
lesiteduhtml
13 janv. 2013 à 19:39
Salut, je pense que je me suis trompé mais je n'arrive pas a voir mon personnage.
Voici le code adapté :

Option Strict On
Imports MySql.Data.MySqlClient
Public Class map

    'image de fond
    Dim MonFond As Image = DessineMonFond()
    'image figure a déplacer
    Dim monperso As Image = DessineMonPerso() 'monperso
    'point de déplacement
    Dim PN_MARIO As Rectangle
    Public recuppos As Boolean = False
    'Combat
    Public posX As Integer
    Public posY As Integer
    Public attaque_main_max As Integer
    Public attaque_main_min As Integer
    Public niveauheros As Integer
    Public vieheros As Integer
    Public vieherosmax As Integer
    Public mapheros As String
    'End Combat
    Public ConnexionSql2 As String = "Database=***;" & "Data Source=***;" & "User Id=***;Password=***;" & "Connection Timeout=20"
    Public connection2 As New MySqlConnection(ConnexionSql2)

    Private Sub Form2_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        posX = PN_MARIO.X
        posY = PN_MARIO.Y
        Dim query2 As String "UPDATE users SET posX @posX"
        Dim query3 As String "UPDATE users SET posY @posY"
        Dim Command2 As New MySqlCommand(query2, connection2)
        Dim Command3 As New MySqlCommand(query3, connection2)
        Command2.Prepare()
        Command2.Parameters.AddWithValue("@posX", posX)
        Command2.ExecuteNonQuery()

        Command3.Prepare()
        Command3.Parameters.AddWithValue("@posY", posY)
        Command3.ExecuteNonQuery()
        '
        MsgBox("Au revoir :)")
        '
        identification.NotifyIcon1.Visible = False
        identification.ShowInTaskbar = True
        identification.Visible = True
        connection2.Close()
    End Sub

    Public Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        connection2.Open()
        Me.DoubleBuffered = True
        Me.Invalidate(Me.ClientRectangle)


        posX = CInt(Module2.posXF(CStr(posX)))
        posY = CInt(Module2.posYF(CStr(posY)))
        niveauheros = CInt(Module2.niveauherosF(niveauheros))
        mapheros = Module2.mapherosF(mapheros)
        attaque_main_min = Module2.attaque_main_minF(attaque_main_min)
        attaque_main_max = Module2.attaque_main_maxF(attaque_main_max)
        vieheros = Module2.vieherosF(vieheros)
        vieherosmax = Module2.vieherosmaxF(vieherosmax)
        Dim user = identification.userbon
        PN_MARIO.X = posX
        PN_MARIO.Y = posY
        Me.Text = user & " - ****** 2013"
        If recuppos = False Then
        Else
            Exit Sub
        End If
        'on applique au formulaire un buffer tampon pour réduire les scintillements
        'on définit un point de départ
        'on repeint le formulaire en entier
    End Sub

    Public Sub Form2_Keydown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        'ici on ne repeint que la partie du formulaire dont le dessin change

        If e.KeyValue Keys.Right And recuppos False Then 'droite
            If PN_MARIO.X + 20 < 688 Then
                recuppos = True
                PN_MARIO.X += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite
                hbwait(50)
                '
                PN_MARIO.X += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite2
                hbwait(50)
                '
                PN_MARIO.X += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite3
                hbwait(50)
                '
                PN_MARIO.X += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite4
                hbwait(50)
                '
                PN_MARIO.X += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.droite
                hbwait(50)


                posX = PN_MARIO.X
                posY = PN_MARIO.Y
                'hbwait(100)
                recuppos = False
                Exit Sub
            Else
                Exit Sub
            End If
        ElseIf e.KeyValue Keys.Left And recuppos False Then 'gauche
            If PN_MARIO.X - 20 > -1 Then
                recuppos = True
                PN_MARIO.X -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche
                hbwait(50)
                '
                PN_MARIO.X -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche2
                hbwait(50)
                '
                PN_MARIO.X -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche3
                hbwait(50)
                '
                PN_MARIO.X -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche4
                hbwait(50)
                '
                PN_MARIO.X -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.gauche
                hbwait(50)


                posX = PN_MARIO.X
                posY = PN_MARIO.Y
                'hbwait(100)
                recuppos = False
                Exit Sub
            Else
                Exit Sub
            End If
        ElseIf e.KeyValue Keys.Up And recuppos False Then 'haut
            If PN_MARIO.Y - 20 > -1 Then
                recuppos = True
                PN_MARIO.Y -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut
                hbwait(50)
                '
                PN_MARIO.Y -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut2
                hbwait(50)
                '
                PN_MARIO.Y -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut3
                hbwait(50)
                '
                PN_MARIO.Y -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut4
                hbwait(50)
                '
                PN_MARIO.Y -= 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.haut
                hbwait(50)


                posX = PN_MARIO.X
                posY = PN_MARIO.Y
                'hbwait(100)
                recuppos = False
                Exit Sub
            Else
                Exit Sub
            End If
        ElseIf e.KeyValue Keys.Down And recuppos False Then 'bas
            If PN_MARIO.Y + 20 < 686 Then
                recuppos = True
                PN_MARIO.Y += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas
                hbwait(50)
                '
                PN_MARIO.Y += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas2
                hbwait(50)
                '
                PN_MARIO.Y += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas3
                hbwait(50)
                '
                PN_MARIO.Y += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas4
                hbwait(50)
                '
                PN_MARIO.Y += 4
                'PN_MARIO.BackgroundImage = WindowsApplication1.My.Resources.Resources.bas
                hbwait(50)


                posX = PN_MARIO.X
                posY = PN_MARIO.Y
                'hbwait(100)
                recuppos = False
                Exit Sub
            Else

                Exit Sub


            End If

            Else
                Exit Sub
            End If

        Else
            Exit Sub
        End If
        Me.Invalidate(New Rectangle(PN_MARIO.X - 2, PN_MARIO.Y - 2, 35, 52))

    End Sub

    Private Sub PN_MARIO_Click(sender As Object, e As System.EventArgs)
        MsgBox("X : " & PN_MARIO.X & "; Y : " & PN_MARIO.Y & "; Niveau : " & niveauheros & "; Map : " & mapheros)
    End Sub

    Private Sub map_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        'dessin du fond
        e.Graphics.DrawImage(MonFond, New Point(0, 0))
        'dessin du motif
        e.Graphics.DrawImage(Monperso, PN_MARIO)
    End Sub

    Private Function DessineMonFond() As Image
        Dim b As New Bitmap(700, 700)
        Dim g As Graphics = Graphics.FromImage(b)
        'g.FillRectangle(Brushes.AliceBlue, 0, 0, 700, 700)
        g.DrawImage(WindowsApplication1.My.Resources.Resources.carré, 0, 0, 20, 20)
        'g.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        Return CType(b.Clone, Image)
    End Function

    'fonction générant un motif à délacer
    Private Function DessineMonPerso() As Image
        Dim b As New Bitmap(31, 48)
        Dim g As Graphics = Graphics.FromImage(b)
        g.DrawImage(WindowsApplication1.My.Resources.Resources.droite, 0, 0, 31, 48)
        'g.FillEllipse(Brushes.Red, New Rectangle(2, 2, 10, 10))
        'g.FillEllipse(Brushes.Blue, New Rectangle(4, 12, 7, 7))
        Return CType(b.Clone, Image)
    End Function


End Class


Voilà,
Je sais que c'est long
J'espère que tu trouveras l'erreur (j'ai moi-même cherché pendant longtemps et je n'ai rien trouvé)
PS : En passant j'ai modifié le PN_MARIO.Point en PN_MARIO.Rectangle.

Merci d'avance :)
Amicalement
Jérôme
0
cs_ShayW Messages postés 3253 Date d'inscription jeudi 26 novembre 2009 Statut Membre Dernière intervention 3 décembre 2019 57
13 janv. 2013 à 20:46
Salut Banana32

Ah le patron ne t'a pas donné de vacances

Me.DoubleBuffered = True correspond à utiliser
les class BufferedGraphics et BufferedGraphicsContext ?

ex

Private BufferredGraphic As BufferedGraphics
 Private CurrentContext As BufferedGraphicsContext 


 BufferredGraphic = Me.CurrentContext.Allocate(Panel1.CreateGraphics(), Panel1.DisplayRectangle)
        BufferredGraphic.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
        BufferredGraphic.Graphics.Clear(Color.Cornsilk)
BufferredGraphic.Graphics.DrawPolygon(mypen, points)


Peut on obtenir le meme résultat avec
Me.DoubleBuffered = True ?
0
Utilisateur anonyme
14 janv. 2013 à 18:15
@lesiteduhtml
Bon je t'ai donné des pistes de réflexion. A toi d'adapter ton code comme tu l'entends. Je t'assures que j'ai très envie de lire ton code... enfin non je ne le lirai pas (il faut être honnête)
Mais je suis sûr que tu vas t'en sortir tout seul. Ton dernier code indique que tu as brûlé des étapes et c'est ce qui explique tes difficultés.
Commence par des choses simples et continue petit à petit à rajouter des difficultés en te servant de l'aide. (msdn)
Bon courage.

@ShayW
Non je n'ai des vacances qu'en même temps que les gamins en février

Pour ce qui est de ta question, je n'en ai aucune idée.
0
lesiteduhtml
14 janv. 2013 à 18:34
Merci beaucoup de toute ton aide :),
Je vous souhaite une bonne année, je marque ce sujet comme résolu, à bientôt
Amicalement
Jérôme
0
Rejoignez-nous