Jump to content
  • Advertisement
Sign in to follow this  
doutmost

How to deal with this?

This topic is 5072 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Suppose I have two squares, square 1 and square 2, 1 is behind 2, how can I draw them correctly as in the real world that I can only the part of square 1 not to be hiden by squre 2? Thanks for any advice.

Share this post


Link to post
Share on other sites
Advertisement
make your map editor substitute bright green(or whatever) as transparent. Thats what most people do I think, I don't know how it's done though

Share this post


Link to post
Share on other sites
Quote:
Original post by Frogget
Draw square 1 first, then square 2 over top of it.


I think what Frogget has suggested is the best solution -- just draw the squares in depth order so the one to be on the bottom is drawn first and the square to be on the top is drawn second.

Share this post


Link to post
Share on other sites
if you are using perspective view then opengl will do this automatically if depth testing is enabled ... if you are using ortho view you can also enable depth testing and give your objcts "z values" ... or if you want to do this manually, you can use a sorting algorithm and sort your list of objects so that when you render them they display furthest to nearest.

Share this post


Link to post
Share on other sites
what kind of game are you making ? im assuming its 2d... is a side scroller or ISO or top down game or what?

anyway, most likely you have to sort your objects by their Y axis, so that things on top will be drawn first. this way, if character A is standing above character B, character A is drawn first, which would make B's upper body cover up A's lower body, making it look like hes standing in front of him.

the way i do this is pretty simple. ill go into more details once you give more info though. the gist of it is i make a master class which all things needing sorting derive from, i store them all in a std::list, i overload the < operator then i just .sort() the list each frame then render.

Share this post


Link to post
Share on other sites
it is the game " breakout ", I want to add some function like there will have some 'prizes' like give you more scores, extend your paddle, etc, drop from the top of the window.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!