• 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
BambooCatfish

Rendering 2D

4 posts in this topic

Hi,

I have question about rendering in general. I have windows or a HUD if you want... how do I handle telling the renderer to draw the informaiton for each window? should they just draw themselves? I'm not sure how to handle turning window specific information into a form that can be handled in a general sense by the renderer.

Another way of putting it:

I want the window to "tell" the renderer to draw it at a position and then to draw its contents, whatever they may be.

Dont know where to start and I'm just scratching my head thinking about it.

Thanks,
Nick
0

Share this post


Link to post
Share on other sites
A window should know it's own location. It's children should know their own location (relative to the window's topleft corner).
When told to draw, a window draws itself, then tells each child to draw themselves, and so on.

A window is a widget, and buttons, text labels, line edits, etc... are all also widgets. Thus, you have a tree hierarchy of abstract widgets that are overrided as windows, buttons, menus, and other GUI elements. Each widget draws itself at the parent's absolute pos, then tells each other widget to draw themselves.
The same thing happens with events, but in reverse. A mouse click gets passed (untouched) from parent to child, until the bottom-most child gets it. If the bottom-most child decides to process the click, then afterward the event is discarded. Otherwise, the second-to-the-bottom child gets an opportunity to process the click and discard, and so on.

This is a very common way GUIs are handled. Almost everything is a widget. Sometimes a 'widget' is also called a 'window', like in Win32 - which in Win32, a button IS-A window. But I think it's better to use the term 'widget', because it separates out the 'abstract' concept from the specific idea of a application window and pop-up windows that contains buttons and other elements.
2

Share this post


Link to post
Share on other sites
How do you store these Windows? When you perform your rendering phase, you will have to loop through all the windows and draw them; I would suggest having a Draw() function each window has, and it handles drawing itself since it knows where it is, and what all it needs to draw. Something like this

[code]
// Let's assume you put all the windows into a vector of TWindows, and they have a Draw() funciton
std::vector<TWindows> Windows;


// in main rendering loop
void Render()
{
// Draw all object in game 1st since HUD sits on top of the game

for (int i = 0; i < Windows.size(); ++i) {
Windows[i].Draw(SurfaceToDraw);
}
}
[/code]
1

Share this post


Link to post
Share on other sites
Servant of the Lord-

Thanks for the info I wasn;t sure how they were handled. The hierarchy definitely makes sense, hopefully I can put it to good use!

BeerNutts-

Yeah, basically I have a container that holds them in my renderer object. However, I am handling sprites and such by reading an xml file to load the appropriate data. so the "playerCharacter" doesn't actually hold is sprite it holds the ID of where it is located in the list of loaded images. the image is drawn @ the playerCharacters location. Thats how my tile map works as well loads the tilemap xml and adds the resources and reads what texture to use based on a textureID. Right now I am just rendering rectangles to get a feel for displaying the data and getting everyhting working right before I start using images and such for the widget/window Appropriate?

Thanks,
Nick
0

Share this post


Link to post
Share on other sites
Nick,

There are many different ways to solve this kind of problem, but I'm of the opinion the individual entities should handle drawing themselves, since they have all the information, and you don't have to share it. And, if you take the path of having the windows draw themselves (which would be best since these "windows" could have different data that it has to display; images, text, etc.), but keep the characters drawn externally, it's a clash of styles.

It's fine how you load the images, and the character only stores an ID for the image it is using, but that doesn't preclude you from still having the character (and all other on-screen entities) draw themselves.

You are limiting how you can draw the player; will your player ONLY ever be the image it's assigned to? Will he not have special FX as well (blinking, glowing, transparent, wearing different items)? If so, then you're going to be writing a lot of code outside the player or other objects to get every possible status. However, if you handle the objects drawing themselves, it will all be contained within the draw:
[code]
void Player::Draw()
{
uint8_t Alpha = 255;

// if our player is invisible, set the alpha small so he looks transparent
if (IsInvisible) {
Alpha = 50;
}
// Draw the image we currently are using
RenderingEngine->Draw(CurrentImage, Alpha, LocationX, LocationY);

// If we have a powerup, create a glow around the player
if (HasQuadDamage) {
RenderingEngine->CircleGlow(LocationX, LocationY, COLOR_BLUE);
}
...
}
[/code]

As an example, you can check out my Old Blog (see the link in my Sig) for a simple game I made. You can also download the source [url="http://dl.dropbox.com/u/27729730/SmashPC-11-15-11.zip"]from here[/url]

Good luck and have fun!
1

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