Bienvenue, Invité. Merci de vous connecter ou de vous inscrire.
Avez-vous perdu votre e-mail d'activation ?

Auteur Sujet: Passage de 1.6 à 2.0: erreur  (Lu 1985 fois)

0 Membres et 1 Invité sur ce sujet

Blabla51

  • Newbie
  • *
  • Messages: 9
    • Voir le profil
    • E-mail
Passage de 1.6 à 2.0: erreur
« le: Juin 26, 2012, 06:48:31 pm »
Bonjour,

Je cherche actuellement à traduire mon code ci dessous qui est en 1.6 en 2.0.

Après plusieurs essais, je n'arrive pas à répondre à toutes mes questions ...

Imports System
Imports System.Threading
Imports SFML.Audio
Imports SFML.Window
Imports SFML.Graphics

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Dim Framerate As Single
        Dim Rendu As New RenderWindow(Me.Handle)
        Dim forme As New Shape()
        Dim I2 As New Image("teste2.png")
        Dim S As New Sprite(I2)
        Dim H, W, H1, H2, H3, H4, L1, L2, L3, L4 As Long
        Dim Tick As Integer = Environment.TickCount And Int32.MaxValue
        Dim Tick2 As String
        Dim BoolH As Boolean = True
        Dim BoolR As Boolean = True
        Dim arial = New Font("arial.ttf")
        Dim Musics = New Music("LaZik")
        Musics.Play()
        Rendu.SetFramerateLimit(50)
        I2.Smooth = False
        I2.CreateMaskFromColor(I2.GetPixel(0, 0))
        H1 = 0
        H2 = 32
        H3 = 1
        H4 = 1
        L1 = 5
        L2 = 0
        L3 = 0
        L4 = 0
        H = 32
        W = 32
        While Rendu.IsOpened And Me.Visible
            System.Windows.Forms.Application.DoEvents()
            'Rendu.Clear(New Color(0, 0, 0))
            Framerate = Math.Floor(1 / Rendu.GetFrameTime())
            forme.AddPoint(New Vector2(0, 0), New Color(L1, L1 / 5 * 2, L1 / 6 * 4))
            forme.AddPoint(New Vector2(0, 250), New Color(L1 / 6 * 4, L1, L1 / 6 * 4))
            forme.AddPoint(New Vector2(250, 250), New Color(L1 / 12 * 5, L1 / 8 * 2, L1 / 6 * 4))
            forme.AddPoint(New Vector2(250, 0), New Color(L1 / 3, L1 / 2, L1))
            forme.AddPoint(New Vector2(0, 0), New Color(L1, L1 / 5 * 2, L1 / 6 * 4))
            Rendu.Draw(forme)
            S.Position = New Vector2(32, 32)
            S.SubRect = New IntRect(H1, 0, H2, 32)
            S.Color = New Color(0, 0, 0, 127)
            S.Position = New Vector2(36, 35)
            S.Rotation = -10
            S.Height = H * 2 / 3
            S.Width = S.Height * W / H
            Rendu.Draw(S)
            S.Position = New Vector2(32, 32)
            S.Color = New Color(255, 255, 255, 255)
            S.Rotation = 0
            S.Height = H
            Rendu.Draw(S)
            Rendu.Display()
            Tick = Environment.TickCount And Int32.MaxValue
            Tick2 = Tick
            Me.Text = Framerate.ToString + " FPS"

            If L1 < 256 And L1 > -1 Then
                If L1 = 255 Then
                    L4 = 1
                End If
                If L1 = 0 Then
                    L4 = 0
                End If
                If L4 = 0 Then
                    L1 = L1 + 1
                End If
                If L4 = 1 Then
                    L1 = L1 - 1
                End If
            End If
            If Tick2(6) = "2" And BoolR = True Or Tick2(6) = "7" And BoolR = True Then
                BoolR = False
                H4 = H4 + 1
                If H4 = 10 Then
                    H4 = 0
                End If
                If H1 = 0 Then
                    H1 = 32
                    H2 = 64
                ElseIf H1 = 32 And H3 = 1 Then
                    H1 = 64
                    H2 = 96
                    H3 = 0
                ElseIf H1 = 64 Then
                    H1 = 32
                    H2 = 64
                ElseIf H1 = 32 And H3 = 0 Then
                    H1 = 0
                    H2 = 32
                    H3 = 1
                End If
            ElseIf Tick2(6) = "3" And BoolR = False Or Tick2(6) = "8" And BoolR = False Then
                BoolR = True
            End If
            forme.Dispose()
            forme = New Shape()
            S.Dispose()
            S = New Sprite(I2)
        End While
        Musics.Stop()
        forme.Dispose()
        S.Dispose()
        Musics.Dispose()
        arial.Dispose()
        I2.Dispose()
        Rendu.Dispose()
    End Sub
End Class

J'ai consulté pas mal de fois le changelog, mais peu de choses changent si j'en crois ce qui est écrit.

Je suis maintenant à ce code la:

