From 5b7a6fc9ab8a8b57e626aea4e197846f0326d838 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sat, 8 Jan 2022 18:00:05 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20Overworld=20Pok=C3=A9mon=20texture=20an?= =?UTF-8?q?imations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- P3D/Entites/Other/NetworkPlayer.vb | 14 +++++----- P3D/Entites/Other/NetworkPokemon.vb | 37 +++++++++++++++++---------- P3D/Entites/Other/OverworldPokemon.vb | 33 +++++++++++------------- P3D/Entites/Other/OwnPlayer.vb | 14 +++++----- 4 files changed, 50 insertions(+), 48 deletions(-) diff --git a/P3D/Entites/Other/NetworkPlayer.vb b/P3D/Entites/Other/NetworkPlayer.vb index 2a86a7e1c..0828b2ffe 100644 --- a/P3D/Entites/Other/NetworkPlayer.vb +++ b/P3D/Entites/Other/NetworkPlayer.vb @@ -165,6 +165,10 @@ Return 0 Case 2 Return 1 + Case 3 + Return 0 + Case 4 + Return 1 End Select ElseIf Me.Texture.Width = Me.Texture.Height Then Select Case AnimationX @@ -198,14 +202,8 @@ If Me.AnimationDelay <= 0.0F Then Me.AnimationDelay = AnimationDelayLength AnimationX += 1 - If Me.Texture.Width = Me.Texture.Height / 2 Then - If AnimationX > 2 Then - AnimationX = 1 - End If - Else - If AnimationX > 4 Then - AnimationX = 1 - End If + If AnimationX > 4 Then + AnimationX = 1 End If End If End If diff --git a/P3D/Entites/Other/NetworkPokemon.vb b/P3D/Entites/Other/NetworkPokemon.vb index 97a7174f0..9682b7ec9 100644 --- a/P3D/Entites/Other/NetworkPokemon.vb +++ b/P3D/Entites/Other/NetworkPokemon.vb @@ -6,13 +6,14 @@ Public LevelFile As String = "" Public PokemonTexture As String = "" Public faceRotation As Integer = 0 + Dim Moving As Boolean = False Dim Texture As Texture2D Dim lastRectangle As New Rectangle(0, 0, 0, 0) Dim loadedTexture As String = "" Dim AnimationX As Integer = 1 - Dim AnimationDelayLength As Single = 2.2F + Dim AnimationDelayLength As Single = 1.1F Dim AnimationDelay As Single = AnimationDelayLength Public Sub New(ByVal pos As Vector3, ByVal PokemonTexture As String, ByVal visible As Boolean) @@ -51,22 +52,26 @@ If Me.PokemonTexture <> "" Then Me.ChangeTexture() - - Me.AnimationDelay -= 0.1F - If AnimationDelay <= 0.0F Then - AnimationX += 1 - 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 Moving = True Then + Me.AnimationDelay -= 0.1F + If AnimationDelay <= 0.0F Then + AnimationX += 1 + AnimationDelay = AnimationDelayLength If AnimationX > 4 Then AnimationX = 1 End If + End If + Else + If Me.Texture.Width = Me.Texture.Height Then + AnimationX = 1 Else - If AnimationX > 3 Then - AnimationX = 1 + Me.AnimationDelay -= 0.1F + If AnimationDelay <= 0.0F Then + AnimationX += 1 + AnimationDelay = 2.2F + If AnimationX > 4 Then + AnimationX = 1 + End If End If End If End If @@ -160,6 +165,10 @@ Return 0 Case 2 Return 1 + Case 3 + Return 0 + Case 4 + Return 1 End Select ElseIf Me.Texture.Width = Me.Texture.Height Then Select Case AnimationX @@ -197,7 +206,7 @@ Public Sub ApplyPlayerData(ByVal p As Servers.Player) Try Me.PlayerID = p.ServersID - + Me.Moving = p.Moving Me.PokemonTexture = p.PokemonSkin Me.Position = p.PokemonPosition Me.LevelFile = p.LevelFile diff --git a/P3D/Entites/Other/OverworldPokemon.vb b/P3D/Entites/Other/OverworldPokemon.vb index 7a8ba86b8..6cd0fe9e1 100644 --- a/P3D/Entites/Other/OverworldPokemon.vb +++ b/P3D/Entites/Other/OverworldPokemon.vb @@ -40,7 +40,6 @@ Public Class OverworldPokemon Me.Texture = PokemonReference.GetOverworldTexture() End If - Dim cameraRotation As Integer = Screen.Camera.GetFacingDirection() Dim spriteIndex As Integer = Me.faceRotation - cameraRotation @@ -96,18 +95,8 @@ Public Class OverworldPokemon If AnimationDelay <= 0.0F Then AnimationX += 1 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 - AnimationX = 1 - End If - Else - If AnimationX > 3 Then - AnimationX = 1 - End If + If AnimationX > 4 Then + AnimationX = 1 End If End If Else @@ -183,15 +172,19 @@ Public Class OverworldPokemon 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 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 End If Else - Me.AnimationDelayLength = 1.1F - If Me.Texture.Width = Me.Texture.Height / 2 Then - Me.Moving = True - Else + Me.AnimationDelayLength = 2.2F + If Me.Texture.Width = Me.Texture.Height Then Me.Moving = False + Else + Me.Moving = True End If End If End Sub @@ -310,6 +303,10 @@ Public Class OverworldPokemon Return 0 Case 2 Return 1 + Case 3 + Return 0 + Case 4 + Return 1 End Select ElseIf Me.Texture.Width = Me.Texture.Height Then Select Case AnimationX diff --git a/P3D/Entites/Other/OwnPlayer.vb b/P3D/Entites/Other/OwnPlayer.vb index ac4c506b0..94c74c9e3 100644 --- a/P3D/Entites/Other/OwnPlayer.vb +++ b/P3D/Entites/Other/OwnPlayer.vb @@ -90,14 +90,8 @@ If AnimationDelay <= 0.0F Then AnimationDelay = GetAnimationDelay() AnimationX += 1 - If Me.Texture.Width = Me.Texture.Height / 2 Then - If AnimationX > 2 Then - AnimationX = 1 - End If - Else - If AnimationX > 4 Then - AnimationX = 1 - End If + If AnimationX > 4 Then + AnimationX = 1 End If End If Else @@ -164,6 +158,10 @@ Return 0 Case 2 Return 1 + Case 3 + Return 0 + Case 4 + Return 1 End Select ElseIf Me.Texture.Width = Me.Texture.Height Then Select Case AnimationX