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] Animated Walls for SDL
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
insurrectionman
DieHard Mutant
DieHard Mutant


Joined: 07 May 2005
Last Visit: 17 Nov 2017

Topics: 85
Posts: 750
Location: Wisconsin
usa.gif

PostPosted: Sun Jun 21, 2009 11:03 am
   Subject: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

The original code given for animated walls does not work well for SDL version. This I tested and it does work. This will work without using any object, it is directly hard coded.

In wl_draw.cpp in both the HitVertWal and HitHorizWall functions just after this code:

::: CODE :::
if(lastside!=-1) ScalePost();

    lastside=0;
    lastintercept=ytile;
    lasttilehit=tilehit;
    lasttexture=texture;
    wallheight[pixx] = CalcHeight();


Add this:

::: CODE :::
switch (lasttilehit)
   {
   case 2: // on map wall ID is 2
   case 42: // on map wall ID is 42
      tilehit+=(frameon>>3)%4; // the 3 is speed, the 4 is frames
      break;
   }


That is all that there is. Any questions ask me.

_________________
I'm back! I missed this community!
Youtube Channel: TreeSapThief

New Site: http://www.treesapthief.com
Twitter: @treesapthief
Dean
Moderator
<B>Moderator</B>


Joined: 10 Jan 2006
Last Visit: 23 Oct 2016

Topics: 52
Posts: 2187
Location: Australia
australia.gif

PostPosted: Mon Jun 22, 2009 7:58 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Nice work Insurrectionman!

_________________
The Wolfenstein 3d Blog
The Wolfenstein 3d Blog is now on Facebook!

"Strong minds discuss ideas, average minds discuss events, weak minds discuss people" - Socrates
insurrectionman
DieHard Mutant
DieHard Mutant


Joined: 07 May 2005
Last Visit: 17 Nov 2017

Topics: 85
Posts: 750
Location: Wisconsin
usa.gif

PostPosted: Tue Jun 23, 2009 2:14 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yea, that took forever to figure out, I cannot say it is 100% perfect. It works in my game, the original code makes the tiles next to it animate, and others stop... wierd effects, so i had to figure a work around, and that seemed to do it.

_________________
I'm back! I missed this community!
Youtube Channel: TreeSapThief

New Site: http://www.treesapthief.com
Twitter: @treesapthief
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 8:49 ago.

Topics: 160
Posts: 7993
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Wed Jun 24, 2009 7:44 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You might consult BT's BunkerSDL source for bugfixes. Smile
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Sun Dec 18, 2016 6:46 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I've tried this code and it doesn't seem to be doing anything.

One of the last levels if Atomprojekt involves a reactor that you have to shut down. I want the reactor core area to have an animated texture. Once BJ flips all switches to power down the reactor, I want the texture to go static. Is this the best way to do this and what would be the best way to make the texture go static once all six switches have been thrown?

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 8:49 ago.

Topics: 160
Posts: 7993
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sun Dec 18, 2016 7:11 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I would enable two different types of animated walls, and then have the wall you're talking about change texture so that it follows a different animation cycle. Maybe it's not terribly efficient, but it's more likely to get results with a minimum of hassle. Smile
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sun Dec 18, 2016 7:23 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You could make it such that the frame you want to be static isn't the starting frame, and then change all the walls from the animated one to the non-animated one.
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Mon Dec 19, 2016 2:41 am
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

For whatever reason I am unable to seem to get my walls to animate at all with this code. I may just do animated sprites instead to have the same effect if I can't get it to work.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Mon Dec 19, 2016 9:27 am
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I noticed that in the DOS version, there is frameon++, but in Wolf4SDL there isn't. Maybe this was something that was removed after whatever version insurrectionman was using (Wolf4SDL 1.6?). Without that line added, frameon will probably always stay 0.
Aryan_Wolf3D
I am Death Incarnate
I am Death Incarnate


Joined: 21 Jul 2011
Last Visit: 20 Nov 2017

Topics: 6
Posts: 171

blank.gif

