• What Do You Need Help With? V6
    7,544 replies, posted
C#, but that works, thanks.
[QUOTE=Angus725;40880534]The "this" pointer fixed it. Replaced the "delete this" with a class that's allocated then given to the unique_ptr. I've gotten rid of all the vectors in my code now due to it's immense want to free/delete all the memory I allocated. Unfortunately, this brings me back to good old pointer issues. [code] Planet* GameSystemDirectory= new Planet[NumPlanets]; [/code] Looks harmless ya? Class definition of planet: [code]//code[/code] But, when I get here from a different function call, the entire GameSystemDirectory is inaccessible. Gives me an error when I try to dereference it. [code]//more code[/code] Any ideas why GameSystemDirectory would decide to undo itself?[/QUOTE] std::vector does free its memory. You just don't have to do it by hand - it's destructor frees all memory. You can also free the memory mid-use via vector.clear(); vector.shrink_to_fit();. You always return something from PlanetSelect, maybe you can return a reference instead of a pointer? The second parameter to TimeUntilCompleteion is a const std::string; you can use a const std::string& to avoid a copy. And what's with the Planet:: in front of two of the declared member functions in Planet? What's the error you get and what's the definition of the GameSystem class (or struct)?
[QUOTE=David Cameron;40865269]Does anyone know an IDE for javascript which will show errors, like visual studio? It's so hard having bits just not work and having to dig the error out myself.[/QUOTE] You can't find errors in javascript without running it. Chrome has the developer tools (Ctrl + shift + J) though, which show you errors and gives you a console that you can use to try out little snippets of code if you want to.
I have some Lua code. When I add things to a table, all the values are the same as the last one I added. It's basically something like this: [CODE] local t = {} function addItem( name ) table.insert(t,name) end[/CODE] I originally had the table in another table, so I made one without an other table. I also used t[#t] too, didn't make any difference. I'm sure the item I add is correct, I checked that multiple times. I've tried this on LuaJIT and the normal Lua, both do the same thing. To explain more: I will do something like: [CODE] addItem("hello") addItem("world")[/CODE] the table is now: t[1]="world" t[2]="world" I then do: [CODE]addItem("bye")[/CODE] table: t[1]="bye" t[2]="bye" t[3]="bye" This isn't the exact code, but this is what it does, I dumbed it as much as possible to debug this and it's basically in the same form. I have no idea what is wrong.
[QUOTE=Kamil_;40890455]I have some Lua code. When I add things to a table, all the values are the same as the last one I added. It's basically something like this: [CODE] local t = {} function addItem( name ) table.insert(t,name) end[/CODE] I originally had the table in another table, so I made one without an other table. I also used t[#t] too, didn't make any difference. I'm sure the item I add is correct, I checked that multiple times. I've tried this on LuaJIT and the normal Lua, both do the same thing. To explain more: I will do something like: [CODE] addItem("hello") addItem("world")[/CODE] the table is now: t[1]="world" t[2]="world" I then do: [CODE]addItem("bye")[/CODE] table: t[1]="bye" t[2]="bye" t[3]="bye" This isn't the exact code, but this is what it does, I dumbed it as much as possible to debug this and it's basically in the same form. I have no idea what is wrong.[/QUOTE] Can you show the [i]actual[/i] code that is causing this behaviour? There is nothing wrong with the code that you posted.
Alright, that code works(In normal Lua) but my [I]actual[/I] code doesn't. (I'm using Love2D 0.9.0 with JIT) So I'll try and rewrite the thing, since it needs it anyway and I'll come back if it doesn't work, but thanks anyway. Oh and one thing I forgot to do is check in the actual lua program(which I just did), not the normal Love2D, it should be the same, but I'm thinking something is wrong on the Love2D side of things.
So I want to move all my Qt shit to a namespace, so I can do "ui::mainui". This is what I've figured out I need to do so far: [cpp]namespace ui { QApplication qapp(argc, argv); // Compiler bitches about QApplication needing to be initialized before other shit MainUI mainui; // MainUI is a QDialog defined in ui/mainui.h };[/cpp] The problem is I need a way to get argc and argv (from main()) into QApplication. I can't figure out any dummy values to pass either, or I'd just do that for the time being.
[img]http://dl.dropboxusercontent.com/s/ys50wiolu1zxy57/example_halp.png[/img] Need a little algorithm help. How do I find what rotation/angle the origin should be at in order to "aim" at the target, based on its position? The target would be a moving plane. [editline].[/editline] I think I can use cosine/sine magic.
[QUOTE=Dr. Evilcop;40894589] Need a little algorithm help. How do I find what rotation/angle the origin should be at in order to "aim" at the target, based on its position? The target would be a moving plane. I think I can use cosine/sine magic.[/QUOTE] math.atan2(target.y-origin.y, target.x-origin.x) [url]http://gamedev.stackexchange.com/questions/14602/what-are-atan-and-atan2-used-for-in-games[/url] [url]http://gamedev.stackexchange.com/questions/17105/getting-the-angle-between-two-objects[/url]
[QUOTE=adnzzzzZ;40894843]math.atan2(target.y-origin.y, target.x-origin.x) [url]http://gamedev.stackexchange.com/questions/14602/what-are-atan-and-atan2-used-for-in-games[/url] [url]http://gamedev.stackexchange.com/questions/17105/getting-the-angle-between-two-objects[/url][/QUOTE] The math behind it: [url]http://www.mathsisfun.com/polar-cartesian-coordinates.html[/url]
[QUOTE=adnzzzzZ;40894843]math.atan2(target.y-origin.y, target.x-origin.x) [url]http://gamedev.stackexchange.com/questions/14602/what-are-atan-and-atan2-used-for-in-games[/url] [url]http://gamedev.stackexchange.com/questions/17105/getting-the-angle-between-two-objects[/url][/QUOTE] [QUOTE=Angus725;40895093]The math behind it: [url]http://www.mathsisfun.com/polar-cartesian-coordinates.html[/url][/QUOTE] Thanks! Maybe next time I shouldn't fall asleep in Math class. [editline].[/editline] Also a note for Java users: Java's Math.atan2(x, y) method returns it in radians, so multiply it by (180/Math.PI) to get it in degrees.
[QUOTE=Dr. Evilcop;40894589]-img- Need a little algorithm help. How do I find what rotation/angle the origin should be at in order to "aim" at the target, based on its position? The target would be a moving plane. [editline].[/editline] I think I can use cosine/sine magic.[/QUOTE] Don't forget that if you want to actually hit the plane you would need to calculate how long it takes for the bullet to reach the plane, look where the plane would be when the bullet reaches it, and then use that position to aim at.
[QUOTE=eternalflamez;40896450]Don't forget that if you want to actually hit the plane you would need to calculate how long it takes for the bullet to reach the plane, look where the plane would be when the bullet reaches it, and then use that position to aim at.[/QUOTE] To add to that, my linear algebra/trigonometry/basic physics skills were highly improved after I implemented a few steering behaviors. So maybe you (Dr. Evilcop) wanna look into those some day... [url]http://www.red3d.com/cwr/steer/[/url] [url]http://gamedev.tutsplus.com/tutorials/implementation/understanding-steering-behaviors-seek/[/url]
[QUOTE=eternalflamez;40896450]Don't forget that if you want to actually hit the plane you would need to calculate how long it takes for the bullet to reach the plane, look where the plane would be when the bullet reaches it, and then use that position to aim at.[/QUOTE] I don't want it to have perfect aim, lest the player be killed immediately :v: It works really well, it'll usually land a few hits unless you zoom fast it really fast.
Maybe something for a higher difficulty setting? It'd definitely be interesting to do anyway.
[QUOTE=eternalflamez;40897519]Maybe something for a higher difficulty setting? It'd definitely be interesting to do anyway.[/QUOTE] I dunno, maybe. Here it is in action. Excuse the shitty recording :v: [video=youtube;XFih7Ssycco]http://www.youtube.com/watch?v=XFih7Ssycco[/video]
I need help installing SFML 2.0 to Codeblocks (with MinGW), I've compiled it with Cmake GUI using [URL="http://www.youtube.com/watch?feature=player_detailpage&v=LbWavdiod1Q&list=UUBqRL7l-mZe6R5GgJQ8lWEg"]this[/URL] video. I followed it precisely, making sure I linked all the files correctly etc. However when I run the test program. I get the errors "Sleep is not a member of sf" and "GetElapsedTime is not a member of sf". [IMG]http://gyazo.com/d3d7a706278914f46729015f8f5433e3.png[/IMG] I switched to CodeBlocks because I was having this problem with VS 2012, however with VS 2012 the "[URL="http://www.sfml-dev.org/tutorials/2.0/start-vc.php"]SFML Works[/URL]" example in which only the sfml-graphics lib needed to be included seemed to run okay. I've searched the net quite extensively but I felt it was the time to get some advice to some people that really know their stuff.
[QUOTE=EdAndrew;40900059]I need help installing SFML 2.0 to Codeblocks (with MinGW), I've compiled it with Cmake GUI using [URL="http://www.youtube.com/watch?feature=player_detailpage&v=LbWavdiod1Q&list=UUBqRL7l-mZe6R5GgJQ8lWEg"]this[/URL] video. I followed it precisely, making sure I linked all the files correctly etc. However when I run the test program. I get the errors "Sleep is not a member of sf" and "GetElapsedTime is not a member of sf". [IMG]http://gyazo.com/d3d7a706278914f46729015f8f5433e3.png[/IMG] I switched to CodeBlocks because I was having this problem with VS 2012, however with VS 2012 the "[URL="http://www.sfml-dev.org/tutorials/2.0/start-vc.php"]SFML Works[/URL]" example in which only the sfml-graphics lib needed to be included seemed to run okay. I've searched the net quite extensively but I felt it was the time to get some advice to some people that really know their stuff.[/QUOTE] Try sf:sleep and Clock.getElapsedTime() It's case sensitive
[QUOTE=EdAndrew;40900059]I need help installing SFML 2.0 to Codeblocks (with MinGW), I've compiled it with Cmake GUI using [URL="http://www.youtube.com/watch?feature=player_detailpage&v=LbWavdiod1Q&list=UUBqRL7l-mZe6R5GgJQ8lWEg"]this[/URL] video. I followed it precisely, making sure I linked all the files correctly etc. However when I run the test program. I get the errors "Sleep is not a member of sf" and "GetElapsedTime is not a member of sf". [IMG]http://gyazo.com/d3d7a706278914f46729015f8f5433e3.png[/IMG] I switched to CodeBlocks because I was having this problem with VS 2012, however with VS 2012 the "[URL="http://www.sfml-dev.org/tutorials/2.0/start-vc.php"]SFML Works[/URL]" example in which only the sfml-graphics lib needed to be included seemed to run okay. I've searched the net quite extensively but I felt it was the time to get some advice to some people that really know their stuff.[/QUOTE] SFML 2.0 member functions are all [url=http://en.wikipedia.org/wiki/CamelCase]camelCase[/url] (Clock.getElapsedTime()) [editline]4th June 2013[/editline] rate late mate
[QUOTE=EdAndrew;40900059]I need help installing SFML 2.0 to Codeblocks (with MinGW), I've compiled it with Cmake GUI using [URL="http://www.youtube.com/watch?feature=player_detailpage&v=LbWavdiod1Q&list=UUBqRL7l-mZe6R5GgJQ8lWEg"]this[/URL] video. I followed it precisely, making sure I linked all the files correctly etc. However when I run the test program. I get the errors "Sleep is not a member of sf" and "GetElapsedTime is not a member of sf". I switched to CodeBlocks because I was having this problem with VS 2012, however with VS 2012 the "[URL="http://www.sfml-dev.org/tutorials/2.0/start-vc.php"]SFML Works[/URL]" example in which only the sfml-graphics lib needed to be included seemed to run okay. I've searched the net quite extensively but I felt it was the time to get some advice to some people that really know their stuff.[/QUOTE] If you're using the latest version of SFML, the library's naming convention has changed. sf::Sleep() should be sf::sleep() clock.GetTimeElapsed() should be clock.getTimeElapsed() [editline]4th June 2013[/editline] ultra ninja'd
[QUOTE=adnzzzzZ;40896488]To add to that, my linear algebra/trigonometry/basic physics skills were highly improved after I implemented a few steering behaviors. So maybe you (Dr. Evilcop) wanna look into those some day... [url]http://www.red3d.com/cwr/steer/[/url] [url]http://gamedev.tutsplus.com/tutorials/implementation/understanding-steering-behaviors-seek/[/url][/QUOTE] Was clicking around when I found this link: [url]http://www.ping.be/math/vect.htm[/url] I took a proper linear algebra course 2 semesters ago, had nightmares from vector spaces in R^n... For whatever reason, my prof decided that it would be better to go directly to an abstract vector space in a higher dimension then using 2D/3D vectors to help visualize what was going on.
@ief014;@MakeR;@Kamil_ Thanks, I didn't know the naming convention had changed. I got the samples from the SFML website and from all the websites I've been on and all the videos I've watched trying to fix my problem. They all seemed to be using the old naming convention for some reason. I'm now going to compile SFML for VC 2012 again and give that a shot, since I know it's not an issue with that. However I'm confident you've solved all my problems.
[QUOTE=eternalflamez;40896450]Don't forget that if you want to actually hit the plane you would need to calculate how long it takes for the bullet to reach the plane, look where the plane would be when the bullet reaches it, and then use that position to aim at.[/QUOTE] [QUOTE=Dr. Evilcop;40897384]I don't want it to have perfect aim, lest the player be killed immediately :v: It works really well, it'll usually land a few hits unless you zoom fast it really fast.[/QUOTE] For nightmare mode, you could use this. Equate the bullet's and the plane's trajectories [img]http://latex.codecogs.com/gif.latex?\overrightarrow{x_b}%20+%20\overrightarrow{v_b}t%20=%20\overrightarrow{x_p}%20+%20\overrightarrow{v_p}t[/img] (1) Reorder, split the bullet's velocity to a speed and a direction [img]http://latex.codecogs.com/gif.latex?V%20\overrightarrow{u_b}t%20=%20\overrightarrow{x_p}%20+%20\overrightarrow{v_p}t%20-%20\overrightarrow{x_b}[/img] Square the direction away [img]http://latex.codecogs.com/gif.latex?V^2t^2%20=%20\overrightarrow{x_p}^2%20+%20\overrightarrow{x_b}^2%20-%202\overrightarrow{x_p}%20\overrightarrow{x_b}%20+%202(\overrightarrow{x_p}\overrightarrow{v_p}%20-%20\overrightarrow{v_p}\overrightarrow{x_b})t%20+%20\overrightarrow{v_p}^2t^2[/img] Reorder [img]http://latex.codecogs.com/gif.latex?V^2t^2%20-%20\overrightarrow{v_p}^2t^2%20-%202(\overrightarrow{x_p}\overrightarrow{v_p}%20-%20\overrightarrow{v_p}\overrightarrow{x_b})t%20+%202\overrightarrow{x_p}%20\overrightarrow{x_b}%20-%20\overrightarrow{x_b}^2%20-%20\overrightarrow{x_p}^2%20=%200[/img] Let [img]http://i.imgur.com/UOEcLky.gif[/img] then [img]http://latex.codecogs.com/gif.latex?At^2%20+%20Bt%20+%20C%20=%200[/img] and finally [img]http://latex.codecogs.com/gif.latex?t%20=%20\frac{B%20\pm%20\sqrt{B^2%20-%204AC}}{2A}[/img] From (1), solve the direction now that t is known [img]http://latex.codecogs.com/gif.latex?\overrightarrow{u_b}%20=%20\frac{\overrightarrow{x_p}%20-%20\overrightarrow{x_b}}{Vt}%20+%20\frac{\overrightarrow{v_p}}{V}[/img] In code: [cpp]// Return value is true if there is a trajectory with which you can hit the target, false if not. bool trajectory( vec2 *out_direction, // Output direction to shoot at float *out_time, // Output time until the bullet is supposed to hit vec2 pos, float speed, // Input own position and muzzle speed vec2 target_pos, vec2 target_vel) // Input target position and target velocity { float a = speed * speed - vec2::dot(target_vel, target_vel); float b = -2.0f * (vec2::dot(target_pos, target_vel) - vec2::dot(target_vel, pos)); float c = 2.0f * vec2::dot(target_pos, pos) - vec2::dot(pos, pos) - vec2::dot(target_pos, target_pos); float d = b*b - 4*a*c; if (d < 0.0f) { // No real solution return false; } d = sqrtf(d); float t0 = (b + d) / (2.0f * a); float t1 = (b - d) / (2.0f * a); // Find the positive solution. float t; if (t1 >= 0.0f) { t = t1; } else if (t0 >= 0.0f) { t = t0; } else { // No positive solution return false; } *out_time = t; *out_direction = (pos - target_pos) / (speed * t) + target_vel / speed; return true; }[/cpp]
[QUOTE=Angus725;40900238]Was clicking around when I found this link: [url]http://www.ping.be/math/vect.htm[/url] I took a proper linear algebra course 2 semesters ago, had nightmares from vector spaces in R^n... For whatever reason, my prof decided that it would be better to go directly to an abstract vector space in a higher dimension then using 2D/3D vectors to help visualize what was going on.[/QUOTE] That reason is that (and I'm not entirely sure if this is true, but from my experience it seems to be) mathematicians usually learn some general theory about something by working their way up and proving stuff from basic axioms. If you've ever read a math heavy book you'll notice that to introduce new concepts they use previously introduced (and properly explored/proved) ones. Which tends to be counter-intuitive to most people, since they usually pick things up differently, as explained [URL="http://chrishecker.com/Physics_references"]here[/URL]: [QUOTE]The way different people learn a complex subject like dynamics is an interesting topic by itself, and I don't think any two people do it the same way. I know I learn in what my friend Casey calls a "depth-first" manner--if I come across a sentence or equation I don't understand, I'll pound on it and read other books about that single topic until I understand it, and then move on. Casey, by contrast, learns in a "breadth-first" manner. He tries to get the big picture first, and will read through an entire article, even if there's stuff in it he doesn't understand. Then he goes back to fill in the holes as he works with the material. I think more people learn breadth-first, so I'm organizing the bibliography to suit that style, but don't worry, there's more than enough depth herein for us depth-first-ers. [/QUOTE] And [URL="http://c2.com/cgi/wiki?BreadthFirstLearning"]here[/URL]. It is my guess that mathematicians are trained to go by depth first, so your teacher probably thought that that would be the better way to teach, since it's the way he's used to while learning.
can anyone tell me something to program i have no ideas for anything i know some python and c
I have lots of objects to send over a network (player entities for example), what is the most effecient way of handling them sending from server to client? Only send the ones where their data has changed?
[QUOTE=hogofwar;40905587]I have lots of objects to send over a network (player entities for example), what is the most effecient way of handling them sending from server to client? Only send the ones where their data has changed?[/QUOTE] It depends on the exact kind of game you're making. There's no catch-all solution.
[QUOTE=Meatpuppet;40904520]can anyone tell me something to program i have no ideas for anything i know some python and c[/QUOTE] How about grabbing some bug-reports of some project that is written in C or Python, debugging them and submitting patches?
[QUOTE=Tamschi;40906848]It depends on the exact kind of game you're making. There's no catch-all solution.[/QUOTE] Oh yeah, currently it's just lots of player positions with just coordinates in the player objects, nothing more complicated than that.
[QUOTE=hogofwar;40909681]Oh yeah, currently it's just lots of player positions with just coordinates in the player objects, nothing more complicated than that.[/QUOTE] In that case put as many of the most important (longest time since last update/proximity to player) updates into a single UDP packet and send it as often as the connection permits while there is still new data. Make sure you choose a packet size that isn't split in the network, you can probe for this if you make it discard instead of split afaik. Put in a sequence number too, that way you can discard outdated updates to a value. Edit: It's possibly also a good idea to limit the maximum bandwidth, that way you won't have to deal with excessive dropped packets when there are many updates.
Sorry, you need to Log In to post a reply to this thread.