• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
chris2307

Changing the Render Order

5 posts in this topic

Hi folks,

I am making an isometric game in 2D and am having some difficulty in coming up with a solution to my current problem.

If I have lots of little characters (just an example) running around the screen, I want to know what order to render those sprites in. I already know that I can do this simply by knowing each of the characters Y coordinate (If the Y coordinate is lower than one sprite, then it should be rendered in front).

I have already written a sample program that gives the illusion of a ball orbiting around a pole. Trouble is, if I have lots more than just two sprites - for example 20 sprites... it becomes a little more complicated.

I am struggling because obviously, a web of IF statements will not suffice. I would like to know if there is a common method that people may use in this situation? And, lets say for example I was able to get all the objects Y pos and order some kind of virtual Z buffer array that will help me order the rendering, how would I go about this for those objects already contained in a vector (A vector containing 10 generic automated characters for example).

Any thoughts on this? (That is, if I have explained myself correctly). I am using Direct3D 9.0 and C++ although I am sure languages and library's do not really come in to this much.

Thanks

Chris
0

Share this post


Link to post
Share on other sites
[quote name='chris2307' timestamp='1352927413' post='5001013']
Hi folks,

I am making an isometric game in 2D and am having some difficulty in coming up with a solution to my current problem.

If I have lots of little characters (just an example) running around the screen, I want to know what order to render those sprites in. I already know that I can do this simply by knowing each of the characters Y coordinate (If the Y coordinate is lower than one sprite, then it should be rendered in front).

I have already written a sample program that gives the illusion of a ball orbiting around a pole. Trouble is, if I have lots more than just two sprites - for example 20 sprites... it becomes a little more complicated.

I am struggling because obviously, a web of IF statements will not suffice. I would like to know if there is a common method that people may use in this situation? And, lets say for example I was able to get all the objects Y pos and order some kind of virtual Z buffer array that will help me order the rendering, how would I go about this for those objects already contained in a vector (A vector containing 10 generic automated characters for example).

Any thoughts on this? (That is, if I have explained myself correctly). I am using Direct3D 9.0 and C++ although I am sure languages and library's do not really come in to this much.

Thanks

Chris
[/quote]

There are two ways I do isometric rendering.

One is kind of slow and relatively complicated for a new dev. One way I do isometric rendering is to give each pixel a number representing it's distance from the virtual camera. So, you start by drawing a tree which has a closeness of it's y value. if the player is in front of the tree then it's y value must be bigger.
Instead of using if statements I used an 2D array of integers which each represent a pixel on the screen. When you draw an image on the screen it writes that corresponding integer in the array to the y value of the image. If another image is trying to be drawn over another image then the image's y value has to be bigger than the one on the screen. I'm finding it hard to explain.
Another method would be to have tiles on the screen then add the objects onto the tiles then when the tile is rendered isometrically then the object is rendered too.
0

Share this post


Link to post
Share on other sites
If I got the problem right, you have several objects and you want to render the ones with bigger Y first, correct? If that is the case, this should do:

1) Place all the objects you want to render in a list.
2) Sort this list by the Y axis (biggest Y will be the first of the list, lowest Y will be the last one).
3) For each object in the list, render it.

Hope it helps.
0

Share this post


Link to post
Share on other sites
I did think about having a tile based game but as I have never used a tile based method before, I kind of cast the idea away. At the moment, I am trying to stick to what I know but if a tile map would be easier than checking against the values for each sprite, then maybe I should look in to this.

And unfortunately, I do not [i]fully [/i]understand what you were trying to explain for your other method but thanks anyway!

I think I will look at adding tiles to the screen unless anyone else has another method that may fit better?
0

Share this post


Link to post
Share on other sites
Am I able to do this with a vector? For example, if I have a vector of 6 objects, can I re-order that vector based on the Y position (which is a value returned from an object contained in the vector anyway)? If I can do this, then I just need to re-order the vector before I render don't I?
0

Share this post


Link to post
Share on other sites
"Yes you can!"

If it is a STL vector (the one that comes by default), you should use the sort function from algorithm. Here is some documentation:
http://www.cplusplus.com/reference/algorithm/sort/

On the rendering, I don't know how Direct3D works, so I can't really help. I
If you render every object every frame, just render every element of your objects vector and you should be fine.

EDIT: Didn't see that you said you are using CPP, corrected some info. Edited by KnolanCross
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0