I'm slowly working on a master server for my WebSpec relay. The TF game servers throw the data at the master server, browsers connect to the master server, pick what server they want and are fed the data from there. I'm struggling.
It's weird working on a project in very small, separate amounts of time. I am working on a fun personal game project but I only get to spend about 1-2 hours on it a night, 3 or so days a week. And every time I have to re-read a bit of the code and I'm like "Oh I already did that task, sweet." or wait I don't remember writing this at all.
Dear Microsoft'll,
[url=http://en.wikipedia.org/wiki/Jim%27ll_Fix_it]Can you fix it for me[/url] to have an XNA project template for Visual Studio named "Windows Game (4.0, No Comments)"
If you add this template you can remove the frankly ludicrous amount of comments you have in the default one.
[img]http://i.imgur.com/cx52m.png[/img]
I feel that anyone with a gram of common sense can work out what your rather aptly named [I]UnloadContent()[/I] function does.
Thanks
Carl
Age 8 ¾
[editline]11th August 2011[/editline]
P.S.
I drew you a picture of how you think it will look
[img]http://i.imgur.com/F87Is.png[/img]
If you're working on a team or writing some sort of library, the /// comments are actually quite useful, as intellisense uses them as tooltip descriptions.
However, I can see it being completely useless in a window class like that. Most likely it's pulling the comments from the base class down with it as it's generated. Why it adds a //TODO comment, I'm not sure, usually it'll throw my favorite exception, the NotImplementedException.
[QUOTE=robmaister12;31667991]Why it adds a //TODO comment, I'm not sure[/QUOTE]
XNA likes to hold your dick for you as you piss.
It assumes no knowledge, so everything is aimed at that level.
[QUOTE=CarlBooth;31667766]I drew you a picture of how you think it will look
[img]http://i.imgur.com/F87Is.png[/img][/QUOTE]
This image is wrong. It says "public override void" but it's "protected override void" :v:
In general is it better to worry about memory or CPU?
i.e, I have a system for storing my trees which I could technically use bytes instead of ints, and it saves a few MB, but it means I have ot multiply the coordinates when I'm drawing each tree. Is it worth it?
[QUOTE=chaz13;31668999]In general is it better to worry about memory or CPU?[/QUOTE]
CPU, except in very specific situations where you're constrained by memory.
[cpp]void TerrainManager::Draw(sf::RenderWindow& win)
{
for(int i = 0; i < 800; i++)
{
for(int k = 0; k < 600; k++)
{
if(pixels[i][k] == true)
{
toDraw.SetPixel(i, k, sf::Color(122, 122, 122));
}
}
}
draw.SetImage(toDraw);
win.Draw(draw);
}
[/cpp]
toDraw is an sf::Image, draw is a sf::Sprite, pixels is a std::map<int, std::map<int, bool> >
How do I make this more efficient, because the way I'm doing it is terrible and runs at 3fps
[QUOTE=neos300;31670717][cpp]void TerrainManager::Draw(sf::RenderWindow& win)
{
for(int i = 0; i < 800; i++)
{
for(int k = 0; k < 600; k++)
{
if(pixels[i][k] == true)
{
toDraw.SetPixel(i, k, sf::Color(122, 122, 122));
}
}
}
draw.SetImage(toDraw);
win.Draw(draw);
}
[/cpp]
toDraw is an sf::Image, draw is a sf::Sprite, pixels is a std::map<int, std::map<int, bool> >
How do I make this more efficient, because the way I'm doing it is terrible and runs at 3fps[/QUOTE] Wikipedia says that vectors would be more efficient for lookups here (O(1) for vectors vs O(log n) for maps). I'm not sure if it would help, but would it be possible to cache that color outside the loop instead of instantiating it every iteration?
[QUOTE=neos300;31670717][cpp]void TerrainManager::Draw(sf::RenderWindow& win)
{
for(int i = 0; i < 800; i++)
{
for(int k = 0; k < 600; k++)
{
if(pixels[i][k] == true)
{
toDraw.SetPixel(i, k, sf::Color(122, 122, 122));
}
}
}
draw.SetImage(toDraw);
win.Draw(draw);
}
[/cpp]
toDraw is an sf::Image, draw is a sf::Sprite, pixels is a std::map<int, std::map<int, bool> >
How do I make this more efficient, because the way I'm doing it is terrible and runs at 3fps[/QUOTE]
Why use an associative map when you are using integers as indexes anyway?
Just use a one dimensional array like this:
[cpp]
pixels = new bool[width * height];
[/cpp]
And when you want to get the value of one element do this:
[cpp]
if (pixels[i + k * height])
[/cpp]
[editline]1:11[/editline]
Or you could use STL vectors like the above said, and like he also said cache the color before you start the loop.
[QUOTE=Neo Kabuto;31670880]Wikipedia says that vectors would be more efficient for lookups here (O(1) for vectors vs O(log n) for maps). I'm not sure if it would help, but would it be possible to cache that color outside the loop instead of instantiating it every iteration?[/QUOTE]
None of that worked, but I changed it so that instead of using a vector/map I simply used the image as a storage medium, and instead of re inputting the pixels every frame I simply putpixel's the pixel every time a method (SetPixel) was called on terrain manager.
[editline]11th August 2011[/editline]
[QUOTE=thf;31670932]words[/QUOTE]
Or I could do that :v:
[QUOTE=ROBO_DONUT;31669085]CPU, except in very specific situations where you're constrained by memory.[/QUOTE]
I disagree. Not with your point that he'll likely have plenty of memory to use, but how you use the memory is just as important for performance. If he's jumping around memory locations then he could cause a tonne of cache misses, which will have a worse effect on performance than simply having to perform extra multiplications.
Also, caching the color did help, nevermind about the first part.
[editline]11th August 2011[/editline]
I probably will use thf's method in the future because eventually I will need to access more complex values.
neos3000, do you have static and moving pixels? Why not think of static pixels as textures with alpha and divide the world into texture-sized "chunks". Then, you could load only active chunks to textures, and every time there is a change to static terrain, you could render over that texture rather than reload the entire thing. Then, use additional layers for moving pixel objects - render the moving object to a shared texture (you will need to write a class to allocate memory from a single texture to multiple objects, perhaps some sharing the same texture space if they look exactly the same), and change the render position of the rect rather than change the texture as that object moves. When a collision stops a moving pixel object, merge it back to the static terrain texture (if visible) by rendering that part of the texture to the terrain texture.
Just note that you will need to narrow the scope of your problem to make optimizations. Here, I've made the assumption that you will have lots of static terrain and an order of magnitude less of moving objects that roughly maintain the same shape for more than several frames.
Almost done now!
[img]http://images.overvprojects.nl/SS-2011-08-11_20.38.16.png[/img]
[QUOTE=Night-Eagle;31671261]neos3000, do you have static and moving pixels? Why not think of static pixels as textures with alpha and divide the world into texture-sized "chunks". Then, you could load only active chunks to textures, and every time there is a change to static terrain, you could render over that texture rather than reload the entire thing. Then, use additional layers for moving pixel objects - render the moving object to a shared texture (you will need to write a class to allocate memory from a single texture to multiple objects, perhaps some sharing the same texture space if they look exactly the same), and change the render position of the rect rather than change the texture as that object moves. When a collision stops a moving pixel object, merge it back to the static terrain texture (if visible) by rendering that part of the texture to the terrain texture.
Just note that you will need to narrow the scope of your problem to make optimizations. Here, I've made the assumption that you will have lots of static terrain and an order of magnitude less of moving objects that roughly maintain the same shape for more than several frames.[/QUOTE]
I'm making an RTS so that might not be as feasible, but I will keep it in mind.
[QUOTE=Overv;31672346]Almost done now!
[img]http://images.overvprojects.nl/SS-2011-08-11_20.38.16.png[/img][/QUOTE]
Splendid. Will use this when I'm ready to learn OpenGL :v:
Just got my game to a working and fast state (I hope!), using SFML2.
[img]http://dl.dropbox.com/u/3715122/TankEngine.PNG[/img]
3000 entities and still running at 30 fps, I am pretty pleased with that! The grass is 3000 sprites bouncing around the world.
[QUOTE=Overv;31672346]Almost done now!
[img]http://images.overvprojects.nl/SS-2011-08-11_20.38.16.png[/img][/QUOTE]
I hope your happy :|
[img]http://img812.imageshack.us/img812/7772/15978921.png[/img]
[QUOTE=Overv;31672346]Almost done now!
[img]http://images.overvprojects.nl/SS-2011-08-11_20.38.16.png[/img][/QUOTE]
You should credit Dajoh for helping you so much
:v:
[QUOTE=Quark:;31672857]You should credit Dajoh for helping you so much
:v:[/QUOTE]
He never helped me with anything, I thought we cleared that up?
I can't wait to read your tutorial, I'm currently leaving the context creation up to SFML, but now I might do it myself.
Is there any performance benefit from the new context / code or is it just easier to work with & nicer to look at?
[QUOTE=Overv;31672910]He never helped me with anything, I thought we cleared that up?[/QUOTE]
I disagree.
[QUOTE=dajoh;31429489]
It wasn't all in vain though, I did something:
[code]
Overv: You did actually help me refresh my memory a bit and gain some motivation
Overv: Thank you for that
[/code][/QUOTE]
:v:
For perlin noise, if I want to get a value out of 600 I multiply by 300 and then add 300, right?
Or is there a different way to do it?
[QUOTE=conman420;31672740]Just got my game to a working and fast state (I hope!), using SFML2.
[img]http://dl.dropbox.com/u/3715122/TankEngine.PNG[/img]
3000 entities and still running at 30 fps, I am pretty pleased with that! The grass is 3000 sprites bouncing around the world.[/QUOTE]
That's not good at all unless you have a very complex game logic. Are you culling offscreen objects?
[QUOTE=neos300;31673254]For perlin noise, if I want to get a value out of 600 I multiply by 300 and then add 300, right?
Or is there a different way to do it?[/QUOTE]
If you mean you wanna go from -1..1 to 0..600 then yes you multiply by 300 then add 300.
[QUOTE=Overv;31672346]Almost done now!
[img]http://images.overvprojects.nl/SS-2011-08-11_20.38.16.png[/img][/QUOTE]
Is there some app to make screenshots like this, or do you stick the fragments together yourself?
Or, did you just Ctrl+Mousewheel? :v:
[QUOTE=SupahVee;31673263]That's not good at all unless you have a very complex game logic. Are you culling offscreen objects?[/QUOTE]
Nothing is off screen for now. What should I expect from 3000 sprites? The sf::Image for the grass sprite is shared so I am not duplicating images.
[QUOTE=conman420;31673537]Nothing is off screen for now. What should I expect from 3000 sprites? The sf::Image for the grass sprite is shared so I am not duplicating images.[/QUOTE]
Have you compared FPS in debug vs release mode?
Sorry, you need to Log In to post a reply to this thread.