1. Post #4521

    September 2008
    137 Posts
    Is there any way to find out what version of DirectX a game uses in runtime? This is C#.
    Reply With Quote Edit / Delete Windows 7 Norway Show Events

  2. Post #4522
    Gold Member
    esalaka's Avatar
    July 2007
    9,603 Posts
    It's a shame C++ doesn't support syntax like this:

    Code:
    if ( -0.0025f <= rollSpeed <= 0.0025f ) rollSpeed = 0;
    Adding exceptions for things like that would be very odd. Comparisons result in boolean values.
    Reply With Quote Edit / Delete Linux Finland Show Events Agree Agree x 3Disagree Disagree x 1 (list)

  3. Post #4523
    sim642's Avatar
    July 2010
    1,038 Posts
    Code:
    if ( -0.0025f <= rollSpeed && rollSpeed <= 0.0025f ) //null speed when within 0.0025 of 0 either way
    rollSpeed = 0;
    Is kind of a better way of writing it, that way you can visualize the values as if it were a number line.
    Write a function inrange that inrange(min, val, max) would do just that.
    Reply With Quote Edit / Delete Windows Vista Estonia Show Events Dumb Dumb x 2 (list)

  4. Post #4524
    landizz's Avatar
    May 2011
    83 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  5. Post #4525
    Gold Member
    Electroholic's Avatar
    June 2011
    1,645 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  6. Post #4526
    landizz's Avatar
    May 2011
    83 Posts
    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).
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  7. Post #4527
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  8. Post #4528
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    2,579 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  9. Post #4529
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  10. Post #4530
    Gold Member
    raBBish's Avatar
    March 2007
    2,667 Posts
    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...
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  11. Post #4531
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    argv[1][0] == 'r'? Since it's just a single character you need to compare...
    I was just using one character for testing purposes.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  12. Post #4532
    Clops with bisousbisous daily <3
    Mr. Smartass's Avatar
    December 2010
    9,176 Posts
    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?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  13. Post #4533
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    #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?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  14. Post #4534
    Gold Member
    thomasfn's Avatar
    July 2008
    2,643 Posts
    Because the standard math library already contains a round function, which you're overloading. You need to rename yours.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  15. Post #4535
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    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
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  16. Post #4536
    Gold Member
    Catdaemon's Avatar
    February 2005
    2,818 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 Show Events Agree Agree x 5Artistic Artistic x 1 (list)

  17. Post #4537
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    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 :)
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  18. Post #4538
    Gold Member
    ZeekyHBomb's Avatar
    June 2006
    3,024 Posts
    God fucking damnit book. Tells me to name the damn function round.

    Edited:

    Fuck I don't know how to use modf
    The author probably didn't know or care about the C++11 standard that was finalized about two months ago (which added std::round).
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  19. Post #4539
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  20. Post #4540
    NovembrDobby's Avatar
    April 2007
    1,121 Posts
    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).
    Reply With Quote Edit / Delete Windows XP United Kingdom Show Events

  21. Post #4541
    joyenusi's Avatar
    May 2006
    148 Posts
    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 ?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  22. Post #4542
    Gold Member
    Armandur's Avatar
    March 2009
    654 Posts
    Is it normal to get a lot of warnings while building boost? I'm building it for vs2010 by the way.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  23. Post #4543
    Gold Member
    esalaka's Avatar
    July 2007
    9,603 Posts
    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
    Reply With Quote Edit / Delete Windows 7 Finland Show Events Funny Funny x 3 (list)

  24. Post #4544
    Gold Member
    Armandur's Avatar
    March 2009
    654 Posts
    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?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  25. Post #4545
    Gold Member
    esalaka's Avatar
    July 2007
    9,603 Posts
    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
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  26. Post #4546
    Gold Member
    Armandur's Avatar
    March 2009
    654 Posts
    Programming
    I already do that.

    Edited:

    Älä hävitä mustikoita metsässä
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  27. Post #4547
    Gold Member
    ZeekyHBomb's Avatar
    June 2006
    3,024 Posts
    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.
    Reply With Quote Edit / Delete Linux Germany Show Events

  28. Post #4548
    Gold Member
    esalaka's Avatar
    July 2007
    9,603 Posts
    I already do that.

    Edited:

    Älä hävitä mustikoita metsässä
    Ä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.
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  29. Post #4549
    Semi-Officially better than Garry.
    StealthArcher's Avatar
    February 2011
    544 Posts
    Posting here instead of Waywo because I'm retarded.


    Terraria like setup, 2d, blokz an shit. The stuff here helped me create what so far seems to be working on the memory front, so now I need to ask one thing and confirm another.


    Physics: I want to have circular objects, and other item physics in the game. Now, Box2D would work for this normally, but we're talking a world made up of voxel chunks that can change constantly.

    The amount of memory and CPU time that would be wasted attempting to keep track of this entire (up to 10x10k for 100 million block) world as small Box2D cube shapes would be ridiculous.

    On this note, if you have worked with Box2D more then I have (probably a certainty if you've really done much with it) might you have an idea how to fix this issue? The world will have other living NPCs and such in it so physics need to be all across the active world. Trailing worlds have more broad macro effects, so physics won't be active on them.


    For the second quicker question, I have an array of chars acting as 8 bit flags for the voxels on the map. Would the easiest method to test if a flag is active a bitwise AND, with 8 corresponding chars with each having 1 bit active (ie. char x = 1, char y = 2, char z = 4, and so on).
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  30. Post #4550
    Gold Member
    Armandur's Avatar
    March 2009
    654 Posts
    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:
    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>
    Edited:

    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?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Winner Winner x 1 (list)

  31. Post #4551
    joyenusi's Avatar
    May 2006
    148 Posts
    Just ignore my post then, it's okay
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 1 (list)

  32. Post #4552
    Gold Member
    WitheredGryphon's Avatar
    July 2011
    687 Posts
    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.

    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();
    		
    		
    	}
    That's the code to what's creating and printing the fps and tickRate (tickrate is fixed at 60).

    Any assistance would be well appreciated.
    Reply With Quote Edit / Delete Windows Vista United States Show Events

  33. Post #4553
    Gold Member
    Octave's Avatar
    January 2009
    2,515 Posts
    Try running it through a leak check tool.
    Reply With Quote Edit / Delete Linux United States Show Events

  34. Post #4554
    Gold Member
    WitheredGryphon's Avatar
    July 2011
    687 Posts
    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).
    Reply With Quote Edit / Delete Windows Vista United States Show Events

  35. Post #4555
    Gold Member
    Octave's Avatar
    January 2009
    2,515 Posts
    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
    Reply With Quote Edit / Delete Linux United States Show Events

  36. Post #4556
    Gold Member
    WitheredGryphon's Avatar
    July 2011
    687 Posts
    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.
    Reply With Quote Edit / Delete Windows Vista United States Show Events

  37. Post #4557
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    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?
    Reply With Quote Edit / Delete United States Show Events

  38. Post #4558
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    2,579 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Agree Agree x 1 (list)

  39. Post #4559
    Meatpuppet's Avatar
    July 2010
    6,696 Posts
    Use a 2D graphics library such as SFML. It's very easy to use yet powerful.
    Thanks a lot dude.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  40. Post #4560
    rute's Avatar
    August 2009
    207 Posts
    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);
    }
    Reply With Quote Edit / Delete Windows 7 Finland Show Events