• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=Jookia;32665567]You have a circular include.[/QUOTE] God damn it, for like 3 weeks now I've not made any progress on any of my programs because I got tangled up in circular dependencies and now circular includes. I seriously can't find anything that shows me how to get past it. All people say is build a third class to transmit data between them(which just led to circular dependencies between the new class and the two others) or set up proper header files. But thats what I did now and look where it got me. Sorry for sounding angry but I really can't find any good tutorial/article which tackles this problem in a good way. It gets really frustrating because I've abandoned 2 other projects because of this.
You could try forward declaration gameManager.h: [code]class mainMenu;[/code]
If you've got a circular dependency, you can get around that with forward declaration. Here's an example: [cpp] class A { A(B& b); } // needs B to be made class B { B(A& a); } // needs A to be made // Fix this by just saying "class B;" at the very top. class B; class A { A(B& b); } class B { B(A& a); } [/cpp] stupid example, simple solution. Forward declaration basically just says "there's this thing, it exists, and I'll tell you more about it later". So then the compiler goes "okay" and won't bitch about it, unless it doesn't actually exist later.
one thing I need help with is how can I use the statement foreach properly ( I know it's an alternative to the for statement but not exactly sure how to use it as it works a bit differently.)
I've decided to rewrite much of my code so that it avoid circular dependences. Thanks for all the advice anyway, I think I made it out to be a lot harder than it actually is.
[QUOTE=confinedUser;32666103]one thing I need help with is how can I use the statement foreach properly ( I know it's an alternative to the for statement but not exactly sure how to use it as it works a bit differently.)[/QUOTE] you use foreach to iterate through a list of objects from start to end, but for can be used to loop through anything really, it just depends on the conditions you give it. [code] int[] someNumbers = new int[] { 1, 4, 9, 16, 25 }; foreach(int val in someNumbers) { Console.WriteLine(val); } // is the same as for(int index = 0; index < 5; index++) { Console.WriteLine(someNumbers[index]); } // is the same as int index = 0; while(index < 5) { Console.WriteLine(someNumbers[index]); index++; } [/code] If you notice the similarities between the while and for loops, you'll notice a for loop is basically a while loop rewritten slightly. Or vice versa.
[QUOTE=confinedUser;32666103]one thing I need help with is how can I use the statement foreach properly ( I know it's an alternative to the for statement but not exactly sure how to use it as it works a bit differently.)[/QUOTE] [code] foreach(var item in collection) { item.doStuff(); } [/code] for example (maybe a bad one): [code] List<string> words = new List<string>(); words.Add("these"); words.Add("are"); words.Add("some"); words.Add("words"); string result = ""; foreach(string str in lines) { result += str; } [/code] You can't modify the values you're iterating on, e.g. if I tried to change [i]str[/i] in that loop I'd get an error. Foreach is slightly slower than a normal [i]for[/i] loop but you can do stuff like making your own collection iterators for it. [url=http://www.dotnetperls.com/foreach]See more here[/url]
I am working on some kind of co-op for my 2D shooter. It is split screen and it works great(at least the camera and scrolling part), but I need to add controller/gamepad support to my game, or do I ? I am using DirectInput for keyboard and mouse and I know DI can also handle gamepads, but is that a good option ? What are the alternatives ? Are ther some tutorials to do it ? Can I use multiple mouse and keyboards in a game using DI? Thanks
[url=http://www.toymaker.info/Games/html/input.html]Here's a good place to start.[/url] DirectInput is slowly being deprecated. RawInput is taking its place and XInput is especially useful for Xbox 360 controllers, but I don't think it works on other gamepads. DirectInput seems like your best bet for non-360 gamepads.
[QUOTE=ZeekyHBomb;32664162]You can also debug release builds .. they don't contain as much information, but the debugger can still pick up on stuff.[/QUOTE] I only got as far as :First-chance exception at 0x77b92a9a in SFML Game.exe: 0xC0000005: Access violation reading location 0xfffffff8. Unhandled exception at 0x77b92a9a in SFML Game.exe: 0xC0000005: Access violation reading location 0xfffffff8. I tried using application verifier, and it outputed : [code]=========================================================== VERIFIER STOP 0000000000000013: pid 0xF74: first chance access violation for current stack trace 000000001D3FA0A4 : Invalid address being accessed 00000000555F1DC6 : Code performing invalid access 000000000026E9A0 : Exception record. Use .exr to display it. 000000000026E4B0 : Context record. Use .cxr to display it. =========================================================== This verifier stop is continuable. After debugging it use `go' to continue. =========================================================== ======================================= VERIFIER STOP 00000013: pid 0xF74: First chance access violation for current stack trace. 1D3FA0A4 : Invalid address causing the exception. 555F1DC6 : Code address executing the invalid access. 0021F72C : Exception record. 0021F77C : Context record. =======================================[/code]
[QUOTE=WTF Nuke;32667623]I only got as far as :First-chance exception at 0x77b92a9a in SFML Game.exe: 0xC0000005: Access violation reading location 0xfffffff8. Unhandled exception at 0x77b92a9a in SFML Game.exe: 0xC0000005: Access violation reading location 0xfffffff8. I tried using application verifier, and it outputed : [code]=========================================================== VERIFIER STOP 0000000000000013: pid 0xF74: first chance access violation for current stack trace 000000001D3FA0A4 : Invalid address being accessed 00000000555F1DC6 : Code performing invalid access 000000000026E9A0 : Exception record. Use .exr to display it. 000000000026E4B0 : Context record. Use .cxr to display it. =========================================================== This verifier stop is continuable. After debugging it use `go' to continue. =========================================================== ======================================= VERIFIER STOP 00000013: pid 0xF74: First chance access violation for current stack trace. 1D3FA0A4 : Invalid address causing the exception. 555F1DC6 : Code address executing the invalid access. 0021F72C : Exception record. 0021F77C : Context record. =======================================[/code][/QUOTE] Are you linking SFML's debug libs? Use the library files that don't have a "-d" suffix if you want to run on release.
No I'm running release libs.
I'm having some problems with performance in Pygame. I'm making a platformer and my framerate takes a dramatic hit based on the amount of terrain tiles/images blitted to the screen. The images for the terrain aren't of a high resolution or of a high size (I am just using placeholder images ATM which are less than 1kb each). I have the image and their location all held in a list and I just run a for loop to blit it to the screen. Now, this is done every tick which I have heard may not be necessary but I'm having trouble finding a way to do this without that. If anyone has any performance tips on this I would appreciate it a lot.
[QUOTE=NovembrDobby;32666395][code] foreach(var item in collection) { item.doStuff(); } [/code] for example (maybe a bad one): [code] List<string> words = new List<string>(); words.Add("these"); words.Add("are"); words.Add("some"); words.Add("words"); string result = ""; foreach(string str in lines) { result += str; } [/code] You can't modify the values you're iterating on, e.g. if I tried to change [i]str[/i] in that loop I'd get an error. Foreach is slightly slower than a normal [i]for[/i] loop but you can do stuff like making your own collection iterators for it. [url=http://www.dotnetperls.com/foreach]See more here[/url][/QUOTE] Thanks your example was a little hard to follow but atleast I know now it's slightly slower than for, mech's example sure got me to understand foreach better.
Something is wrong with my bullets.. they wont go the direction i want them too but i cant find the error.. can someone see it? [code] double vx = 5*Math.cos(angle * ( Math.PI / 180) ); double vy = 5*Math.sin(angle * ( Math.PI / 180 ) ); x+= vx; y+= vy; [/code]
I'm wondering could it be you didn't space between the 180 and the )? (idk all I know is usually the slightest mistake makes annoying errors)
[QUOTE=Tortex;32670405]Something is wrong with my bullets.. they wont go the direction i want them too but i cant find the error.. can someone see it? [code] double vx = 5*Math.cos(angle * ( Math.PI / 180) ); double vy = 5*Math.sin(angle * ( Math.PI / 180 ) ); x+= vx; y+= vy; [/code][/QUOTE] What do you mean it doesn't go in the direction you want to? Be a little more specific.
I'll repost here since this might be a better place to get help... [IMG]http://i52.tinypic.com/2ecoxvs.png[/IMG] So yeah, any way to fix this?
[QUOTE=amazer97;32674119]I'll repost here since this might be a better place to get help... [IMG]http://i52.tinypic.com/2ecoxvs.png[/IMG] So yeah, any way to fix this?[/QUOTE] I don't see you including GL/gl.h anywhere?
[QUOTE=T3hGamerDK;32675259]I don't see you including GL/gl.h anywhere?[/QUOTE] Both glload and sfml include it.
[QUOTE=amazer97;32675385]Both glload and sfml include it.[/QUOTE] I know that SFML doesn't include it directly. Have you tried including it?
[QUOTE=T3hGamerDK;32675435]I know that SFML doesn't include it directly. Have you tried including it?[/QUOTE] Tried it, still doesn't do anything.
[QUOTE=amazer97;32676185]Tried it, still doesn't do anything.[/QUOTE] Go to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\gl and make sure those files are there. They probably are but there might be things its not including that you need to include.
How the fuck do you get programs to compile for Mac? I downloaded the XCode bundle (third time lucky) and installed it, so now I have gcc and make on there. Only, my project is using cmake and the Mac cmake doesn't work. So I try compiling the files using g++ in the terminal manually... only pretty much every single language construct or header is missing or broken. Such a pain in the ass. I've heard you can cross-compile for mac from linux, so I think I might just try doing that somehow. [editline]8th October 2011[/editline] It needs to be said, too - I don't think you can call Mac the greatest developer-friendly operating system if the only way you'll be able to compile programs is spending hours downloading a 3GB file which expands into something far bigger, then you still can't even compile basic C++ programs consisting almost entirely of mathematical functions. Linux nearly always provides gcc by default, and in windows it takes less time to google for, download, install and use mingw32 than it does to even search for installing gcc on mac! Argh.
[QUOTE=darkrei9n;32676496]Go to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\gl and make sure those files are there. They probably are but there might be things its not including that you need to include.[/QUOTE] Under v7.0A? I have a v6.0A and a v7.0A folder, but only 6.0 has the include folder with the gl headers in it.
[QUOTE=Samuka97;32672043]What do you mean it doesn't go in the direction you want to? Be a little more specific.[/QUOTE] [t]http://data.fuskbugg.se/skalman02/192d0465_nn.png[/t] cannot figure this one out..
[QUOTE=Tortex;32678606][t]http://data.fuskbugg.se/skalman02/192d0465_nn.png[/t] cannot figure this one out..[/QUOTE] [QUOTE=Tortex;32670405]Something is wrong with my bullets.. they wont go the direction i want them too but i cant find the error.. can someone see it? [code] double vx = 5*Math.cos(angle * ( Math.PI / 180) ); double vy = 5*Math.sin(angle * ( Math.PI / 180 ) ); x+= vx; y+= vy; [/code][/QUOTE] How are you calculating your value for angle?
[QUOTE=mechanarchy;32679235]How are you calculating your value for angle?[/QUOTE] [code] angle = Math.atan2(dx, dy); [/code] where dx and dy is the distance between the cursor and the "player". that should be correct since i use the same angle to set the player facing the cursor and that seems to work
Math.atan2 and Math.cos should work in the same units, probably radians. Try removing the degree -> radian conversion. (The Math.PI / 180) stuff.
[QUOTE=thomasfn;32680883]Math.atan2 and Math.cos should work in the same units, probably radians. Try removing the degree -> radian conversion. (The Math.PI / 180) stuff.[/QUOTE] Tried that, but i still get weird results
Sorry, you need to Log In to post a reply to this thread.