Programming 2D Games

The official forum for "Programming 2D Games" the book by: Charles Kelly

It is currently Fri Feb 28, 2020 8:50 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Sprite Clipping
PostPosted: Tue Apr 12, 2016 5:47 pm 
Offline

Joined: Wed Nov 25, 2015 4:56 pm
Posts: 24
Is there a way to set a clipping zone within the screen area for automatically clipping sprites? I have written my own code for doing this and it works great until the sprites are rotated or flipped. I am using your engine for displaying sprites.

Thanks :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Sprite Clipping
PostPosted: Wed Apr 13, 2016 9:22 am 
Offline
Site Admin
User avatar

Joined: Sat Jan 28, 2012 4:36 pm
Posts: 554
This is not a feature in the current game engine.
It should be possible to merge your code with the sprite rendering code in the Image class or possibly the Graphics class.

_________________
Professor Kelly


Top
 Profile  
Reply with quote  
 Post subject: Re: Sprite Clipping
PostPosted: Wed Apr 13, 2016 11:33 am 
Offline

Joined: Wed Nov 25, 2015 4:56 pm
Posts: 24
Thanks for reply.

I knew the ability is not part of the current game engine but I was wondering if there was a direct X function for doing this. Otherwise my work around will be to just draw all the visible sprites first and then place a frame with a window over the top. This workaround will not work for split screen though.

I did write my own code for clipping sprites but it was only good for non rotated sprites. There must be a way to give direct X a region of the screen so it can automatically clip sprites within it. :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Sprite Clipping
PostPosted: Wed Apr 13, 2016 7:33 pm 
Offline
Site Admin
User avatar

Joined: Sat Jan 28, 2012 4:36 pm
Posts: 554
You can use the stencil buffer to clip images.

_________________
Professor Kelly


Top
 Profile  
Reply with quote  
 Post subject: Re: Sprite Clipping
PostPosted: Thu Apr 21, 2016 10:47 pm 
Offline

Joined: Fri Oct 19, 2012 5:50 pm
Posts: 32
This might be what you're looking for:

https://msdn.microsoft.com/en-us/librar ... 85%29.aspx


Top
 Profile  
Reply with quote  
 Post subject: Re: Sprite Clipping
PostPosted: Fri Apr 22, 2016 6:07 am 
Offline

Joined: Wed Nov 25, 2015 4:56 pm
Posts: 24
Oh yes that is exactly what I'm looking for. Cheers mate! :)

Who'd of thought to call it ScissorRect, only Microsoft lol.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group