Imports System
Imports System.Threading
Imports SFML.Audio
Imports SFML.Window
Imports SFML.Graphics

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Dim Framerate As Single
        Dim Rendu As New RenderWindow(Me.Handle)
       [color=red] Dim forme As New Shape()[/color]
        Dim I2 As New Image("teste2.png")
        [color=red]Dim S As New Sprite(I2)[/color]
        Dim H, W, H1, H2, H3, H4, L1, L2, L3, L4 As Long
        Dim Tick As Integer = Environment.TickCount And Int32.MaxValue
        Dim Tick2 As String
        Dim BoolH As Boolean = True
        Dim BoolR As Boolean = True
        Dim arial = New Font("arial.ttf")
        Dim Musics = New Music("LaZik")
        Musics.Play()
        Rendu.SetFramerateLimit(50)
        I2.CreateMaskFromColor(I2.GetPixel(0, 0))
        H1 = 0
        H2 = 32
        H3 = 1
        H4 = 1
        L1 = 5
        L2 = 0
        L3 = 0
        L4 = 0
        H = 32
        W = 32
        While Rendu.IsOpen And Me.Visible
            System.Windows.Forms.Application.DoEvents()
            'Rendu.Clear(New Color(0, 0, 0))
            Framerate = Math.Floor(1 / Stopwatch.GetTimestamp())
            Stopwatch.StartNew()
            forme.AddPoint(New Vector2f(0, 0), New Color(L1, L1 / 5 * 2, L1 / 6 * 4))
            forme.AddPoint(New Vector2f(0, 250), New Color(L1 / 6 * 4, L1, L1 / 6 * 4))
            forme.AddPoint(New Vector2f(250, 250), New Color(L1 / 12 * 5, L1 / 8 * 2, L1 / 6 * 4))
            forme.AddPoint(New Vector2f(250, 0), New Color(L1 / 3, L1 / 2, L1))
            forme.AddPoint(New Vector2f(0, 0), New Color(L1, L1 / 5 * 2, L1 / 6 * 4))
            Rendu.Draw(forme)
            S.Position = New Vector2f(32, 32)
            [color=red]S.SubRect = New IntRect(H1, 0, H2, 32)[/color]
            S.Color = New Color(0, 0, 0, 127)
            S.Position = New Vector2f(36, 35)
            S.Rotation = -10
            [color=red]S.Height = H * 2 / 3
            S.Width = S.Height * W / H[/color]
            Rendu.Draw(S)
            S.Position = New Vector2f(32, 32)
            S.Color = New Color(255, 255, 255, 255)
            S.Rotation = 0
            [color=red]S.Height = H[/color]
            Rendu.Draw(S)
            Rendu.Display()
            Tick = Environment.TickCount And Int32.MaxValue
            Tick2 = Tick
            Me.Text = Framerate.ToString + " FPS"

            If L1 < 256 And L1 > -1 Then
                If L1 = 255 Then
                    L4 = 1
                End If
                If L1 = 0 Then
                    L4 = 0
                End If
                If L4 = 0 Then
                    L1 = L1 + 1
                End If
                If L4 = 1 Then
                    L1 = L1 - 1
                End If
            End If
            If Tick2(6) = "2" And BoolR = True Or Tick2(6) = "7" And BoolR = True Then
                BoolR = False
                H4 = H4 + 1
                If H4 = 10 Then
                    H4 = 0
                End If
                If H1 = 0 Then
                    H1 = 32
                    H2 = 64
                ElseIf H1 = 32 And H3 = 1 Then
                    H1 = 64
                    H2 = 96
                    H3 = 0
                ElseIf H1 = 64 Then
                    H1 = 32
                    H2 = 64
                ElseIf H1 = 32 And H3 = 0 Then
                    H1 = 0
                    H2 = 32
                    H3 = 1
                End If
            ElseIf Tick2(6) = "3" And BoolR = False Or Tick2(6) = "8" And BoolR = False Then
                BoolR = True
            End If
[color=red]            forme.Dispose()
            forme = New Shape()
            S.Dispose()
            S = New Sprite(I2)[/color]
        End While
        Musics.Stop()
        forme.Dispose()
        S.Dispose()
        Musics.Dispose()
        arial.Dispose()
        I2.Dispose()
        Rendu.Dispose()
    End Sub
End Class

Avec pas mal d'erreur sur les Shape et les Sprite (Shape = inexistant, par quoi remplacer ? Vertex: des fonctions ne sont pas possibles)(Sprite = Don't understand anything)

Merci d'avance
« Modifié: Juin 26, 2012, 10:08:05 pm par Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : Passage de 1.6 à 2.0: erreur
« Réponse #1 le: Juin 26, 2012, 09:15:03 pm »
Regarde la doc C++ en ligne, ou bien génère la doc .Net. Tu peux aussi regarder les exemples C++ fournis avec le SDK. Ou bien attend les tutoriels si tu n'y arrives vraiment pas.
Laurent Gomila - SFML developer