PostPosted: Mon Dec 19, 2016 12:22 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Barry

Perhaps this will help you: http://diehardwolfers.areyep.com/viewtopic.php?t=5481

It's for animated floors, but it also shows how to get "frameon" working again.

_________________
"Way too many #ifdefs in the code!" - John Carmack
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Mon Dec 19, 2016 7:05 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks for the assistance everyone! However, I went through the tutorial to get add "frameon" back to the code as well as added Chris' "frameon++" to wl_draw.cpp and my walls still will not animate.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Mon Dec 19, 2016 7:47 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Edit: Nevermind, I thought it might be related to NEWTILE_OFFSET because that was causing issues with my switches, but I tried the animation code with a lower wall value and animation is still not happening.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Dec 19, 2016 10:07 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Can you post your HitHorizWall function?
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Mon Dec 19, 2016 11:05 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
Can you post your HitHorizWall function?


I have decided to go with animated statics instead to have the same effect, which I have working.

Now I just need to figure out how to stop the animation after the six switches are thrown. I am thinking the best way is to replace the existing objects with a non-animated version, but I am not currently sure how to do that.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Dec 19, 2016 11:19 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

How does the animated static code choose which objects to animate?
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Mon Dec 19, 2016 11:32 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
How does the animated static code choose which objects to animate?


I used this tutorial, which does well.

http://diehardwolfers.areyep.com/viewtopic.php?t=6264

If I could replace the placed animated objects with another object (a non-animated version) it would work. Since this is only used in one room in one level, I can hard code it if need be. I've already done that with some walls in that level, changing the texture from a lit to non-lit version.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Dec 19, 2016 11:48 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ah, you could have it find the relevant objects and just replace their shapenum with a frame of their animation that isn't the first instead of sticking another object in their place, that would probably be less messy.
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Tue Dec 20, 2016 10:29 am
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
Ah, you could have it find the relevant objects and just replace their shapenum with a frame of their animation that isn't the first instead of sticking another object in their place, that would probably be less messy.


I'll try just making the animation code conditional based off the gamestate, so when the sixth switch is thrown, it stops.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Dec 20, 2016 1:40 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Barry wrote:
AlumiuN wrote:
Ah, you could have it find the relevant objects and just replace their shapenum with a frame of their animation that isn't the first instead of sticking another object in their place, that would probably be less messy.


I'll try just making the animation code conditional based off the gamestate, so when the sixth switch is thrown, it stops.


That would require a test every frame, which is a little suboptimal. Try something like the following when the switch is thrown:

::: CODE :::
    for (statobj_t *stat = &statobjlist[0]; stat != laststatobj ; stat++)
        if (stat->shapenum == FIRST_SHAPE)
            stat->shapenum == SECOND_SHAPE;


Where FIRST_SHAPE is the animating frame and SECOND_SHAPE is another frame that is not set to animate and looks fine as a non-animated object.
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Tue Dec 20, 2016 6:24 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
Barry wrote:
AlumiuN wrote:
Ah, you could have it find the relevant objects and just replace their shapenum with a frame of their animation that isn't the first instead of sticking another object in their place, that would probably be less messy.


I'll try just making the animation code conditional based off the gamestate, so when the sixth switch is thrown, it stops.


That would require a test every frame, which is a little suboptimal. Try something like the following when the switch is thrown:

::: CODE :::
    for (statobj_t *stat = &statobjlist[0]; stat != laststatobj ; stat++)
        if (stat->shapenum == FIRST_SHAPE)
            stat->shapenum == SECOND_SHAPE;


Where FIRST_SHAPE is the animating frame and SECOND_SHAPE is another frame that is not set to animate and looks fine as a non-animated object.


Thanks.

I tried this and it doesn't appear to be working. Here is my exact code. Am I supposed to change something in the "for" line?

