Buenas, aqui pongo un poco mejor, el codigo.
Acabo de intentarlo con variables de tipo single, pero se pierde demasaiada precision, y necesito q sea todo exacto. Y Speed es una variable, no una constante, ya que puede variar dependiendo unas cosas.
Timer
Private Sub tmrMove_Timer()
nx = posX[CODE]
ny = posY
With m_Input
If actMov = D_NONE Then
If (.Key(Key_RControl)) Or (.Key(Key_LControl)) Then
If .Key(Key_Left) Then
Look = Act_Look + L_WEST
ElseIf .Key(Key_Right) Then
Look = Act_Look + L_EAST
ElseIf .Key(Key_Down) Then
Look = Act_Look + L_SOUTH
ElseIf .Key(Key_Up) Then
Look = Act_Look + L_NORTH
End If
Else
If .Key(Key_Left) Then
Look = Act_Look + L_WEST
actMov = D_WEST
Call GetTile(D_WEST)
ElseIf .Key(Key_Right) Then
Look = Act_Look + L_EAST
actMov = D_EAST
Call GetTile(D_EAST)
ElseIf .Key(Key_Down) Then
actMov = D_SOUTH
Look = Act_Look + L_SOUTH
Call GetTile(D_SOUTH)
ElseIf .Key(Key_Up) Then
Look = Act_Look + L_NORTH
actMov = D_NORTH
Call GetTile(D_NORTH)
End If
End If
Else
lastMov = actMov
Call GetTile(D_LAST)
End If
End With
End Sub
El timer llama al procedimiento GetTile() q solo hace unas comprobaciones y llama a Walk()
Estas son las variables
Public actMov As Integer
Public lastMov As Integer
Public Speed As Double
Public Movement As Double
Public posX As Double
Public posY As Double
Public Sub Walk(Direction As Integer)
Select Case Direction
Case D_NORTH
posY = posY - Speed
Movement = Movement + Speed
Case D_SOUTH
posY = posY + Speed
Movement = Movement + Speed
Case D_EAST
posX = posX + Speed
Movement = Movement + Speed
Case D_WEST
posX = posX - Speed
Movement = Movement + Speed
Case D_LAST
Select Case lastMov
Case D_NORTH
If 1 = Int(Movement) Then
Movement = 0
actMov = D_NONE
lastMov = D_NONE
Look = Act_Look + L_NORTH
ElseIf Movement = 0.3 Then
Look = Act_Look + L_NORTH + 1
posY = posY - Speed
Movement = Movement + Speed
ElseIf Movement = 0.3 Then
Look = Act_Look + L_NORTH + 2
posY = posY - Speed
Movement = Movement + Speed
Else
posY = posY - Speed
Movement = Movement + Speed
End If
Case D_SOUTH
If 1 = Int(Movement) Then
Movement = 0
actMov = D_NONE
lastMov = D_NONE
Look = Act_Look + L_SOUTH
ElseIf Movement = 0.3 Then
Look = Act_Look + L_SOUTH + 1
posY = posY + Speed
Movement = Movement + Speed
ElseIf Movement = 0.6 Then
Look = Act_Look + L_SOUTH + 2
posY = posY + Speed
Movement = Movement + Speed
Else
posY = posY + Speed
Movement = Movement + Speed
End If
Case D_EAST
If 1 = Int(Movement) Then
Movement = 0
actMov = D_NONE
lastMov = D_NONE
Look = Act_Look + L_EAST
ElseIf Movement = 0.3 Then
Look = Act_Look + L_EAST + 1
posX = posX + Speed
Movement = Movement + Speed
ElseIf Movement = 0.6 Then
Look = Act_Look + L_EAST + 2
posX = posX + Speed
Movement = Movement + Speed
Else
posX = posX + Speed
Movement = Movement + Speed
End If
Case D_WEST
If 1 = Int(Movement) Then
Movement = 0
actMov = D_NONE
lastMov = D_NONE
Look = Act_Look + L_WEST
ElseIf Movement = 0.3 Then
Look = Act_Look + L_WEST + 1
posX = posX - Speed
Movement = Movement + Speed
ElseIf Movement = 0.6 Then
Look = Act_Look + L_WEST + 2
posX = posX - Speed
Movement = Movement + Speed
Else
posX = posX - Speed
Movement = Movement + Speed
End If
End Select
End Select
Debug.Print Movement
End Sub
Los 0.3 y 0.6 en realidad son variables q dependen de speed, pero no hace ninguna diferencia.
Bueno, espero no se haga muy engorroso. Aver si alguien tiene idea q error estoy cometiendo.
En cuanto al valor de Movement lo imprimo directamente en la ventana inmediato, como tipo double y aparece "1" asique no creo q sea ese el problema
Bueno, eso es todo, gracias desde ya.
Saludos