Jump to content
  • Advertisement

Rhaal

Member
  • Content Count

    1385
  • Joined

  • Last visited

Community Reputation

754 Good

About Rhaal

  • Rank
    Contributor

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Rhaal

    c++, "combining" variables..

    In the sake of instilling good programming practices early on, I'm more curious as to what you're trying to achieve by doing this? Why do you need A to be B, and B to be A? I think you're just going to confuse yourself more by programming this way.
  2. Typical.. I post and then solve it :) For anyone else with the problem, calling cpSpaceFree instead of cpSpaceDestroy fixes it. (Though it seems like this should cause a crash/memory leak, not the problem I had.)
  3. I'd love to ask this on the official Chipmunk physics forums, but I can't get a verification email for my forum registration over there :( Does anyone have experience with the Chipmunk 2D physics engine? I am trying to create a level editor for my game that uses Chipmunk, but I can't for the life of me figure out how to "turn off" gravity and restart it. My goal is: - The editor starts with no gravity. Levels are edited this way. - "Play" is pressed, and gravity kicks in. Level is tested this way. - "Stop" button is pressed, and gravity goes back to zero and the level is reloaded, for editing again. The problem is every time I press play, the gravity seems to increase as shapes fall incredibly fast. Here is how I start gravity: // Yes, cpInitChipmunk() is called before any of this. void State_Playing::StartGravity() { g_pSpace = cpSpaceNew(); g_pSpace->gravity = cpv(0, 0); g_pSpace->elasticIterations = 5; SetTimer(NULL, 1, 1.0f / 60.0f, TimerProc); } Here's how I remove shapes and stop gravity: void State_Playing::StopGravity() { // all Block's deconstructors called here... cpSpaceDestroy(g_pSpaceNew); g_pSpace = cpSpaceNew(); g_pSpace->gravity = cpv(0, 0); g_pSpace->elasticIterations = 5; } // Block deconstructor Block::~Block() { // Free shape if(fixed) cpSpaceRemoveStaticShape(space, shape); else cpSpaceRemoveShape(space, shape); // Free body cpSpaceRemoveBody(space, body); // Free sprite delete sprite; } It all appears to work, but every time I call the stop function, and then the start function everything falls faster. I can't narrow it down to gravity increasing or mass increasing (though I'm removing all the shapes!). Any clue? Is there some kind of cpShutdownChipmunk function? My only other option is to have two separate apps, a level editor and a level tester - which would be much less productive.
  4. Rhaal

    Decelerate Golf Ball

    I've been working on a 2D Mini-Golf game but I'm getting stuck on decelerating the ball after it's been hit. My research has lead me to this formula: Deceleration = (Original Velocity - Final Velocity) / Time I've plugged this into my code, however I'm confused on a couple things as it's not working properly. 1) Final velocity is zero right? I want the ball to stop. 2) Time: Is this time since the last frame, or time elapsed since the ball was hit? 3) Deceleration: What do I do with the deceleration? Do I multiply the velocity by it? Is the Deceleration the new velocity? I'm having a hard time grasping the concepts. When I tried to do it on my own, I was just subtracting 10% of the current speed, which obviously never got to 0. So can someone explain simply ball-rolling deceleration? I don't care about grass or wind friction. Thanks.
  5. Rhaal

    Points Distance from Center of Circle

    Thanks guys, it works now :) Part of the problem was that I was using this API's (HGE) version of printf, and I used a %d instead of %f to output my distance. Dividing by the radius gave me my ratio. I'm not doing collision detection, but rather trying to implement a color wheel.
  6. I'm having a hard time figuring out an equation, and even then figuring out how to use it :( Let's say I have a circle and the diameter is 200 pixels. I render this circle at 0,0 in my window. Thus, the center is at 100, 100. When the mouse is on this circle, I want to know how far away from the center the cursor currently is. I found this equation: sqrt((x-x1)^2 + (y-y1)^2) In my c++ code, I write this as follows: m_fDistanceFromCenter = sqrt(pow(m_fMouseX - fCenterX, 2) + pow(m_fMouseY - fCenterY, 2)); However, sometimes the distance is 0 even when I'm clearly not pointing at the center. Other times, the number is about 10 digits long. First question: What am I doing wrong to get 0 sometimes? Second question: How do I convert the 10 digit string to a ratio from 0.0 to 1.0? Any insight is greatly appreciated!
  7. Rhaal

    HGE Website

    Is anyone able to login or register for an account at HGE? I'm desperately trying to login and it says I can't because my account is inactive, and to contact the administrator. Neither of the 2 administrator emails work. Trying to register for an account and I never get the confirmation email. Sorry if this is a bad place to post this but I think there may be a chance Prof Eclipse comes by it and can figure this out? Great engine, but no support if the site can't get new users, or old ones can't login :(
  8. Rhaal

    How am I wrong?

    Wow you guys jumped all over it :) Thanks. I guess I'll plug this into some code and step through it. I never really messed with an array of classes - haven't had the need to. Guess I have the wrong understanding of what an exception is, so I'll study up there too. Edit: Stonemetal, while I appreciate the insight there's no need to be a dick.
  9. Can someone explain to me how I got this answer wrong? This was on a test for a position I was trying for, but I really don't think it's wrong. "On some embedded systems that may not have full exception handling capabilities, what is the potential problem with the following code snippet?" void GetValue(void) { CClass *pcClass; pcClass = new CClass[3]; pcClass[0].m_nMember = 1; pcClass[1].m_nMember = 3; pcClass[2].m_nMember = 5; delete [] pcClass; } My answer: When accessing member variables of pcClass, you should use the “->” operator, not the “.” operator. Now I understand there may be a problem with dereferencing an invalid pointer, but 1 - How is that even possible with this exact code? They're all alocated so they are not invalid - and 2 - How is my answer "wrong"? Thanks for any insight. I must be crazy.
  10. Rhaal

    Detecting Video Card

    Ok I'm able to get the Description and Pixel Shader version, but I can't figure out how to get the VRAM size. How do I determine if they have a big enough video card in that regard? (128 MB / 512 MB etc). It doesn't seem to be a part of D3DCAPS9.
  11. Rhaal

    HELP! Can't find the error!

    Quote:Original post by sourcreamandcurtains It doesn't matter that o's turn goes after x, because a tie checks if turns are above 8, and o's turn doesn't occur if the turns are above 8 either. Sure it does. O's turn should not go after X if X just won the game. The game is over and nobody's turn should occur. And x | x | x | | | o | o | x | o | X just won in 7 moves.
  12. Rhaal

    HELP! Can't find the error!

    You should put your code in [source] [/source] tags like this: #include<iostream> #include<string> using namespace std; char space [9]={' ',' ',' ',' ',' ',' ',' ',' ',' '},again='y',turn='X', win='n',redo='n'; int num,turnnum=0,pass=1; string box; void out() { cout<<"\t \t|\t \t|\t \n"; cout<<"\t"<<space[0]<<"\t|\t"<<space[1]<<"\t|\t"<<space[2]<<"\n"; cout<<"\t \t|\t \t|\t \n"; cout<<"------------------------------------------------\n"; cout<<"\t \t|\t \t|\t \n"; cout<<"\t"<<space[3]<<"\t|\t"<<space[4]<<"\t|\t"<<space[5]<<"\n"; cout<<"\t \t|\t \t|\t \n"; cout<<"------------------------------------------------\n"; cout<<"\t \t|\t \t|\t \n"; cout<<"\t"<<space[6]<<"\t|\t"<<space[7]<<"\t|\t"<<space[8]<<"\n"; cout<<"\t \t|\t \t|\t \n"; cout<<"\t(Columns 1,2,3 and Rows A,B,C)\n"; cout<<endl; } void boxselect() { if ((box=="A1")&&(space[0]==' ')) space[0]=turn, redo='n'; else if ((box=="a1")&&(space[0]==' ')) space[0]=turn, redo='n'; else if ((box=="A2")&&(space[1]==' ')) space[1]=turn, redo='n'; else if ((box=="a2")&&(space[1]==' ')) space[1]=turn, redo='n'; else if ((box=="A3")&&(space[2]==' ')) space[2]=turn, redo='n'; else if ((box=="a3")&&(space[2]==' ')) space[2]=turn, redo='n'; else if ((box=="B1")&&(space[3]==' ')) space[3]=turn, redo='n'; else if ((box=="b1")&&(space[3]==' ')) space[3]=turn, redo='n'; else if ((box=="B2")&&(space[4]==' ')) space[4]=turn, redo='n'; else if ((box=="b2")&&(space[4]==' ')) space[4]=turn, redo='n'; else if ((box=="B3")&&(space[5]==' ')) space[5]=turn, redo='n'; else if ((box=="b3")&&(space[5]==' ')) space[5]=turn, redo='n'; else if ((box=="C1")&&(space[6]==' ')) space[6]=turn, redo='n'; else if ((box=="c1")&&(space[6]==' ')) space[6]=turn, redo='n'; else if ((box=="C2")&&(space[7]==' ')) space[7]=turn, redo='n'; else if ((box=="c2")&&(space[7]==' ')) space[7]=turn, redo='n'; else if ((box=="C3")&&(space[8]==' ')) space[8]=turn, redo='n'; else if ((box=="c3")&&(space[8]==' ')) space[8]=turn, redo='n'; else cout<<"Pick Again...\n",redo='y'; //endif } void checkwin() { if ((space[0]==turn)&&(space[1]==turn)&&(space[2]==turn)) win=turn; else if ((space[3]==turn)&&(space[4]==turn)&&(space[5]==turn)) win=turn; else if ((space[6]==turn)&&(space[7]==turn)&&(space[8]==turn)) win=turn; else if ((space[0]==turn)&&(space[3]==turn)&&(space[6]==turn)) win=turn; else if ((space[1]==turn)&&(space[4]==turn)&&(space[7]==turn)) win=turn; else if ((space[2]==turn)&&(space[5]==turn)&&(space[8]==turn)) win=turn; else if ((space[0]==turn)&&(space[4]==turn)&&(space[8]==turn)) win=turn; else if ((space[2]==turn)&&(space[4]==turn)&&(space[6]==turn)) win=turn; if (win=='X') cout<<"X Wins!\n"; else if (win=='O') cout<<"O Wins!\n"; } void xturn() { cout<<"X's Turn!\n"; cout<<"Line 96 "<<turnnum<<" "<<pass<<endl; turn='X'; cin>>box; boxselect(); out(); checkwin(); } void oturn() { if ((turnnum<8)&&(win=='n')) { cout<<"O's turn!\n"; turn='O'; cin>>box; boxselect(); out(); //} checkwin(); } } void reset() { space [0]=' '; space [1]=' '; space [2]=' '; space [3]=' '; space [4]=' '; space [5]=' '; space [6]=' '; space [7]=' '; space [8]=' '; again='y'; turn='X'; win='n'; redo='n'; turnnum=0; out(); } int main() { out(); while (again=='y') { win='n'; while ((turnnum<8)&&(win=='n')) { redo='y'; while (redo=='y') xturn(); turnnum=turnnum+1; cout<<"Line 150 "<<turnnum<<" "<<pass<<endl; redo='y'; while (redo=='y') oturn(); turnnum=turnnum+1; pass=pass+1; cout<<"Line 157 "<<turnnum<<" "<<pass<<endl; } cout<<"Line 159"<<endl; if ((turnnum>7)&&(win=='n')) cout<<"Tie!"; cout<<"Line 162"<<endl; cout<<"Play Again (y/n)?: "; cin>>again; cout<<endl; reset(); } return 0; } But from what I can read, your problem is that it's trying to move onto the O's turn after the X - no matter what. If X wins, it shouldn't move onto O's turn. I won't write the code for you, but this is what you want: Your checkwin function should return a bool, not void. Return true if there's a win, or false if the game should continue. Your xturn and oturn values should also return bool, and that should be whatever checkwin returned. If xturn returns a win, break out of your while loop and don't move on to oturn (because it's game over).
  13. Rhaal

    Detecting Video Card

    Quote:Original post by Evil Steve It may well still fail. But if there's no drivers installed, how can Windows know what the video card name is? I don't know, but it does. Like I said, when I run msinfo32 it knows I have "Geforce 6800 Ultra, Microsoft Compatible". I'm sure it's just a brand string somewhere, similar to the cpu, but I don't know where it comes from. Edit: Nevermind, I think you're talking about display drivers and I'm talking about DirectX drivers. I am ok displaying "Unknown" with no display drivers. It seems that one dx lib is enough :)
  14. Rhaal

    Detecting Video Card

    Quote:Original post by Evil Steve I'd be inclined to load d3d9.dll at runtime and get the adapter identifier string. Ok I'll try that. I thought you were implying GetAdapterIdentifier would fail in the case they don't have DirectX but it's worth a shot. Thanks!
  15. Rhaal

    Detecting Video Card

    Yeah I probably should check specific capabilities. I do still want to display the name of the video card for cosmetic purposes though. I see this in msinfo32.exe: System Summary->Components->Display->"Adapter Type->"Geforce 6800 Ultra, Microsoft Compatible" I'm digging in the registry though, and can't find this information. I'd think it'd be under HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\VIDEO but no luck. I've even searched the entire registry for the exact string.
  • 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!