::: CODE :::
        else if (!buttonheld[bt_use] && (doornum == SWITCHTILE))
    {
   //
   // use switch
   //
        buttonheld[bt_use] = true;
        tilemap[checkx][checky]++;
        gamestate.reactor++;
        if(gamestate.mapon == 32 && gamestate.reactor == 6)
        {
            for (statobj_t *stat = &statobjlist[0]; stat != laststatobj ; stat++)
                if (stat->shapenum == SPR_MD_1)
                    stat->shapenum == SPR_MD_4;
        }

        SD_PlaySound (LEVELDONESND);
        SD_WaitSoundDone();

    }

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Dec 20, 2016 7:25 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hmm, that should be working fine. You have made sure gamestate.reactor is initialized to zero when starting the level?

EDIT: Actually, in the _animatedstaticobjects.h file, try putting curly braces around the lines, with the exception of the trailing comma. Something like this:

::: CODE :::
   {SPR_STAT_0,  6,  4},
    {SPR_STAT_4, 12, 8},
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Tue Dec 20, 2016 7:36 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
Hmm, that should be working fine. You have made sure gamestate.reactor is initialized to zero when starting the level?

EDIT: Actually, in the _animatedstaticobjects.h file, try putting curly braces around the lines, with the exception of the trailing comma. Something like this:

::: CODE :::
   {SPR_STAT_0,  6,  4},
    {SPR_STAT_4, 12, 8},


Yes, gamestate.reactor is set to zero when starting the level, just like keys, captured, etc. I tried the curly braces but that isn't working either. I know my switches are working because it unlocks a door when it gets to 6 and that is working fine.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Dec 20, 2016 10:41 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

OK, and the level you want it to work on is level 33?
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Tue Dec 20, 2016 10:44 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
OK, and the level you want it to work on is level 33?


Correct. I have added code to change some wall textures when the sixth switch is thrown and that works.

::: CODE :::

        else if (!buttonheld[bt_use] && (doornum == SWITCHTILE))
    {
        buttonheld[bt_use] = true;
        tilemap[checkx][checky]++;      // flip switch
        gamestate.reactor++;
        if(gamestate.mapon == 32 && gamestate.reactor == 6)
        {
            tilemap[30][29]++;
            tilemap[31][29]++;
            tilemap[33][29]++;
            tilemap[34][29]++;
            tilemap[35][30]++;
            tilemap[35][31]++;
            tilemap[35][33]++;
            tilemap[35][34]++;
            tilemap[34][35]++;
            tilemap[33][35]++;
            tilemap[31][35]++;
            tilemap[30][35]++;
            tilemap[29][34]++;
            tilemap[29][33]++;
            tilemap[29][31]++;
            tilemap[29][30]++;
            for (statobj_t *stat = &statobjlist[0]; stat != laststatobj ; stat++)
                if (stat->shapenum == SPR_MD_1)
                    stat->shapenum == SPR_MD_4;
        }

        SD_PlaySound (LEVELDONESND);
        SD_WaitSoundDone();

    }

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Dec 20, 2016 11:16 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I wouldn't recommend hard-coding that. Try something like this instead:

::: CODE :::
for (int x = 0; x < MAPSIZE; x++)
    for (int y = 0; y < MAPSIZE; y++)
        if (tilemap[x][y] == VALUE_TO_CHANGE)
            tilemap[x][y]++;


Also, if you still want to go with the static objects, the section should actually be:

::: CODE :::
            for (statobj_t *stat = &statobjlist[0]; stat != laststatobj ; stat++)
                if (stat->shapenum == SPR_MD_1)
                    stat->shapenum = SPR_MD_4;


Note the single equals sign in the last line, I screwed that up Razz
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Tue Dec 20, 2016 11:46 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
I wouldn't recommend hard-coding that. Try something like this instead:

::: CODE :::
for (int x = 0; x < MAPSIZE; x++)
    for (int y = 0; y < MAPSIZE; y++)
        if (tilemap[x][y] == VALUE_TO_CHANGE)
            tilemap[x][y]++;


Also, if you still want to go with the static objects, the section should actually be:

