[Code] Scrolling wall textures - Like in Doom
Select messages from
# through # FAQ
[/[Print]\]

DieHard Wolfers -> Code Tutorials

#1: [Code] Scrolling wall textures - Like in Doom Author: Adam BiserLocation: USA PostPosted: Sun Dec 12, 2004 10:26 pm
    —
You've seen them in Doom, now you can have them in Wolf3D, and it's actually pretty painless...

Open WL_DRAW.C and add this code BEFORE HitVertWall():
::: CODE :::
unsigned ScrollTexture(unsigned texture, boolean vertical)
{
   if (tilehit & 0x40) // don't scroll the door sides.
   {   // check for adjacent doors
      if (vertical)
      {   if ( tilemap[xtile-xtilestep][yintercept>>TILESHIFT]&0x80 )
            return texture;
      }
      else
      {
         if ( tilemap[xintercept>>TILESHIFT][ytile-ytilestep]&0x80 )
            return texture;
      }
   }
   switch (MAPSPOT(xtile,ytile,1))
   {
      case 8:// left to right, fast
         return texture+(((frameon/2)%64)*0xfc0) &0xfc0;
      case 9:// left to right, medium
         return texture+(((frameon/3)%64)*0xfc0) &0xfc0;
      case 10:// right to left, fast
         return texture-(((frameon/2)%64)*0xfc0) &0xfc0;
      case 11:// right to left, medium
         return texture-(((frameon/3)%64)*0xfc0) &0xfc0;
      default:
         return texture;
   }
}

Then inside of HitVertWall(), add the red line in front of the black one:
::: CODE :::
   texture = ScrollTexture(texture,1);
   wallheight[pixx] = CalcHeight();

And for HitHorizWall(), add the red line in front of the black one:
::: CODE :::
   texture = ScrollTexture(texture,0);
   wallheight[pixx] = CalcHeight();

Now, to make a wall scroll, just place the appropriate object code above the wall tile. You find these codes in the switch statement. ie: object code 8 will make the wall scroll from left to right at a fast pace.
You slow down the scroll speed by increasing the divisor value. You change the scroll direction by changing the + to a - (as seen in 10 and 11).

You can also try vertical scrolling, but it won't look as good.
::: CODE :::
         return texture+(((frameon/2)%64));

The problem here is that parts of the adjoined textures in memory can sometimes be seen as it scrolls and the texture will sort of click over once it reaches the bottom. If you try it, you'll see what I mean.

I do not think that this will cause a drop in the FPS. If you use wall decals, I think that the decal will scroll along with the texture.

#2: Re: [Tutorial] Scrolling wall textures Author: TexZKLocation: Northern Italy PostPosted: Mon Dec 13, 2004 11:58 am
    —
Sooooooo simple!?!?!?!? It looks like the wall patches tutorial!
I'll merge them!

Thanks Adam!!!

#3: Re: [Tutorial] Scrolling wall textures Author: Adam BiserLocation: USA PostPosted: Mon Dec 13, 2004 12:19 pm
    —
Have fun, but both methods use an object to modify the wall.
Glad you like it. Very Happy

#4: Re: [Tutorial] Scrolling wall textures Author: ZuljinRaynorLocation: New Jersey, USA PostPosted: Mon Dec 13, 2004 12:47 pm
    —
What is this really? Scrolling Wall Textures? You mean like those "Flesh Walls" in Doom going <------< like that?

#5: Re: [Tutorial] Scrolling wall textures Author: Adam BiserLocation: USA PostPosted: Mon Dec 13, 2004 12:48 pm
    —
Yes, that's what I mean. A screenshot just wouldn't have worked for this..

#6: Re: [Code] Scrolling wall textures - Like in Doom Author: BrotherTankLocation: Ontario PostPosted: Tue Dec 14, 2004 9:26 am
    —
I don't know if you found this or not Adam using the original Wolf3d code... but in my code (using the Darkone Raycastor)... you can't use two of these modifiers side by side... doing so has strange effects... it grabs other graphics or sometimes trashed/garbled images as part of the slide...

Greg
BrotherTank

#7: Re: [Code] Scrolling wall textures - Like in Doom Author: Adam BiserLocation: USA PostPosted: Tue Dec 14, 2004 9:32 am
    —
That's the reason why vertical scrolling looks bad, but the horizontal scrolling seemed OK with the original code. I had 3 in a row, and 1 more diagonally and they scrolled smoothly. I'll check again, but I'm pretty sure it was only scrolling one texture (not half and half).

#8: Re: [Code] Scrolling wall textures - Like in Doom Author: BrotherTankLocation: Ontario PostPosted: Tue Dec 14, 2004 10:08 am
    —
