Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Progressive 4 frame + idle character animation


pastornater
 Share

Recommended Posts

So I have been pickin apart the source to see how the player anims work and I found that in the 4 frame animation type the player cycles through frames 2 and 4 with the potential to stop on either 1 or 3\. I have been trying some different tweaks and I can't seem to get it to cycle progressively through frames 1,2,3,4 yet not stopping on any of those but stop on 5\. I got it to easily stop on 5 but then the walk order is 2,5,4,5, etc. Any ideas thanks?

Btw I'm at work so I'm unable to post my code untill later
Link to comment
Share on other sites

Ok here's my code. I almost have it working Except the animation is always flickering the Idle player frame in between the walk animation frames,

Example Of what i want, numbers are character animation frames from left to Right.

Not moving: 1

Moving: 2, 3, 4, 5, 2, 3, 4, 5…

This is what I get:

Not moving 1

Moving 2, quick 1, 3, quick 1, 4, etc

All of This is Client Side

This is Under ModGraphics:

>! Public Sub DrawPlayer(ByVal Index As Long)
>! Dim anim As Byte, i As Long, x As Long, y As Long
>! Dim Sprite As Long, spritetop As Long
>! Dim rec As RECT
>! Dim attackspeed As Long
>! ' If debug mode, handle error then exit out
>! If Options.Debug = 1 Then On Error GoTo errorhandler
>! Sprite = GetPlayerSprite(Index)
>! If Sprite < 1 Or Sprite > NumCharacters Then Exit Sub
>! ' speed from weapon
>! If GetPlayerEquipment(Index, Weapon) > 0 Then
>! attackspeed = Item(GetPlayerEquipment(Index, Weapon)).speed
>! Else
>! attackspeed = 1000
>! End If
>! If VXFRAME = False Then
>! ' Reset frame
>! ' If Player(Index).Step = 3 Then
>! ' anim = 0
>! ' ElseIf Player(Index).Step = 1 Then
>! ' anim = 2
>! ' End If
>! ' anim = Player(Index).Step
>! ' Resets Character to Pose Frame when not moving
>! If DirUp = False And DirDown = False And DirLeft = False And DirRight = False And Player(Index).Moving = 0 Then
>! Player(Index).Step = 0
>! ElseIf Player(Index).Moving > 0 And Player(Index).Step = 0 Then ' This makes character play next animation frame immediately when you press key.
>! Player(Index).Step = 1
>! anim = 1
>! End If
>! Else
>! anim = 1
>! End If
>! ' Check for attacking animation
>! If Player(Index).AttackTimer + (attackspeed / 2) > GetTickCount Then
>! If Player(Index).Attacking = 1 Then
>! If VXFRAME = False Then
>! anim = 5
>! Else
>! anim = 2
>! End If
>! End If
>! Else
>! ' If not attacking, walk normally
>! Select Case GetPlayerDir(Index)
>! Case DIR_UP
>! If (Player(Index).yOffset > 8) Then anim = Player(Index).Step
>! Case DIR_DOWN
>! If (Player(Index).yOffset < -8) Then anim = Player(Index).Step
>! Case DIR_LEFT
>! If (Player(Index).xOffset > 8) Then anim = Player(Index).Step
>! Case DIR_RIGHT
>! If (Player(Index).xOffset < -8) Then anim = Player(Index).Step
>! End Select
>! End If
>! ' Check to see if we want to stop making him attack
>! With Player(Index)
>! If .AttackTimer + attackspeed < GetTickCount Then
>! .Attacking = 0
>! .AttackTimer = 0
>! End If
>! End With
>! ' Set the left
>! Select Case GetPlayerDir(Index)
>! Case DIR_UP
>! spritetop = 3
>! Case DIR_RIGHT
>! spritetop = 2
>! Case DIR_DOWN
>! spritetop = 0
>! Case DIR_LEFT
>! spritetop = 1
>! End Select
>! With rec
>! .Top = spritetop * (Tex_Character(Sprite).Height / 4)
>! .Bottom = .Top + (Tex_Character(Sprite).Height / 4)
>! If VXFRAME = False Then
>! .Left = anim * (Tex_Character(Sprite).Width / 8)
>! .Right = .Left + (Tex_Character(Sprite).Width / 8)
>! Else
>! .Left = anim * (Tex_Character(Sprite).Width / 3)
>! .Right = .Left + (Tex_Character(Sprite).Width / 3)
>! End If
>! End With
>! ' Calculate the X
>! If VXFRAME = False Then
>! x = GetPlayerX(Index) * PIC_X + Player(Index).xOffset - ((Tex_Character(Sprite).Width / 5 - 32) / 2)
>! Else
>! x = GetPlayerX(Index) * PIC_X + Player(Index).xOffset - ((Tex_Character(Sprite).Width / 3 - 32) / 2)
>! End If
>! ' Is the player's height more than 32..?
>! If (Tex_Character(Sprite).Height) > 32 Then
>! ' Create a 32 pixel offset for larger sprites
>! y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset - ((Tex_Character(Sprite).Height / 4) - 32)
>! Else
>! ' Proceed as normal
>! y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset
>! End If
>! ' render player shadow
>! RenderTexture Tex_Shadow, ConvertMapX(x + 32), ConvertMapY(y + 18), 0, 0, 32, 32, 32, 32, D3DColorRGBA(255, 255, 255, 200)
>! ' render the actual sprite
>! If GetTickCount > Player(Index).StartFlash Then
>! Call DrawSprite(Sprite, x, y, rec)
>! Player(Index).StartFlash = 0
>! Else
>! Call DrawSprite(Sprite, x, y, rec, True)
>! End If
>! ' check for paperdolling
>! For i = 1 To UBound(PaperdollOrder)
>! If GetPlayerEquipment(Index, PaperdollOrder(i)) > 0 Then
>! If Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll > 0 Then
>! Call DrawPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, anim, spritetop)
>! End If
>! End If
>! Next
>! ' Error handler
>! Exit Sub
>! errorhandler:
>! HandleError "DrawPlayer", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext
>! Err.Clear
>! Exit Sub
>! End Sub

