Jump to content
  • Advertisement

DraganO

Member
  • Content Count

    84
  • Joined

  • Last visited

Everything posted by DraganO

  1. DraganO

    Help with c++ windows

    Quote:Original post by OneThreeThreeSeven I noticed that they used ((LPCREATESTRUCT)lParam)->hInstance To get the instance. But exactly what does that mean? This is basically a shorter version for something like this: LPCREATESTRUCT pTemp = (LPCREATESTRUCT)lParam; pTemp->hInstance; So, it's just a cast and accessing the member variable of a pointer combined. Also, it's quite obvious that you don't really know a lot about C++. I really recommend you to make sure you know your language inside out (or at LEAST know the most important syntax), before you try to move on and program something bigger, or you will hit a lot more obstacles on your way.
  2. DraganO

    Flowcharting

    here and here
  3. DraganO

    Confused about Exceptions

    If your running out of memory your exception handler itself will throw an out of memory exception. But it certainly depends on what kind of exception you are handling: If you're handling an out of memory exception, you probably shouldn't allocate memory
  4. Quote:Original post by Andy474 the filename variable is passed as a parameter int ShowDialog(string filepath, string param, string Directory) {} No. int ShowDialog(string filepath, string param, string Directory) { using( Process process = Process.Start( newProcessStartInfo( filename, param ) ) ) Quote:Original post by Andy474and the Double Quote marks apparently have something to when entering System addresses with spaces. (look at the link) Yeah, the system will break commands at spaces. So if you for example pass a path, with spaces in it, as a commandline argument, it will be split at the spaces and passed as multiple arguments. To prevent this, you have to enclose those paths with quotation marks to tell the system not to split them. Since your starting your string literals with a @ sign, you have to write a double quotation mark to insert a single one in the string. (look here) But this doesn't change the fact that this string: "@"\""C:\Users\Alex\Desktop\Cricket Scorebook\"is broken and will give you a compiler error. So the code you provided does NOT compile! But you tell us you get runtime errors when you run it, which means this code can, under no circumstances, be the exact code you are having trouble with. And as long as nobody on the forums has a crystal ball at hand, nobody will be able to help you until you post the actual code you're having issues with.
  5. Quote:Original post by Andy474 and When I Run this Code, the Code Breaks and ... How can you run this code? It's totally broken and won't compile. For example, your quotation marks are wrong and you are using a "filename" variable in your "ShowDialog" function that isn't defined anywhere.
  6. Quote:Original post by Crazyfool3. How can I tell if its the GPU? We thought it might have been the graphics card (and it might be), but the players wont lag when around a lot of different npcs, or with a lot of items equipped (items are all separate sprites). One thing I tend to do before I send any of my games to someone ot test it, is this: I first display the framerate somewhere on the screen so anyone will be able to tell me what framerates they are getting on their computer. Then I build in a "pause" key, that will immediately stop all gamelogic while it is pressed, something like this. void Frame() { if(!PauseKeyPressed()) { GameLogic(); } Render(); } So while the key is pressed the game won't update its state but only render and if it is GPU bound the framerate won't change, if it is CPU bound the framerate goes up (assuming you don't to any fancy calculations with your CPU inside your rendering function). This will at least point you in the general direction of where the problem lies, but you will need to do more profiling to see exactly what is causing your slowdown. What I really like about it is that everyone can do this. It tends to be quite hard to gather information if you don't have direct access to the computer that is experiencing the problem. Most people just will tell you that your game "runs slow and is crap" and won't be of any further use. But most of them will be able to tell you what framerate is displayed in the corner of the screen and if it changes when they press the 'p' key. I'm not sure if this is so easily possible to do in a networked game or if your using multiple threads.
  7. DraganO

    The Brainfuck programming language

    Quote:Original post by Sc4Freak 1) it's actually quite difficult to generate a BF program that isn't valid Isn't this already invalid?^^ < The datapointer is starting at 0 and I always thought most brainfuck implementations didn't allow a negative datapointer. :P Edit: Thinking about this again, I came to the conclusion, that this actually IS a valid bf program, it's probably just going to crash on you...^^
  8. DraganO

    C++ Coursework Timeline Advice

    Quote:First, does C++ have an exponent operator? No, use pow() instead. Don't make the mistake to use "^", it's the bitwise xor operator. Quote:Second, is there a way to validate input from cin? While researching it I saw some other iostream things, but I couldn't find a way to do even simple numerical validation. The console goes crazy if it gets a character in place of a number :-). You can use stringstreams for that, take a look at this code: #include <iostream> #include <string> #include <sstream> int main() { int number = 0; std::string input; std::cin >> input; std::stringstream sstream(input); if(sstream >> number) { std::cout << "It's a number!" << std::endl; std::cout << "You entered: " << number << std::endl; } else { std::cout << "It's not a number!" << std::endl; } return 0; } Quote:I'm currently on an "at least one a day" kind of schedule, but to keep my interest up I'd also like to make some goals for simple games (from simple text based to basic 2d), and am looking for some estimates of the typical time it would take to start making games with graphics [i.e, graduating from the console]. This depends on your background, have you done anything similar with other languages or are you totally new to all this? Either way, I strongly recommend you to take your time to learn your language first before you reach for more. I actually made this mistake myself, I got a C++ book (back in the days where not everybody had internet and the world was still black and white...), read it, made a few examples and then tried to do some "cool stuff". Writing a game, even a simple one, is already a lot to swallow, but becomes insanely hard if you're still struggling with your programming language and have to constantly look something up in your book, because you forgot what the syntax is to write a switch-statement or declare and dereference a pointer, etc...
  9. DraganO

    Begining audio portion of Game

    It might also be of interrest to you how DirectSound handles the volume of its 3D buffers.They are using two ranges, a minimum and a maximum distance. Minimum and Maximum Distances But this might be overkill for you if your current technique is all you need.
  10. DraganO

    linker problem: LNK 2005

    Quote:main.cpp includes: collision.cpp. Do you means this or is this just a typo? Quote:i get the following error: Are you using inclusion guards? Have a look at this article.
  11. DraganO

    D3DCREATE_MULTITHREADED ??

    Google is your friend!
  12. DraganO

    Is there a bug here?

    Quote:Original post by Plethora So I take it that I cannot do this via a simple container of references? Nope you have a vector of Objects that should look something like this: std::vector<Object> SomeVector; If you add any Object to the vector it will be copied and the copy will be stored in the vector. If you then change this stored copy your changes will not effect the original object. If you wanted to store a reference you would have to do something like this (WHICH IS NOT ALLOWED!!!): std::vector<Object&> SomeVector; But if you have a central vector where you store all monsters currently in game, you could use vectors of pointers (or preferably smartpointers) for every player, that point to the monsters that belong to the player that owns the vector, like this: std::vector<Object*> OwnedMonsters; If you copy a pointer, the object it was pointing to is unaffected, i.e. doesn't get copied. But you also have to consider that this is potentially dangerous, since if you remove a monster from you central vector, pointers to that objcet will still point to the memory of the object and if you still try to use that pointer, all hell will break loose on you. So you have to somehow take care that your pointers always point to valid objects. Welcome to the wonderful world of pointers.^^ Edit: Ninja'd [Edited by - DraganO on June 25, 2009 2:22:49 AM]
  13. DraganO

    pls help me with this c++ error

    Quote:Original post by Hodgman You've added a function to the class 'space' named 'display'... but you didn't implement the function in a CPP file? !
  14. Quote:Original post by phresnel Quote:Original post by DraganO Oh, come on guys... Okay, I admit that my choice of words was a bit inauspicious. What I meant to say is that a valid C program is also (at least most of the time) a valid C program But, but, a valid C program is always a valid C program *ducks and covers* *throws shoe and misses* So, for the record: a valid C program is most of the time a valid C++ program Well at least ToohrVyk got his proof now.^^
  15. Oh, come on guys... Okay, I admit that my choice of words was a bit inauspicious. What I meant to say is that a valid C program is also (at least most of the time) a valid C program, since the OP was about if it is possible to read and understand C code with C++ knowlege, which most certainly is the case. I did add the link to point out that there are differences, but they are irrelevant if he doesn't want to compile C code as C++ code, but only read it. Quote:Out of respect for my fellow forum members, I will choose the explanation that assumes the least stupidity on their parts—DraganO may feel free to prove me wrong Actually I am quite known to behave stupid frequently, so you won't have to wait long for proof.^^ Parkinson's Law of Triviality
  16. Since C++ merely extends C, every valid C program is also a valid C++ program. So if you can read and write C++ code you should have no problem at all grasping C code, you don't have to "teach yourself c syntax". (There are a few subtle differences.) But you might be better off picking up a book that uses C++ and an OO approach instead. I guess I can't really recommend you a book since most of my books are in german.^^
  17. DraganO

    Vista and running games on it

    There is a pretty good article on msdn addressing this problem: User Account Control for Game Developers
  18. DraganO

    Hiccups as I walk between tiles...

    Quote:Original post by _fastcall I agree with Endurion; the problem could lie here. Except, you could just set the position to the target position instead of the minimum delta that is required to move the position to the target position. [smile] Try this: *** Source Snippet Removed *** Coming soon: A refactoring of your code snippet so you don't have to change your code in four places! That's just needlessly complicated. If you simply check if the player moved to far after you actually moved him, you won't need to predict anything. So just move him, THEN check if he moved too far. If so move him back. And THEN render.
  19. DraganO

    Hiccups as I walk between tiles...

    The code is quite simple and looks okay, so I don't think it is wrong. The player shouldn't be able to walk beyond a tile. The only thing i can think of: Maybe you're rendering at the wrong time. Are you sure you are: 1. Moving the player. 2. Checking it's position against the target tile. 3. Rendering your scene. In that order? Also prepare to get flamed for using the word "manager" in a variable name.^^
  20. DraganO

    Understanding Recursion

    Have you tried to step through the code with a debugger? Recursion might seem difficult and complicated at first, but if you get used to it it becomes easier. So recursiveMinimum() is calling itself over and over again with all of its arguments unchanged except for its low argument, that is incremented with every call, i.e. the deeper the recursion, the higher is low. The last recursive call to recursiveMinimum() (where low = high = 9) returns the last integer stored in a[] (i.e. a[9] = 5). After the function returns, execution resumes in the penultimate call of recursiveMinimum() at the line where the last recursive call was made. The penultimate call to recursiveMinimum() (where low = 8) takes the returned value, stores it in "min" and compares it against the value stored in a[] at the index 8 and returns the smaller of both values. Then, one level higher in the recursion, this value gets compared against the value a[] at the index 7. This goes on until the programm reaches the first call of recursiveMinimum() and on this way it is alway returning the smallest value in a[] until then (from behind). So basically what this code does is to take the last two values stored in a[], keeps the the smaller one of the two and discards the bigger one. Then it compares the value it kept agains the third value from behind and keeps the smaller one and compares it against fourth value from behind and keeps the smaller one of both and so on until it reaches the first value. I hope this helped and I made myself clear, feel free to ask of anything is still unclear.
  21. static float distance = 10.0f; static float horiangle = 0.0f; static float vertangle = 0.0f; static float camrightangle = 0.0f; static float xpos = 0.0f; static float zpos = 0.0f; static float ypos = 0.0f; static float rotationx = 0.0f; static float rotationy = 0.0f; static float rotationz = 0.0f; static float xright = 1.0f; static float yright = 0.0f; static float zright = 0.0f; if(KEY_DOWN(VK_UP) && distance >= 7.0f) { distance -= 0.5f; } if(KEY_DOWN(VK_DOWN)) { distance += 0.5f; } if(KEY_DOWN(VK_RIGHT) && KEY_UP(VK_SHIFT)) { horiangle += 4.0f; } if(KEY_DOWN(VK_LEFT) && KEY_UP(VK_SHIFT)) { horiangle -= 4.0f; } if(KEY_DOWN(VK_PRIOR) && vertangle > -90) { vertangle -=3.0f; } if(KEY_DOWN(VK_NEXT) && vertangle < 90) { vertangle +=3.0f; } if(KEY_DOWN(VK_RIGHT) && KEY_DOWN(VK_SHIFT)) { camrightangle += 4.0f; } if(KEY_DOWN(VK_LEFT) && KEY_DOWN(VK_SHIFT)) { camrightangle -= 4.0f; } xpos = distance * sin(D3DXToRadian(horiangle)) * cos(D3DXToRadian(vertangle)); ypos = distance * sin(D3DXToRadian(vertangle)) ; zpos = distance * cos(D3DXToRadian(horiangle)) * cos(D3DXToRadian(vertangle)); xright = sin(D3DXToRadian(horiangle-90)); yright = 0.0f; zright = cos(D3DXToRadian(horiangle-90)); D3DXMATRIX matView; // the view transform matrix D3DXVECTOR3 CamPos(xpos, ypos, zpos); D3DXVECTOR3 LookAt(0.0f, 0.0f, 0.0f); D3DXVECTOR3 Right(xright, yright, zright); D3DXVECTOR3 ViewVec = LookAt - CamPos; D3DXVECTOR3 Up; D3DXVec3Cross(&Up, &Right, &ViewVec); D3DXVec3Normalize(&Up, &Up); D3DXMatrixLookAtLH(&matView, &CamPos, // the camera position &LookAt, // the look-at position &Up); // the up direction D3DXMATRIX matRoll; D3DXMatrixRotationZ(&matRoll, D3DXToRadian(camrightangle)); matView *= matRoll; This should work. But first I'll try to explaining it (I'm not so good at explaining complicated stuff in english, but I'll give it a try :P). Its pretty important, that you understand what this does. You computed your 'right' vector like this. xright = xpos + distance * sin(D3DXToRadian(camrightangle)) * sin(D3DXToRadian(horiangle)); yright = ypos + distance * cos(D3DXToRadian(vertangle)) ; zright = zpos + distance * cos(D3DXToRadian(camrightangle)) * sin(D3DXToRadian(horiangle)); This is nonsense since your 'right', 'up' and your cameras view direction should build a relative coordinate system that defines the camera space that your hole scene ist transformed into during rendering. So they should have the lenght 1 and be perpendicular (at least in this case since you don't want to scale or stretch the hole scene). You computed a vector from the origin to a point somewhere near the camera, rather than a vector representing the new coordinate spaces' x vector after transformation. I also didn't directly rotate the right and up vectors by camrightangle to create the roll effect you wanted, but rather ignored roll and set the camera only up to face the box and applied a rotation around the z-axis after camera transformation, since this is a lot easier to do. Like this: D3DXMATRIX matRoll; D3DXMatrixRotationZ(&matRoll, D3DXToRadian(camrightangle)); matView *= matRoll; I simply created a rotation matrix that will rotate the hole scene around the z-axis (using D3DXMatrixRotationZ())and multiplied it to the camera matrix. This way the hole scene will be first transformed to camera space and then rotated around the z-axis (which is you cameras viewing direction in camera space). I don't think I made things cristal clear, but just ask if you have problems with this. Also it might help you to understand if you read up a bit about linear transformations and matrices in general and about the DirectX transformation pipeline. MSDN - Transformations
  22. DraganO

    How to handle "DeviceLost"

    Lost Devices You will have to reload the device and then reload all your resources that were allocated in the default pool with the new device. If you get the error "Fehler in der Anwendung", this means you did something wrong and without a look at your code nobody will be able to tell you what it is. Also MDX is as dead as it can possibly be. It has not even been included in the DirectX SDK for a long time now. You should consider to use XNA or SlimDX instead.
  23. You are loading the texture every frame from your hard drive when you call CreateTexture() and override the pointer that points to the texture you created the previous frame (texture_1). This is called am memory leak since your program hasn't any means anymore to free the memory of the texture from the last frame and this memory is lost. So your use of memory is increasing during runtime. But when you release the texture every frame this doesn't happen since you freed the memory your pointer was pointing to before you overwrite it again. Therefore your program doesn't leak memory any more. But loading your texture every frame is, like I already said, very unefficient and slow. So try instead to remove the CreateTexture() and the release() call from your rendering function and load the texture at program start (i.e. before your main loop starts), keep the pointer and pass it to your render function every frame and release it when your program ends (after your mainloop). Basically your init_graphics() function is supposed to be called only ONCE to create your texture and vertex buffer and you should release them also only once after your main loop. If anything is still unclear, feel free to post here again, I will try to elaborate. And BTW this is exactly the kind of problem many people encounter who learn from directxtutorial.com. You might be better off buying a good DirectX book that will teach you right.
  24. Quote:I'm pretty sure it'll be due to your specifying the 'up' vector in D3DXMatrixLookAtLH() as being (0,1,0). I second. Try to calculate a up vector rather than using a static one. Try this to compute your view matrix: D3DXMATRIX matView; // the view transform matrix D3DXVECTOR3 CamPos(xpos, ypos, zpos); D3DXVECTOR3 LookAt(0.0f, 0.0f, 0.0f); D3DXVECTOR3 Right(1.0f, 0.0f, 0.0f); D3DXVECTOR3 ViewVec = LookAt - CamPos; D3DXVECTOR3 Up; D3DXVec3Cross(&Up, &Right, &ViewVec); D3DXVec3Normalize(&Up, &Up); D3DXMatrixLookAtLH(&matView, &CamPos, // the camera position &LookAt, // the look-at position &Up); // the up direction d3ddev->SetTransform(D3DTS_VIEW, &matView); // set the view transform to matView This uses a static right vector to compute a up vector by taking the cross product of your view direction and the right vector. But note, that this will no longer work if you change your camera code to enable panning. Then you will have to use a variable right vector that you compute from your camera orientation. Also, from your code I can see that you are loading and releasing your texture every frame. This is terribly slow and inefficient and you should rather load it once at the program start, keep it during program execution and release it at the end of the program. Edit: Changed the code to make it more understandable.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!