Adam Biser wrote:
That's the reason why vertical scrolling looks bad, but the horizontal scrolling seemed OK with the original code. I had 3 in a row, and 1 more diagonally and they scrolled smoothly. I'll check again, but I'm pretty sure it was only scrolling one texture (not half and half).


I think I've figured out why it doesn't work right in the Darkone Raycastor code... it's due to the same problem we found in the Patches... the "lasttilehit"... there should be a check to make sure the texture is the same as the last one used by the routine or it tries to grab the texture stored in the last defined "lasttilehit"... thus it gives the garbled image...

I'm working on converting it over and make it work in the Darkone code...

Greg
BrotherTank

#9: Re: [Code] Scrolling wall textures - Like in Doom Author: BrotherTankLocation: Ontario PostPosted: Wed Dec 15, 2004 9:39 am
    —
Got it all figured out Adam...

For some reason it must be a seperate routine or function called from the CheckIntersection routine in Darkone's raycastor code. If you just incorperate the texture shift within the original code, it gives some very strange results, but moving it external to the routine works fine. Got me stumped on that one...

The reason I just incorperated it into the Darkone Raycastor code is because it uses 1 single routine in replacement of the HitVertWall and HitHorzonWall routines in the orginal code.

Anyhow, it's working now... great effect...

Greg
BrotherTank

#10: Re: [Code] Scrolling wall textures - Like in Doom Author: Adam BiserLocation: USA PostPosted: Wed Dec 15, 2004 9:41 am
    —
@BTank: Good deal. Thanks. How does vertical scrolling look with that engine? I imagine about the same as the original. (ie: You start to see the edge of the next/prior texture and *click* it goes away as the top of the texture appears at the top)

#11: Re: [Code] Scrolling wall textures - Like in Doom Author: BrotherTankLocation: Ontario PostPosted: Wed Dec 15, 2004 9:45 am
    —
Yep...

I'm playing with that now... for some reason it is shifting the image either right or left (depending on direction of scroll Smile yes, I enabled up and down). I'm trying to figure out why it's doing it as it seems it's playing with the width of the texture to be drawn...

If I find an answer, I'll definitely keep everyone informed...

Greg
BrotherTank

#12: Re: [Code] Scrolling wall textures - Like in Doom Author: Adam BiserLocation: USA PostPosted: Wed Dec 15, 2004 9:51 am
    —
OK, let me try to explain this... it's actually a twisted optical illusion, if you ask me.
Let's say the texture bytes are 0 to 4095...
As it is scrolling horizontally, we guarantee the post to be drawn always starts at the top pixel (a multiple of 64) using "&0xfc0".
Now, with vertical scrolling, we don't do this nice alignment. we say the top pixel goes from 0 to 63.
When the tpo pixel is 63, the bottom right pixel is 4095 + 63, out of range (in the next texture).

Think of the texture as a line of pixels being cut up into posts. When the top pixel of one post goes up 1, it becomes the bottom of the next post to the left, or runs off the edge.

See what I mean?

The only way to do smooth vertical scrolling would be to alter the texture (ala some code similar to wall patches) so that we rearrange the pixels post-by-post. Which, come to think of it, wouldn't be too hard.

#13: Re: [Code] Scrolling wall textures - Like in Doom Author: RingmanLocation: up my nose PostPosted: Wed Dec 15, 2004 5:32 pm
    —
It would be interesting for you to make Pulsating lights like in hexen using this method, but it may not look right without pulsating lights on floors. Be great for a scifi mod.

Awesome as usual Adam! Too Cool

#14: Re: [Code] Scrolling wall textures - Like in Doom Author: MatteLocation: Jämtland PostPosted: Sun Feb 04, 2007 10:04 am
    —
How do I add the scrolling walls to my game? Do I add them in FloEdit with the codes you said?

#15: Re: [Code] Scrolling wall textures - Like in Doom Author: Anonymous PostPosted: Sun Feb 04, 2007 10:09 am
    —
I don't know how to do this in Floedit but you need to add objects with ids from 8 to 11.
You have to put these objects over the walls you want to scroll.
With Adam`s code objects 8 and 9 make the wall scroll from left to right and 10-11 make the wall scroll from right to left.

#16: Re: [Code] Scrolling wall textures - Like in Doom Author: MatteLocation: Jämtland PostPosted: Sun Feb 04, 2007 10:15 am
    —
Thanks for the fast reply! I got it to work with Floedit.

#17: Re: [Code] Scrolling wall textures - Like in Doom Author: MatteLocation: Jämtland PostPosted: Tue Feb 06, 2007 9:08 am
    —
Now I stumbled upon another problem, does anybody know how to get this to work with 128x128 graphics?

#18: Re: [Code] Scrolling wall textures - Like in Doom Author: Anonymous PostPosted: Tue Feb 06, 2007 9:47 am
    —
I haven't tested this so make a backup although it probably should work
From Adam`s original code replace the parts in red
::: CODE :::