::: CODE :::
            for (statobj_t *stat = &statobjlist[0]; stat != laststatobj ; stat++)
                if (stat->shapenum == SPR_MD_1)
                    stat->shapenum = SPR_MD_4;


Note the single equals sign in the last line, I screwed that up Razz


Thanks! That worked for the static objects. They now work as they should.

I haven't implemented the more general code for changing the wall textures. I'm about to turn in for the night and will add that tomorrow. Out of curiosity, why is hard coding it not a good idea?

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Wed Dec 21, 2016 12:14 am
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Barry wrote:
AlumiuN wrote:
I wouldn't recommend hard-coding that. Try something like this instead:

::: CODE :::
for (int x = 0; x < MAPSIZE; x++)
    for (int y = 0; y < MAPSIZE; y++)
        if (tilemap[x][y] == VALUE_TO_CHANGE)
            tilemap[x][y]++;


Also, if you still want to go with the static objects, the section should actually be:

::: CODE :::
            for (statobj_t *stat = &statobjlist[0]; stat != laststatobj ; stat++)
                if (stat->shapenum == SPR_MD_1)
                    stat->shapenum = SPR_MD_4;


Note the single equals sign in the last line, I screwed that up Razz


Thanks! That worked for the static objects. They now work as they should.

I haven't implemented the more general code for changing the wall textures. I'm about to turn in for the night and will add that tomorrow. Out of curiosity, why is hard coding it not a good idea?


Well, hard coding the locations means that if you want to change the location of the tile in the map you then also have to change the location in the code and recompile it. It's also a pain in the ass if anyone ends up fiddling with the source later (yourself included if it's long enough).
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 8:49 ago.

Topics: 160
Posts: 7993
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Wed Dec 21, 2016 2:16 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
EDIT: Actually, in the _animatedstaticobjects.h file, try putting curly braces around the lines, with the exception of the trailing comma. Something like this:

::: CODE :::
   {SPR_STAT_0,  6,  4},
    {SPR_STAT_4, 12, 8},
The code he uses adds the brackets for you. A large number of mods use several animated sprites, so if the code doesn't require you to type in the brackets for every single line, it saves the user time in the long run. That was the main reason I wrote the tutorial the way I did. Smile

I haven't tried the code with wall images, and in all honesty, I'd use a different tutorial for that. The tutorial he links to doesn't really have wall images in mind. Confused
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 5:22 ago.

Topics: 36
Posts: 2393
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Wed Dec 21, 2016 7:10 pm
   Subject: Re: [Tutorial] Animated Walls for SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Tricob wrote:
AlumiuN wrote:
EDIT: Actually, in the _animatedstaticobjects.h file, try putting curly braces around the lines, with the exception of the trailing comma. Something like this:

::: CODE :::
   {SPR_STAT_0,  6,  4},
    {SPR_STAT_4, 12, 8},
The code he uses adds the brackets for you. A large number of mods use several animated sprites, so if the code doesn't require you to type in the brackets for every single line, it saves the user time in the long run. That was the main reason I wrote the tutorial the way I did. Smile

I haven't tried the code with wall images, and in all honesty, I'd use a different tutorial for that. The tutorial he links to doesn't really have wall images in mind. Confused


Each individual object should still have braces around it. Most compilers will realise the contents of the array should be interpreted as the relevant structs, but just in case someone is using an unusual compiler it's probably best to have them. IMO it's also better for readability.
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 Announcement: Wolf3d & Spear of Destiny Shareware SDL Downloads
Author: BrotherTank
10 13007 Tue Aug 24, 2010 10:18 am
dcbasic View latest post
No new posts Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 17046 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts [Help] Gun Bobbing in SDL
Author: RichterBelmont12
8 2141 Wed Jul 23, 2008 6:37 pm
Tricob View latest post
No new posts [SDL-Help] Wall patches fix
Author: insurrectionman
0 902 Tue Jul 15, 2008 11:12 am
insurrectionman View latest post
No new posts [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
Author: Andy_Nonymous
9 3203 Sun Apr 27, 2008 2:30 am
AlumiuN 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