Fixed Overworld Pokémon texture animations

Pokémon textures with 3 and 4 frames work better now
When the player is running, the Pokémon animates faster
When a (network) player is standing still, the Pokémon animates slower (unless the Pokémon texture has 4 frames, then it stops at the first frame)
Cleaned up the code a little
This commit is contained in:
JappaWakka 2022-01-08 18:00:05 +01:00
parent c116f30c6b
commit 5b7a6fc9ab
4 changed files with 50 additions and 48 deletions

View File

@ -165,6 +165,10 @@
Return 0 Return 0
Case 2 Case 2
Return 1 Return 1
Case 3
Return 0
Case 4
Return 1
End Select End Select
ElseIf Me.Texture.Width = Me.Texture.Height Then ElseIf Me.Texture.Width = Me.Texture.Height Then
Select Case AnimationX Select Case AnimationX
@ -198,14 +202,8 @@
If Me.AnimationDelay <= 0.0F Then If Me.AnimationDelay <= 0.0F Then
Me.AnimationDelay = AnimationDelayLength Me.AnimationDelay = AnimationDelayLength
AnimationX += 1 AnimationX += 1
If Me.Texture.Width = Me.Texture.Height / 2 Then If AnimationX > 4 Then
If AnimationX > 2 Then AnimationX = 1
AnimationX = 1
End If
Else
If AnimationX > 4 Then
AnimationX = 1
End If
End If End If
End If End If
End If End If

View File

@ -6,13 +6,14 @@
Public LevelFile As String = "" Public LevelFile As String = ""
Public PokemonTexture As String = "" Public PokemonTexture As String = ""
Public faceRotation As Integer = 0 Public faceRotation As Integer = 0
Dim Moving As Boolean = False
Dim Texture As Texture2D Dim Texture As Texture2D
Dim lastRectangle As New Rectangle(0, 0, 0, 0) Dim lastRectangle As New Rectangle(0, 0, 0, 0)
Dim loadedTexture As String = "" Dim loadedTexture As String = ""
Dim AnimationX As Integer = 1 Dim AnimationX As Integer = 1
Dim AnimationDelayLength As Single = 2.2F Dim AnimationDelayLength As Single = 1.1F
Dim AnimationDelay As Single = AnimationDelayLength Dim AnimationDelay As Single = AnimationDelayLength
Public Sub New(ByVal pos As Vector3, ByVal PokemonTexture As String, ByVal visible As Boolean) Public Sub New(ByVal pos As Vector3, ByVal PokemonTexture As String, ByVal visible As Boolean)
@ -51,22 +52,26 @@
If Me.PokemonTexture <> "" Then If Me.PokemonTexture <> "" Then
Me.ChangeTexture() Me.ChangeTexture()
If Moving = True Then
Me.AnimationDelay -= 0.1F Me.AnimationDelay -= 0.1F
If AnimationDelay <= 0.0F Then If AnimationDelay <= 0.0F Then
AnimationX += 1 AnimationX += 1
AnimationDelay = AnimationDelayLength AnimationDelay = AnimationDelayLength
If Me.Texture.Width = Me.Texture.Height / 2 Then
If AnimationX > 2 Then
AnimationX = 1
End If
ElseIf Me.Texture.Width = Me.Texture.Height Then
If AnimationX > 4 Then If AnimationX > 4 Then
AnimationX = 1 AnimationX = 1
End If End If
End If
Else
If Me.Texture.Width = Me.Texture.Height Then
AnimationX = 1
Else Else
If AnimationX > 3 Then Me.AnimationDelay -= 0.1F
AnimationX = 1 If AnimationDelay <= 0.0F Then
AnimationX += 1
AnimationDelay = 2.2F
If AnimationX > 4 Then
AnimationX = 1
End If
End If End If
End If End If
End If End If
@ -160,6 +165,10 @@
Return 0 Return 0
Case 2 Case 2
Return 1 Return 1
Case 3
Return 0
Case 4
Return 1
End Select End Select
ElseIf Me.Texture.Width = Me.Texture.Height Then ElseIf Me.Texture.Width = Me.Texture.Height Then
Select Case AnimationX Select Case AnimationX
@ -197,7 +206,7 @@
Public Sub ApplyPlayerData(ByVal p As Servers.Player) Public Sub ApplyPlayerData(ByVal p As Servers.Player)
Try Try
Me.PlayerID = p.ServersID Me.PlayerID = p.ServersID
Me.Moving = p.Moving
Me.PokemonTexture = p.PokemonSkin Me.PokemonTexture = p.PokemonSkin
Me.Position = p.PokemonPosition Me.Position = p.PokemonPosition
Me.LevelFile = p.LevelFile Me.LevelFile = p.LevelFile

