Hi, I have the following program and it works fine. I have a couple of questions because I'm not an expert at this.
If you run the program (I attached the images), you will see that it moves faster to the left than to the right. I did that on purpose. My first question is -> If you look close, the motion kind of stutters or there are tiny steps where it jumps. Would this be super smooth if I implement Frame Independent movement?
My second question is -> Can someone show me an example of how I can use a sprite sheet. I would like to make the character walk to the left and right.
Bonus question -> Where can I find info on frame independent movement in VB .net - C++ code is ok with me too, but .NET uses different timing devices, so I'm not sure where to start.
Don't forget to change the file paths.
Imports SFML
Imports SFML
.WindowImports SFML
.GraphicsImports System
.DrawingModule Module1
Dim WithEvents window
As RenderWindow
Sub Main
() Dim contextSettings
As New ContextSettings
contextSettings
.DepthBits = 32 window
= New RenderWindow
(New VideoMode
(800,
600),
"Learning SFML", Styles
.Default, contextSettings
) window
.SetVerticalSyncEnabled(True) Dim myTexture
As New Texture
("c:\pics\bg.png") Dim myTexture2
As New Texture
("c:\pics\char123.gif") Dim mySprite
As New Sprite
Dim mySprite2
As New Sprite
mySprite
.Texture = myTexture
mySprite2
.Texture = myTexture2
Dim b
As Boolean = False Dim r
As New Single r
= 0
.1F
mySprite2
.Origin = New Vector2f
(myTexture2
.Size.X / 2, myTexture2
.Size.Y / 2) Dim n
As Integer = 100 While window
.IsOpen window
.DispatchEvents() window
.Clear() mySprite
.Position = New Vector2f
(0,
0) mySprite2
.Position = New Vector2f
(n,
320) mySprite2
.Rotation = r
window
.Draw(mySprite
) r
+= 0.5 If b
= False Then n
+= 2 Else n
-= 1 End If If n
= 50 Then b
= False If n
= 750 Then b
= True window
.Draw(mySprite2
) window
.Display() End While End Sub Sub App_Closed
(sender
As Object, e
As EventArgs
) Handles window
.Closed Dim window
= CType(sender, RenderWindow
) window
.Close() End SubEnd Module