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

XNA questions

10 posts in this topic

I have a few simple questions that don't require much thought, so I figured I'd put them in one thread instead of making a bunch of threads. I don't know where else to put them lol.

 

1: If I have one million cubes, is it faster to draw them from one big list, or 20 smaller lists?

2: When I'm drawing a skybox, should I have it drawn relative to the player or to the map?

3: Is there a method that can change how a texture looks depending on player color? For example, if player ones color is red, part of the texture will be red. I don't remember what the exact word for it is...maybe alpha blending or something like that.

4: In a multiplayer game, I'm assuming it's correct to create a camera for each player. Is this easiest to do through the player class?

5: What's the difference between the LoadContent and Initialize method created for you? I use both of them while initializing variables, although I'm not really sure why

Edited by burnt_casadilla
0

Share this post


Link to post
Share on other sites


1: If I have one million cubes, is it faster to draw them from one big list, or 20 smaller lists?

 

Generally the fewer draw calls the better - so, one big list. However, if you can avoid drawing any of your 20 smaller lists (say because you know that none of the cubes in that list will be visible from the current camera), then 20 smaller lists is the better way to go.

 


3: Is there a method that can change how a texture looks depending on player color? For example, if player ones color is red, part of the texture will be red. I don't remember what the exact word for it is...maybe alpha blending or something like that.

 

You could use a second texture that indicates which parts of the first texture get replaced by red. Then write a custom shader that uses these two textures to determine the final output color.

Or, draw the object twice. Once normally, and then again using the "team color" texture that is transparent where you want the original color to show through.

1

Share this post


Link to post
Share on other sites

Your first answer helped a lot. Since the entire map is huge, I'll end up using smaller lists. And fog too.

 

With the texture I'm using it'll be easy enough to determine which colors to change to the player color. If the pixel is a certain shade of gray and the player places it, that shade of gray will change to the player color

0

Share this post


Link to post
Share on other sites

1: If I have one million cubes, is it faster to draw them from one big list, or 20 smaller lists?

 

 

 

 

If that million is ON SCREEN, then it should be faster to draw from one list... if for "list" you mean drawcall.

If they are not all visible, then having the possibility to discard cubes might be faster. There's a sweet spot to be found between batch size and ability to cull out blocks and that is very application specific and can only be found through benchmarking your own game.

0

Share this post


Link to post
Share on other sites

If I have one million cubes, is it faster to draw them from one big list, or 20 smaller lists?

 

Neither, your still doing 1,000,000 draw calls wither way. what you need to-do is only draw them if they are onscreen and through the use of Culling or instancing.

 

 


Is there a method that can change how a texture looks depending on player color? For example, if player ones color is red, part of the texture will be red. I don't remember what the exact word for it is...maybe alpha blending or something like that.

 

No, Make one smile.png you will need to use RenderTargets to modify the texture. here is a snippet how to use a rendertarget:

 

RenderTarget2D target = new RenderTarger2D(...); 
//I cant remeber the arguments off the top of my head.
//I think its GraphicsDevice, Width, Height, GenerateMipmap, SurfaceFormat, Depthformat

GraphicsDevice.SetRenderTarget(target);
GraphicsDevice.Clear(Color.Black); //any colour will do
using(SpriteBatch b = new SpriteBatch(GraphicsDevice))
{
b.Begin();

//Draw anything here to draw onto a new texture E.g.
//Draw the Basic non-coloured texture
//Draw the players colour where we are supposed too.

b.End();
}

GraphicsDevice.SetRenderTarget(null);

//Then to access your new Texture, just do 
Texture newTexture = target; //Target inherits from Texture2D so no casting needed

 

 


In a multiplayer game, I'm assuming it's correct to create a camera for each player. Is this easiest to do through the player class?

 

Depends, Local multiplayer, E.g. on the same PC? s this the design you want? I would probally have 1 camera class (Singleton maybe?) which contained ALL the informatio

 

 