View File

@ -40,7 +40,6 @@ Public Class OverworldPokemon
Me.Texture = PokemonReference.GetOverworldTexture() Me.Texture = PokemonReference.GetOverworldTexture()
End If End If
Dim cameraRotation As Integer = Screen.Camera.GetFacingDirection() Dim cameraRotation As Integer = Screen.Camera.GetFacingDirection()
Dim spriteIndex As Integer = Me.faceRotation - cameraRotation Dim spriteIndex As Integer = Me.faceRotation - cameraRotation
@ -96,18 +95,8 @@ Public Class OverworldPokemon
If AnimationDelay <= 0.0F Then If AnimationDelay <= 0.0F Then
AnimationX += 1 AnimationX += 1
AnimationDelay = AnimationDelayLength AnimationDelay = AnimationDelayLength
If Me.Texture.Width = Me.Texture.Height / 2 Then If AnimationX > 4 Then
If AnimationX > 2 Then AnimationX = 1
AnimationX = 1
End If
ElseIf Me.Texture.Width = Me.Texture.Height Then
If AnimationX > 4 Then
AnimationX = 1
End If
Else
If AnimationX > 3 Then
AnimationX = 1
End If
End If End If
End If End If
Else Else
@ -183,15 +172,19 @@ Public Class OverworldPokemon
If Screen.Camera.IsMoving() = True And Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then If Screen.Camera.IsMoving() = True And Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
If CInt(Me.Position.X) <> CInt(Screen.Camera.Position.X) Or CInt(Me.Position.Z) <> CInt(Screen.Camera.Position.Z) Then If CInt(Me.Position.X) <> CInt(Screen.Camera.Position.X) Or CInt(Me.Position.Z) <> CInt(Screen.Camera.Position.Z) Then
Me.Position += GetMove() Me.Position += GetMove()
Me.AnimationDelayLength = 1.1F If Core.Player.IsRunning = True Then
Me.AnimationDelayLength = 1.1F / 1.4F
Else
Me.AnimationDelayLength = 1.1F
End If
Me.Moving = True Me.Moving = True
End If End If
Else Else
Me.AnimationDelayLength = 1.1F Me.AnimationDelayLength = 2.2F
If Me.Texture.Width = Me.Texture.Height / 2 Then If Me.Texture.Width = Me.Texture.Height Then
Me.Moving = True
Else
Me.Moving = False Me.Moving = False
Else
Me.Moving = True
End If End If
End If End If
End Sub End Sub
@ -310,6 +303,10 @@ Public Class OverworldPokemon
Return 0 Return 0
Case 2 Case 2
Return 1 Return 1
Case 3
Return 0
Case 4
Return 1
End Select End Select
ElseIf Me.Texture.Width = Me.Texture.Height Then ElseIf Me.Texture.Width = Me.Texture.Height Then
Select Case AnimationX Select Case AnimationX

View File

@ -90,14 +90,8 @@
If AnimationDelay <= 0.0F Then If AnimationDelay <= 0.0F Then
AnimationDelay = GetAnimationDelay() AnimationDelay = GetAnimationDelay()
AnimationX += 1 AnimationX += 1
If Me.Texture.Width = Me.Texture.Height / 2 Then If AnimationX > 4 Then
If AnimationX > 2 Then AnimationX = 1
AnimationX = 1
End If
Else
If AnimationX > 4 Then
AnimationX = 1
End If
End If End If
End If End If
Else Else
@ -164,6 +158,10 @@
Return 0 Return 0
Case 2 Case 2
Return 1 Return 1
Case 3
Return 0
Case 4
Return 1
End Select End Select
ElseIf Me.Texture.Width = Me.Texture.Height Then ElseIf Me.Texture.Width = Me.Texture.Height Then
Select Case AnimationX Select Case AnimationX