Is there any way to find out what version of DirectX a game uses in runtime? This is C#.
Is there any way to find out what version of DirectX a game uses in runtime? This is C#.
Adding exceptions for things like that would be very odd. Comparisons result in boolean values.
Write a function inrange that inrange(min, val, max) would do just that.
Well so I got a problem, I guess everyone has it sometimes. It's called creativity and it's a real b*tch.
I have no idea what to make, I recently learned pointers, arrays, classes, constructors, deconstructors and a little other things. But I have no idea what to do where I can impliment these syntaxes..
Any suggestions?
If you haven't figured it out it's c++ I am talking about.
I would recommend making a parser of some sort.
The first project I made in C++ was a config/ini file parser that parsed sections/keys into structured data that could be manipulated, then written back to the file. It got me familiar with classes and pointers. Depending on the data your parsing, you may use vectors, maps, arrays, linked lists and probably a lot of pointers.
But yeah, not sure how advanced you are yet, but I would recommend parsing some sort of data file.
I'm not really advanced, yea I might know those syntaxes but I have never used them. The most advanced thing I have done probably would be my roulette game for the programming class or my text RPG (Which is like 2% done, barely done nothing on it).
A quiz in my C++ book had a question that had me write a program that needed a password parsed via commandline. I tried using an if statement like "if(argv[1] == "r"). That didn't work. So I tried doing pointers and shit with it, by making a pointer point to a string where the string was "r". I tried using strcmp, but I couldn't get that to work either. It turns out that the answer was so fucking obvious, it was just "if(!strcmp(argv[1] == "r")". That's the only thing I didn't try. Fuck, I overcomplicate things way too much.
Use == to compare two variables. You're using =, which is the assignment operator.
Woops. I just typed the post wrong. And I'm pretty sure you can't compare char** and char.
argv[1][0] == 'r'? Since it's just a single character you need to compare...
I was just using one character for testing purposes.
In XNA, my content folders for all my projects just became corrupted, and it does the same for each new project I create. What can I do to create new, non-corrupt ones?
#include <iostream> #include <cmath> using namespace std; void round(double &num); int main() { double i; cout << "Enter a double-precision float: "; cin >> i; round(i); return 0; } void round(double &num) { double i = num; modf(i, num); cout << "Rounded: " << num; }
Why is round(i) ambiguous?
Because the standard math library already contains a round function, which you're overloading. You need to rename yours.
God fucking damnit book. Tells me to name the damn function round.
Edited:
Fuck I don't know how to use modf
You know when everyone says don't using namespace std? This is why you don't using namespace std.
I haven't, because I'm just a beginner who's trying to get my way through this book so I can actually make something for once.
Edited:
4. Create a void function called round() that rounds the value of its double argument to the nearest whole value. Have round() use a reference parameter and return the rounded result in this parameter. Demonstrate round() in a program. To solve this problem, you'll have to use modf() etc...
How can I input a reference parameter into modf, but modf only accepts non pointers in it's first parameter?
Edited:
Nevermind I got it :)
The author probably didn't know or care about the C++11 standard that was finalized about two months ago (which added std::round).
© 2002
oh
That explains another question asking me to find the absolute value of a double using abs()
Edited:
Another question, probably due to the outdated-ness.
void println(bool b, int indent = 0);
Why doesn't this work? I was taught that you can't have default arguments to the left of another argument that isn't a default.
It should work, unless you've put the default argument into both the method declaration and the method definition. It only needs to be in the prototype (declaration).
I'm trying to use the farseer physics engine with XNA, I've added the farseer XNA project to my current project and I've added the reference, but when I start typing "using Farseer" the reference doesn't appear... What am I missing ?
Is it normal to get a lot of warnings while building boost? I'm building it for vs2010 by the way.
It's normal to get a lot of warnings while building anything you haven't written yourself
Edited:
If you write something by yourself there are usually more errors instead
Does anyone have some guidelines for in what order you should learn C++?
I know the basics, classes, strutcts, pointers, STL lists, vectors, queues, etc. But what next?
Programming
I already do that.
Edited:
Älä hävitä mustikoita metsässä
No specific order other than syntax and common coding guidelines followed by the standard library.
Having a rough digest of the standard library should be enough, since you can usually just take a look at the reference to see how exactly stuff works; you just need to know that it could be part of it.
Älä puhu sekavia, ei tuo oo mikään sananlasku.
I mostly meant you should start writing little projects or programming experiments and learn stuff as you need it.
Posting here instead of Waywo because I'm retarded.
SUCCESS!
I've made a (kind-of) text based rpg engine where I can dynamically add Areas and connect them to other Areas which you can move around in, and now, finally, I got XML serialization working :)
Output:
Edited:Code:<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!DOCTYPE boost_serialization> <boost_serialization signature="serialization::archive" version="9"> <Area class_id="0" tracking_level="1" version="0" object_id="_0"> <Blocked>0</Blocked> <Hidden>0</Hidden> <EnterText>Du befinner dig i klassrum 219</EnterText> <DescriptionText>Undervisningssal</DescriptionText> <Exits class_id="1" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id_reference="0" object_id="_1"> <Blocked>0</Blocked> <Hidden>0</Hidden> <EnterText>Du befinner dig pa plan 2</EnterText> <DescriptionText>Undervisningssal</DescriptionText> <Exits> <count>2</count> <item_version>0</item_version> <item class_id_reference="0" object_id_reference="_0"></item> <item class_id_reference="0" object_id="_2"> <Blocked>0</Blocked> <Hidden>0</Hidden> <EnterText>Du har trŴt in i Olles hǬe. SjŬv sitter han pƠen benheյg och jųer.</EnterText> <DescriptionText>En hǬe i backen.</DescriptionText> <Exits> <count>2</count> <item_version>0</item_version> <item class_id_reference="0" object_id_reference="_1"></item> <item class_id_reference="0" object_id="_3"> <Blocked>0</Blocked> <Hidden>0</Hidden> <EnterText>Du har lyckats kravla dig in i Heinrichs hǬe. Ljuset Ų skummt, men du kan se att han sitter dŲborte i sitt hղn och trycker.</EnterText> <DescriptionText>En hǬe i backen, i Olles hǬe.</DescriptionText> <Exits> <count>1</count> <item_version>0</item_version> <item class_id_reference="0" object_id_reference="_2"></item> </Exits> </item> </Exits> </item> </Exits> </item> </Exits> </Area> <Area class_id_reference="0" object_id_reference="_1"></Area> <Area class_id_reference="0" object_id_reference="_2"></Area> <Area class_id_reference="0" object_id_reference="_3"></Area> </boost_serialization>
Any ideas as to how I could accomplish outputting åäö to an xml archive using boost serialization? Or should I just use the corresponding escape sequences?
Just ignore my post then, it's okay![]()
I need some help with this, it appears I'm suffering from some form of a memory leak but I have no idea how to identify it. I've tried now 2 methods of fps counting and both claim my program to be suffering from it. Of course, it is as over the course of about 15 seconds it drops to 3-5 fps from 190-200 fps.
That's the code to what's creating and printing the fps and tickRate (tickrate is fixed at 60).Code:public void init(){ try { screen = new Screen(WIDTH, HEIGHT, new SpriteSheet(ImageIO.read(Game.class.getResourceAsStream("/icons.png")))); } catch (IOException e) { e.printStackTrace(); } } public void tick(){ screen.xScroll++; screen.yScroll++; tickCount++; } public void run(){ int frames = 0; double secondsPerTick = 1 / 60.0; double unprocessedSeconds = 0.0; long previousTime = System.nanoTime(); int tickCount = 0; boolean ticked=false; init(); while(running){ long currentTime = System.nanoTime(); long passedTime = currentTime - previousTime; previousTime = currentTime; unprocessedSeconds += passedTime / 1000000000.0; while(unprocessedSeconds > secondsPerTick){ tick(); unprocessedSeconds -= secondsPerTick; ticked = true; tickCount++; if(tickCount % 60 == 0){ System.out.println(tickCount + " ticks, " + frames + " fps"); previousTime+= 1000; tickCount = 0; frames = 0; } } if(ticked){ render(); frames++; } render(); frames++; } } public void render(){ BufferStrategy bs = getBufferStrategy(); if(bs == null){ createBufferStrategy(3); return; } screen.render(pixels, 0, WIDTH); Graphics g = bs.getDrawGraphics(); g.drawImage(image, 0, 0, getWidth(), getHeight(), null); g.dispose(); bs.show(); }
Any assistance would be well appreciated.
Try running it through a leak check tool.
Could you recommend one to me? I'm not familiar with any of them (due to never having this issue).
I only have personal experience with valgrind which is Unix-like exclusive afaik, but if you're using Visual Studio there's a built in one: http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
I'm currently using Eclipse (java), and thanks, I'll look into it and update with further notice.
Once I'm done with this c++ book, where should I go? I want to learn how to create a simple 2d game, and I would like to learn how to do use utilizing my c++ knowledge. Any suggestions?
Use a 2D graphics library such as SFML. It's very easy to use yet powerful.
Thanks a lot dude.
Everytime FModSound gets called it makes annoying lag spike. How can I get rid of it? Sounds are only 8000hz.
Code:void ERRCHECK(FMOD_RESULT result) { if (result != FMOD_OK) { DebugMessage("FMOD error!"); exit(-1); } } void FModSound(char *SoundX) { FMOD::System *system; FMOD::Sound *sound1; FMOD::Channel *channel = 0; FMOD_RESULT result; unsigned int version; result = FMOD::System_Create(&system); ERRCHECK(result); result = system->getVersion(&version); ERRCHECK(result); if (version < FMOD_VERSION) { DebugMessage("Error! You are using an old version of FMOD"); return; } result = system->init(32, FMOD_INIT_NORMAL, 0); ERRCHECK(result); result = system->createSound(SoundX, FMOD_HARDWARE, 0, &sound1); ERRCHECK(result); result = system->playSound(FMOD_CHANNEL_FREE, sound1, false, &channel); ERRCHECK(result); }