This is the other Sub I edited. It is Under ModGameLogic:

>! Sub ProcessMovement(ByVal Index As Long)
>! Dim MovementSpeed As Long
>! ' If debug mode, handle error then exit out
>! If Options.Debug = 1 Then On Error GoTo errorhandler
>! ' Check if player is walking, and if so process moving them over
>! Select Case Player(Index).Moving
>! Case MOVING_WALKING: MovementSpeed = ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))
>! Case MOVING_RUNNING: MovementSpeed = ((ElapsedTime / 1000) * (RUN_SPEED * SIZE_X))
>! Case Else: Exit Sub
>! End Select
>! Select Case GetPlayerDir(Index)
>! Case DIR_UP
>! Player(Index).yOffset = Player(Index).yOffset - MovementSpeed
>! If Player(Index).yOffset < 0 Then Player(Index).yOffset = 0
>! Case DIR_DOWN
>! Player(Index).yOffset = Player(Index).yOffset + MovementSpeed
>! If Player(Index).yOffset > 0 Then Player(Index).yOffset = 0
>! Case DIR_LEFT
>! Player(Index).xOffset = Player(Index).xOffset - MovementSpeed
>! If Player(Index).xOffset < 0 Then Player(Index).xOffset = 0
>! Case DIR_RIGHT
>! Player(Index).xOffset = Player(Index).xOffset + MovementSpeed
>! If Player(Index).xOffset > 0 Then Player(Index).xOffset = 0
>! End Select
>! ' Check if completed walking over to the next tile
>! If Player(Index).Moving > 0 Then
>! If GetPlayerDir(Index) = DIR_RIGHT Or GetPlayerDir(Index) = DIR_DOWN Then
>! If (Player(Index).xOffset >= 0) And (Player(Index).yOffset >= 0) Then
>! Player(Index).Moving = 0
>! If VXFRAME = False Then
>! If Player(Index).Step = 4 Then ' Cycles progressive 4 frame animation
>! Player(Index).Step = 1
>! Else: Player(Index).Step = Player(Index).Step + 1
>! End If
>! ' Player(Index).Moving = 0
>! Else
>! If Player(Index).Step = 0 Then
>! Player(Index).Step = 2
>! Else
>! Player(Index).Step = 0
>! End If
>! End If
>! End If
>! Else
>! If (Player(Index).xOffset <= 0) And (Player(Index).yOffset <= 0) Then
>! Player(Index).Moving = 0
>! If VXFRAME = False Then
>! If Player(Index).Step = 4 Then
>! Player(Index).Step = 1
>! Else: Player(Index).Step = Player(Index).Step + 1
>! End If
>! ' Player(Index).Moving = 0
>! Else
>! If Player(Index).Step = 0 Then
>! Player(Index).Step = 2
>! Else
>! Player(Index).Step = 0
>! End If
>! End If
>! End If
>! End If
>! ' Else: Player(Index).Moving = 0
>! End If
>! ' Error handler
>! Exit Sub
>! errorhandler:
>! HandleError "ProcessMovement", "modGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext
>! Err.Clear
>! Exit Sub
>! End Sub
>! Sub ProcessNpcMovement(ByVal MapNpcNum As Long)
>! ' If debug mode, handle error then exit out
>! If Options.Debug = 1 Then On Error GoTo errorhandler
>! ' Check if NPC is walking, and if so process moving them over
>! If MapNpc(MapNpcNum).Moving = MOVING_WALKING Then
>! Select Case MapNpc(MapNpcNum).Dir
>! Case DIR_UP
>! MapNpc(MapNpcNum).yOffset = MapNpc(MapNpcNum).yOffset - ((ElapsedTime / 1000) * (Npc(MapNpc(MapNpcNum).num).speed * SIZE_X))
>! If MapNpc(MapNpcNum).yOffset < 0 Then MapNpc(MapNpcNum).yOffset = 0
>! Case DIR_DOWN
>! MapNpc(MapNpcNum).yOffset = MapNpc(MapNpcNum).yOffset + ((ElapsedTime / 1000) * (Npc(MapNpc(MapNpcNum).num).speed * SIZE_X))
>! If MapNpc(MapNpcNum).yOffset > 0 Then MapNpc(MapNpcNum).yOffset = 0
>! Case DIR_LEFT
>! MapNpc(MapNpcNum).xOffset = MapNpc(MapNpcNum).xOffset - ((ElapsedTime / 1000) * (Npc(MapNpc(MapNpcNum).num).speed * SIZE_X))
>! If MapNpc(MapNpcNum).xOffset < 0 Then MapNpc(MapNpcNum).xOffset = 0
>! Case DIR_RIGHT
>! MapNpc(MapNpcNum).xOffset = MapNpc(MapNpcNum).xOffset + ((ElapsedTime / 1000) * (Npc(MapNpc(MapNpcNum).num).speed * SIZE_X))
>! If MapNpc(MapNpcNum).xOffset > 0 Then MapNpc(MapNpcNum).xOffset = 0
>! End Select
>! ' Check if completed walking over to the next tile
>! If MapNpc(MapNpcNum).Moving > 0 Then
>! If MapNpc(MapNpcNum).Dir = DIR_RIGHT Or MapNpc(MapNpcNum).Dir = DIR_DOWN Then
>! If (MapNpc(MapNpcNum).xOffset >= 0) And (MapNpc(MapNpcNum).yOffset >= 0) Then
>! MapNpc(MapNpcNum).Moving = 0
>! If VXFRAME = False Then
>! If MapNpc(MapNpcNum).Step = 1 Then
>! MapNpc(MapNpcNum).Step = 3
>! Else
>! MapNpc(MapNpcNum).Step = 1
>! End If
>! Else
>! If MapNpc(MapNpcNum).Step = 0 Then
>! MapNpc(MapNpcNum).Step = 2
>! Else
>! MapNpc(MapNpcNum).Step = 0
>! End If
>! End If
>! End If
>! Else
>! If (MapNpc(MapNpcNum).xOffset <= 0) And (MapNpc(MapNpcNum).yOffset <= 0) Then
>! MapNpc(MapNpcNum).Moving = 0
>! If VXFRAME = False Then
>! If MapNpc(MapNpcNum).Step = 1 Then
>! MapNpc(MapNpcNum).Step = 3
>! Else
>! MapNpc(MapNpcNum).Step = 1
>! End If
>! Else
>! If MapNpc(MapNpcNum).Step = 0 Then
>! MapNpc(MapNpcNum).Step = 2
>! Else
>! MapNpc(MapNpcNum).Step = 0
>! End If
>! End If
>! End If
>! End If
>! End If
>! End If
>! ' Error handler
>! Exit Sub
>! errorhandler:
>! HandleError "ProcessNpcMovement", "modGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext
>! Err.Clear
>! Exit Sub
>! End Sub

Thanks for looking. Not Sure why formatting disappeared in the spoiler drop downs…
Link to comment
Share on other sites

I only changed DrawPlayer lol '-'

Just put:

If Player(MyIndex).Moving = 0 then

Anim = 0

under the

If VXFRAME = False Then

' Reset frame

' If Player(Index).Step = 3 Then

' anim = 0

' ElseIf Player(Index).Step = 1 Then

' anim = 2

' End If

thing

Nvm, dont read dthe idle part on the title lol ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)
Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...