unsigned ScrollTexture(unsigned texture, boolean vertical)
{
   if (tilehit & 0x40) // don't scroll the door sides.
   {   // check for adjacent doors
      if (vertical)
      {   if ( tilemap[xtile-xtilestep][yintercept>>TILESHIFT]&0x80 )
            return texture;
      }
      else
      {
         if ( tilemap[xintercept>>TILESHIFT][ytile-ytilestep]&0x80 )
            return texture;
      }
   }
   switch (MAPSPOT(xtile,ytile,1))
   {
      case 8:// left to right, fast
         return texture+(((frameon/2)%64)*0x3f80) &0x3f80;
      case 9:// left to right, medium
         return texture+(((frameon/3)%64)*0x3f80) &0x3f80;
      case 10:// right to left, fast
         return texture-(((frameon/2)%64)*0x3f80) &0x3f80;
      case 11:// right to left, medium
         return texture-(((frameon/3)%64)*0x3f80) &0x3f80;
      default:
         return texture;
   }
}

#19: Re: [Code] Scrolling wall textures - Like in Doom Author: MatteLocation: Jämtland PostPosted: Tue Feb 06, 2007 10:07 am
    —
Thanks again Flamer46!

It worked perfectly!

I changed the 64's to 128's too.

#20: Re: [Code] Scrolling wall textures - Like in Doom Author: Military PostPosted: Fri May 26, 2017 11:47 am
    —
Would this code need some adjustments to work with Wolf4SDL? I copied the code to my project and it's having no effect whatsoever.

I'm now thinking that Wolf4SDL could really use some sort of debug console/log. Something you could call from anywhere and write comments and variable values into. So you could tell which part of the code is not working.

#21: Re: [Code] Scrolling wall textures - Like in Doom Author: ChrisLocation: Canada PostPosted: Fri May 26, 2017 2:17 pm
    —
Military wrote:
Would this code need some adjustments to work with Wolf4SDL? I copied the code to my project and it's having no effect whatsoever.

You probably need to re-add frameon++ into SDL first: http://diehardwolfers.areyep.com/viewtopic.php?p=101111#101111

#22: Re: [Code] Scrolling wall textures - Like in Doom Author: Military PostPosted: Sat May 27, 2017 4:48 am
    —
That helped, thanks!

Though now there's a one pixel/less than one pixel seam on the far left side of every row of scrolling textures.


#23: Re: [Code] Scrolling wall textures - Like in Doom Author: TricobLocation: Neo-traditions, Inc. PostPosted: Sat May 27, 2017 6:31 am
    —
Are you using that tutorial by Chris that connects walls that are apart by the corners? This is probably what you're seeing.

#24: Re: [Code] Scrolling wall textures - Like in Doom Author: Military PostPosted: Sun May 28, 2017 2:40 am
    —
I don't recall any such tutorial, and the seam also appears between two sides of the same wall, so I guess that's not it.


#25: Re: [Code] Scrolling wall textures - Like in Doom Author: TricobLocation: Neo-traditions, Inc. PostPosted: Sun May 28, 2017 10:53 am
    —
If that's the case, then it probably is Chris's tutorial. Many updates of Wolf4SDL have this tutorial already put in.

#26: Re: [Code] Scrolling wall textures - Like in Doom Author: ChrisLocation: Canada PostPosted: Sun May 28, 2017 12:20 pm
    —
Yes if you're using the source on AlumiuN's repository it is included. Basically if you see the green code instead of red:
https://github.com/AlumiuN/Wolf4SDL/commit/7ec3514342f75e9a5f1c96cece672645213e3087

Not sure if that version affects scrolling walls but I should put it in a define regardless so you can easily turn it off and on.

#27: Re: [Code] Scrolling wall textures - Like in Doom Author: ChrisLocation: Canada PostPosted: Sat Jun 03, 2017 4:51 pm
    —
@Military: Just to confirm, you checked the code I posted, and yours was similar to one without the green... or?

#28: Re: [Code] Scrolling wall textures - Like in Doom Author: Military PostPosted: Sun Jun 04, 2017 4:01 am
    —
I checked it now, and my version doesn't include the added code from there.



DieHard Wolfers -> Code Tutorials


output generated using printer-friendly topic mod. All times are GMT

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group