DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[tutorial] Not another Animated Sprites tutorial!
Page 1 of 1
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:20 ago.

Topics: 163
Posts: 8194
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Nov 07, 2011 4:47 pm
   Subject: [tutorial] Not another Animated Sprites tutorial!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

This code has bits and pieces from just about everyone, including WSJ, BrotherTank, DarkOne ... the list goes on.

So what makes this tutorial different? Well, to change or expand the data for your animated sprites, you *don't* have to go into the middle of WL_DRAW.CPP to change things. Just go into an H file instead, and Rebuild the code.

So, let's get started. Go into WL_DRAW.CPP, and do a search for "static objects". You should see this code:

::: CODE :::
//
// place static objects
//

Insert this code just above it:
::: CODE :::
// Animated Objects code
    frameon+=tics;
    frameon%=2520;
    /* remember 70 tics/second, so this will support total cycle time of 2 seconds tops.  Just increase the 140 if you want*/
// End Animated Objects code

Now do a search for "visable". Yes, I know it's misspelled. I'm just telling you the way it's put it in the code. Smile Anyway, you should see this:
::: CODE :::
        if (!*statptr->visspot)
            continue;                                               // not visable

Now, insert this code just below it:
::: CODE :::
struct
{
    short      picnum;
    int        animtics, animframes;
} animsprinfo[] =
{
#include "_animatedstaticobjects.h"
    {-1}                                    // terminator
};

    for (int animstat = 0; animsprinfo[animstat].picnum != -1 ; animstat++)
    {
// Animated objects
    if (visptr->shapenum == animsprinfo[animstat].picnum)
                            visptr->shapenum += int((frameon/(animsprinfo[animstat].animtics))
                            %animsprinfo[animstat].animframes);
       }

What this code does is take all the Animated Sprites and puts them in an array, then goes through that array until it hits the "-1" end-marker. Does doing the code this way lower the framerate? Slightly, maybe. But it'll be easier to work with.

Now, create a text file called "_animatedstaticobjects.h". Note the "_" I put in the filename. This ensures that the file always appears at the top of your Project list.

In this example, I'm giving the file this content:
::: CODE :::
// Format: SprName, T, F
//
// If the sprite has the name of SprName, animate it using F frames total, and change the frame
// every T tics.  For example, if the object is called SPR_STAT_0, then the data
// "SPR_STAT_0, 6, 4" will have it uses 4 frames of animation, and the frame will change every 6
// tics.  70 "tics" is equal to one second.

    SPR_STAT_0,  6,  4,
    SPR_STAT_4, 12, 8,

Now save the file, and Add it to your project in the compiler. Now Rebuild your code, and run the EXE. The water puddle is animated with four frames of animation, and the frame is changed every 6 tics. The chandelier should use eight frames of animation, and the frame changes every 12 tics.

I think that should do it. Hope my tutorial proves useful. Smile
mallo
Registered User
Registered User


Joined: 12 Nov 2009
Last Visit: 23 Jan 2012

Topics: 4
Posts: 15
Location: Warszawa/Warsaw
poland.gif

PostPosted: Thu Jan 19, 2012 11:04 am
   Subject: Re: [tutorial] Not another Animated Sprites tutorial!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

How to make it work with directional 3d sprites?

_________________
MALLO GAMES!!!
Currently Working: SpongeBobStein, Wolf3d creator pack, Fantasy game on wolfenstein engine
In future: Friendship Ponystein
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:20 ago.

Topics: 163
Posts: 8194
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Thu Jan 19, 2012 6:36 pm
   Subject: Re: [tutorial] Not another Animated Sprites tutorial!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The same, if I'm not mistaken. Smile
mallo
Registered User
Registered User


Joined: 12 Nov 2009
Last Visit: 23 Jan 2012

Topics: 4
Posts: 15
Location: Warszawa/Warsaw
poland.gif

PostPosted: Thu Jan 19, 2012 11:44 pm
   Subject: Re: [tutorial] Not another Animated Sprites tutorial!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

No, it doesn't work for me.
Non-directional version animated, directional not.

_________________
MALLO GAMES!!!
Currently Working: SpongeBobStein, Wolf3d creator pack, Fantasy game on wolfenstein engine
In future: Friendship Ponystein
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:20 ago.

Topics: 163
Posts: 8194
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Fri Jan 20, 2012 4:19 pm
   Subject: Re: [tutorial] Not another Animated Sprites tutorial!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Okay; thanks for the bug report. Smile Thankfully, the MyMod4SDL engine uses this very same code to animate things, and I deliberately made adding new objects easier than in the original code. So I'm hoping I can resolve this problem without a great deal of trouble. Smile
mallo
Registered User
Registered User


Joined: 12 Nov 2009
Last Visit: 23 Jan 2012

Topics: 4
Posts: 15
Location: Warszawa/Warsaw
poland.gif

PostPosted: Sun Jan 22, 2012 12:36 pm
   Subject: Re: [tutorial] Not another Animated Sprites tutorial!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

No offense, but i asked:
mallo wrote:
How to make it work with directional 3d sprites?

_________________
MALLO GAMES!!!
Currently Working: SpongeBobStein, Wolf3d creator pack, Fantasy game on wolfenstein engine
In future: Friendship Ponystein
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:20 ago.

Topics: 163
Posts: 8194
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Jan 23, 2012 7:28 pm
   Subject: Re: [tutorial] Not another Animated Sprites tutorial!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Yes, I haven't figured it out yet. Smile
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 24559 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts [HELP] Different ammo types.
Author: Raziel
15 2311 Thu Jan 01, 2009 4:45 am
Raziel View latest post
No new posts [IDEA] Introducing the new "Haasboy Engine"
Author: Haasboy
2 1274 Fri Aug 01, 2008 10:37 am
dcbasic View latest post
No new posts [CODE] Health Shown as a message with full screen view
Author: Raziel
13 2797 Thu Jul 31, 2008 8:07 pm
Raziel View latest post
No new posts [Wolf4SDL Help] Inserting a second palette (like in SoD)
Author: Andy_Nonymous
10 3286 Mon Jun 02, 2008 3:59 pm
Adam Biser View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group