What's the difference between the LoadContent and Initialize method created for you? I use both of them while initializing variables, although I'm not really sure why

 

GraphicsDevice ... Initialize() ... is called just after the constructor, that's it. it is never called again until you create another instance of the class.

Whereas LoadContent<T>() ... is called on starup AND whenever the graphics device is Lost or Reset recovering your ingame assets.

 

This means that LoadContent is called when the Game Window is minimized and reopened, or something takes control of the screen (E.g. UAC) and everything run in loaded is run again, this means it is not a good idea to put any data initialization in here, as it will be "reset" when your device is reset / lost.

Edited by Andy474
2

Share this post


Link to post
Share on other sites

Thanks! I guess when the time comes I'll have to figure out a way to get a certain RGB value of a texture and then change it according to player color. When I was playing around with sprites I recalled that pink was always transparent, so I figured I could take a color and make it transparent, then draw over it with the player color

0

Share this post


Link to post
Share on other sites


GraphicsDevice ... Initialize() ... is called just after the constructor, that's it. it is never called again until you create another instance of the class.

Whereas LoadContent() ... is called on starup AND whenever the graphics device is Lost or Reset recovering your ingame assets.



This means that LoadContent is called when the Game Window is minimized and reopened, or something takes control of the screen (E.g. UAC) and everything run in loaded is run again, this means it is not a good idea to put any data initialization in here, as it will be "reset" when your device is reset / lost.

 

That may have been true in older versions of XNA, but not anymore. LoadContent should only be called once.

0

Share this post


Link to post
Share on other sites

 

That may have been true in older versions of XNA, but not anymore. LoadContent should only be called once.

 

 

Not what MSDN Says:

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.loadcontent%28v=xnagamestudio.40%29.aspx

 

 


This method is called by Initialize. Also, it is called any time the game content needs to be reloaded, such as when the DeviceReset event occurs. You should not access the GraphicsDevice until LoadContent is called.

LoadContent is called by Initialize, and before Draw. During the time the code for this method is executing, the user will experience a delay before the initial game screen appears.

Edited by Andy474
0

Share this post


Link to post
Share on other sites

As is often the case, MSDN is wrong (see here: http://xboxforums.create.msdn.com/forums/p/27316/150367.aspx#150367). It's pretty easy to verify this yourself by adding a DeviceReset handler, and putting a bp on it and on your game's LoadContent.

 

XNA will recreate most graphics resources automatically. The only resources that "lose" their data on a device reset are render targets, DynamicVertexBuffers, DynamicIndexBuffers and maybe I few more I can't remember.

Edited by phil_t
0

Share this post


Link to post
Share on other sites

As is often the case, MSDN is wrong (see here: http://xboxforums.create.msdn.com/forums/p/27316/150367.aspx#150367). It's pretty easy to verify this yourself by adding a DeviceReset handler, and putting a bp on it and on your game's LoadContent.

 

XNA will recreate most graphics resources automatically. The only resources that "lose" their data on a device reset are render targets, DynamicVertexBuffers, DynamicIndexBuffers and maybe I few more I can't remember.

 

Interesting ... I'll take the word on it, but if i remember correctly a game i made a while ago used to have problem that every time the game was Minimized all the content would reload and score rest etc. (this was in XNA 3.0) and i got around this by moving all Data stuff (scores etc. out of the LoadContent method. )

 

So smile.png

Edited by Andy474
0

Share this post


Link to post
Share on other sites

2: When I'm drawing a skybox, should I have it drawn relative to the player or to the map?

Nobody answered this one yet smile.png

Skybox should move with the player. But only translation; rotation of the skybox must be fixed with the map.

The reason why you want to move skybox with the player is that this way it will appear to be really far away and you don't need an extremely huge skybox model. If the model wasn't incredibly huge and if it didn't move with the player, it would appear to be very close, which would break the immersion.

Edited by Tom KQT
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