Print Page | Close Window

Multiple Map Animations

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=150
Printed Date: 20 December 2006 at 5:52pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Multiple Map Animations
Posted By: Sync
Subject: Multiple Map Animations
Date Posted: 11 February 2006 at 3:08pm
Difficulty: Hard 5/5

Originaly Posted By: Deuxexemachina

This one's from me guys. Not a tutorial, just code. I'll take some questions if it comes down to it.  Obviously, the extra layers need to be added.

Replace the normal blttile with this one, assuming you've made no other changes..

Sub BltTile(ByVal X As Long, ByVal Y As Long)
Dim Ground As Long
Dim Anim1 As Long
Dim Anim2 As Long
Dim Anim3 As Long

Ground = Map.Tile(X, Y).Ground
Anim1 = Map.Tile(X, Y).Mask
Anim2 = Map.Tile(X, Y).Anim
Anim3 = Map.Tile(X, Y).Anim2

' Only used if ever want to switch to blt rather then bltfast
With rec_pos
.top = Y * PIC_Y
.Bottom = .top + PIC_Y
.Left = X * PIC_X
.Right = .Left + PIC_X
End With

rec.top = Int(Ground / 14) * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (Ground - Int(Ground / 14) * 14) * PIC_X
rec.Right = rec.Left + PIC_X
'Call DD_BackBuffer.Blt(rec_pos, DD_TileSurf, rec, DDBLT_WAIT)
Call DD_BackBuffer.BltFast(X * PIC_X, Y * PIC_Y, DD_TileSurf, rec, DDBLTFAST_WAIT)

If (MapAnim = 0) Or (Anim2 <= 0) Then
' Is there an animation tile to plot?
If Anim1 >= 0 And TempTile(X, Y).DoorOpen = NO Then
rec.top = Int(Anim1 / 14) * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (Anim1 - Int(Anim1 / 14) * 14) * PIC_X
rec.Right = rec.Left + PIC_X
'Call DD_BackBuffer.Blt(rec_pos, DD_TileSurf, rec, DDBLT_WAIT Or DDBLT_KEYSRC)
Call DD_BackBuffer.BltFast(X * PIC_X, Y * PIC_Y, DD_TileSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
If (MapAnim = 1) Or (MapAnim = 3) Then
' Is there a second animation tile to plot?
If Anim2 >= 0 Then
rec.top = Int(Anim2 / 14) * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (Anim2 - Int(Anim2 / 14) * 14) * PIC_X
rec.Right = rec.Left + PIC_X
'Call DD_BackBuffer.Blt(rec_pos, DD_TileSurf, rec, DDBLT_WAIT Or DDBLT_KEYSRC)
Call DD_BackBuffer.BltFast(X * PIC_X, Y * PIC_Y, DD_TileSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
' Is there a third animation tile to plot?
If (MapAnim = 2) Then
If Anim3 > 0 Then
rec.top = Int(Anim3 / 14) * PIC_Y
rec.Bottom = rec.top + PIC_Y
rec.Left = (Anim3 - Int(Anim3 / 14) * 14) * PIC_X
rec.Right = rec.Left + PIC_X
'Call DD_BackBuffer.Blt(rec_pos, DD_TileSurf, rec, DDBLT_WAIT Or DDBLT_KEYSRC)
Call DD_BackBuffer.BltFast(X * PIC_X, Y * PIC_Y, DD_TileSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End If
End Sub

and this into your loop..

Call MapTimer

and this in modgame logic any old place.

Sub MapTimer()
If GetTickCount > MapAnimTimer + 250 Then
MapAnim = (MapAnim + 1) Mod 4
MapAnimTimer = GetTickCount
End If
End Sub

Here's the break down. Basically, every loop it checks to see the get tick counts like everything else. It keeps adding up until it hits 3 and then it resets to 0. The map animation code in bltTile checks these numbers- 0 is mask, 1 is your normal anim layer, 2 is your new one, then 3 is your normal one again, etc, etc. This is also how I achieved the multi-picture walk animations. A similar code, albeit using a timer instead of the loop, is used in my sprite animator. One of my more requested codes. If there's anything left out you can ask, but for the most part everything is here. Understand you only need to add one more animation layer, not one for all of them. Read the code and you'll figure it out. Its simple enough.



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info