The Dink Network

sp_clip_[side] - discussion.

March 16th, 05:52 PM
Jester Male Australia
You feed the madness, and it feeds on you. 
First the obvious flaw in the DinkC reference with the commands sp_clip_<side>, then I'll get to the bug with using them with DinkC and some findings:

The incorrect DinkC reference info
The DinkC reference states each of these sp_clip commands gets or sets the amount of pixels to clip off the sprite.
This is true for sp_clip_left and sp_clip_top.
E.g: sp_clip_left(&current_sprite, 10); << this will clip 10 pixels off the left off the sprite.

However, for sp_clip_right and sp_clip_bottom, you are actually setting how many pixels of the sprite to DISPLAY
E.g: let's say you have a 90 pixel wide sprite, to clip 10 pixels off the right of the sprite you would actually run: sp_clip_right(&current_sprite, 80); << It will display 80 pixels, and truncate the rest to the right.

Bug using DinkC to clip sprites if they haven't been clipped in the editor(and the fix without clipping in the editor)
So I noticed many times that the sp_clip_<side> commands did not work in the past unless the sprite is already clipped in the editor. I've noticed a few ppl have mentioned this in the past too, which is why I'm posting these findings.

Then I stumbled upon a post by Arik a while ago that states that you have to set the original width and height of the sprite first with:

Then, you can clip as you please from any side. I found the thought of this annoying initially because I couldn't be bothered checking the size of each sprite just to set it up. But I recently realised that you don't have to set it the original width and height.. as long as the bottom and right clip is set GREATER than the sprite, it will fix it. I confirmed this with a normal rock, which is roughly 60 pixels wide. I initally set it's clip_right and bottom to 620 and 400(size of a screen). Then I used sp_clip_right(&current_sprite, 50); to display 50 of it's pixels, and it worked as expected. To be sure I also tested all other sides, they clipped fine.

So all you have to do is (put this in an external proc call "clipfix()" or something if you want, and call it before you clip a sprite, or just run these each time):
sp_clip_bottom(&current_sprite, 400);
sp_clip_right(&current_sprite, 620);
(I set it to the boundaries of the screen, so it will set up any sprite, no matter how big it is).

Then you can clip as normal AND, it won't act as if the sprite is 620 pixels wide.. it will work as normal. E.g:
sp_clip_right(&current_sprite, 80);
Will display 80 pixels and truncate the rest to the right, as expected.
March 16th, 06:29 PM
Peasant Male New Zealand xbox steam
Don't look at me, I'm a ghost 
Sounds like an idea for a new DSPT Tutorial then
March 17th, 01:26 PM
Peasant Male United States bloop
2nd generation. No easy way to be free. 
Nice analysis work Robj!
March 18th, 09:39 AM
Peasant Male
I disagree. 
E.g: let's say you have a 90 pixle wide sprite

I refuse to take this post as a reliable source of information, due to spelling error
March 18th, 10:55 AM
Jester Male Australia
You feed the madness, and it feeds on you. 
Corrected. I wrote it on my phone so it's pretty good considering.