DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 3 123 LastLast
Results 1 to 15 of 32

Thread: game-making tool questions

  1. #1
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72

    game-making tool questions

    Hi, I've been working on making games in C++ with OpenGL and am doing alright. However, I've recently been making an outside program where I'll make the graphics, those are saved and then I load them into the games. All this is working fine, but now I'm adding menu support to it. Firstly, in the initial version of my tool, holding the <r><g>or<b> key while pressing up or down changed the RGB values, allowing for easy color palette changes, because I used the RGB value currently set, applying it to a point when one is placed, and then writing that to file along with the point's coordinates when the shape is saved. I recently used My older, yet slightly better compiler(MS DevStudio with Visual C++)(my current compiler is the Bloodshed Dev-C++) to create a dialog box visually with three sliders for the RGB. I loaded that .rc file into my Shape Maker program and everything works, except I don't know how to display that dialog box in the program. You see, my menu has "Colors->Set RGB" and that is when I want the box to come up. For the other small yes-no dialog boxes I've used the simple MessageBox() function, but that doesn't support sliders(as far as I know). Anyway, I tried using

    HDIALOG setRGB;
    setRGB = LoadDialog(hInstance, MAKEINTRESOURCE(IDD_RGBBOX));

    which is just like the function I used to load my menu from a .rc file, but it didn't work. So maybe someone could please help me. I'm only a freshman in high school , so forgive my un..knowing...ness.. lol. Anyway, any help is greatly appreciated.

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    you make an instance of the class:
    mydialog dlg;
    dlg.domodal(); // this pops up the dialog, but it takes over until closed, its the simple way to do things.

  3. #3
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72
    so if I put that code in, how does it know which dialog to pop up? Is there some argument I need to pass?

  4. #4
    Join Date
    Dec 2003
    Posts
    3,366
    Its the dialog that that class is (the one you made -- HDIALOG I suppose?)

    When you make a dialog it should be a derived class of CDialog, with you own stuff. You make an instance of that, and the domodal works.

    Did that make sense?

  5. #5
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72
    actually the HDIALOG was something I thought was part of the Win32 API like HMENU. I know; I'm stupid- just making up classes.
    So, I need an instance of CDialog and then domodal()

    CDialog rgbBox;
    rgbBox.domodal();

    like that? or just

    CDialog rgbBox;
    domodal();

    ?
    Last edited by Algorien; 03-31-2005 at 10:36 PM. Reason: accidentaly tabbed out while typing
    Daniel Borgman
    Founder, MAD Programming( MADtek )
    www.MadProgramming.biz.ly
    www.MadProgramming.byethost2.com
    Founder, Old Baby Pictures Skate( BP )
    www.obpskate.byethost12.com

  6. #6
    Join Date
    Dec 2003
    Posts
    3,366
    Ok. Hmm. You should make, if you have not, a new dialog class, which can be done in visual studio's 'what you see is what you get' editor. You drag and drop stuff on it, set up control variables to read/talk to the stuff, etc. Those files that it creates for you define your dialog class. You want to make an instance of it (include the .h file, and make a variable like this: whatever_dialog_name variable;) and then call the .domodal.

    That works for any class:

    class whatever
    {
    int member;
    };

    whatever x;
    x.member = 3; //etc

    You're doing the same thing, except the IDE connects everything up for you, including the derivation of the class from the basic CDialog.

    You *can* do it all in text, but it requires a lot of know-how about the details of MFC, and some other voodoo.

  7. #7
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72
    lol. okay, so I should use the classWizard in MSDEV?
    Daniel Borgman
    Founder, MAD Programming( MADtek )
    www.MadProgramming.biz.ly
    www.MadProgramming.byethost2.com
    Founder, Old Baby Pictures Skate( BP )
    www.obpskate.byethost12.com

  8. #8
    Join Date
    Dec 2003
    Posts
    3,366
    Do add resource, new, dialog -- the class wiz works better for non-mfc classes, the normal programming stuff (although it adds so much strangeness I rarely use it).

  9. #9
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72
    I have the dialog box editor open but the ClassWizard won't open, in the menu it's greyed.(btw: thanks for your patience, I know I can be clueless)
    Daniel Borgman
    Founder, MAD Programming( MADtek )
    www.MadProgramming.biz.ly
    www.MadProgramming.byethost2.com
    Founder, Old Baby Pictures Skate( BP )
    www.obpskate.byethost12.com

  10. #10
    Join Date
    Dec 2003
    Posts
    3,366
    I don't know what's causing that, but you don't need it right now. That means you added a dialog class, so now you should be able to spawn it with the domodal.

  11. #11
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72
    okay, thank you
    Daniel Borgman
    Founder, MAD Programming( MADtek )
    www.MadProgramming.biz.ly
    www.MadProgramming.byethost2.com
    Founder, Old Baby Pictures Skate( BP )
    www.obpskate.byethost12.com

  12. #12
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72
    Okay, now for my next question. Currently in my game I am using a hspeed and vspeed(horizontal and vertical), which are set in a vector array and the vector is applied every step. However, it would be very beneficial to be able to use a direction variable(0-360, 0* being straight up) and a speed in num of units to go. I know it probably has to do with sines and cosines, but I'm only in geometry, two years away from trig, so maybe a grad can help me. so i guess with sines and cosines and tangents, you need a right triangle:
    _ _ _
    vspeed(leg1)-J | `-. <-hypotenuse(combined motion, length = speed)-H
    90*-> |]___`-. <-direction angle
    ^ _
    hspeed(leg2)-L
    and we only kow two of the angle, the 90* one where the hspeed meets the vspeed and the direction. the direction is angle <HL. I don;t know the details of how you take the speed(hypotenuse) as a side, direction and 90* as angles and find the length of L and J, but I've given you what I could muster, and your help would be very appreciated.
    PS. the underscores above the letters represent the names of the sides and the splat(asterisk) is a degree symbol, and the rest of the symbols are supposed to form a right triangle. sorry for the crappy ASCII graphic.
    Last edited by Algorien; 04-05-2005 at 09:44 PM. Reason: the symbols didn't line up correctly
    Daniel Borgman
    Founder, MAD Programming( MADtek )
    www.MadProgramming.biz.ly
    www.MadProgramming.byethost2.com
    Founder, Old Baby Pictures Skate( BP )
    www.obpskate.byethost12.com

  13. #13
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72
    btw, the spacing on that stickin graphic didn't work, sorry

    |`-.
    |....`-.<-Hypotenuse(speed)- side H
    |........`-.<-direction

    that's sort of what it was supposed to be, using periods for spacers
    the bottom leg is L and the Vertical leg is J
    sorry again for being so hard to understand.
    Last edited by Algorien; 04-05-2005 at 09:47 PM. Reason: I edit everything
    Daniel Borgman
    Founder, MAD Programming( MADtek )
    www.MadProgramming.biz.ly
    www.MadProgramming.byethost2.com
    Founder, Old Baby Pictures Skate( BP )
    www.obpskate.byethost12.com

  14. #14
    Join Date
    Dec 2003
    Posts
    3,366
    speed is
    sqrt(hspeed*hspeed + vspeed*vspeed);

    direction = inverse tan (opposite/adjacent) ..
    = inverse tan(vspeed/hspeed);
    more or less, but you will have to detect quadrant and fix that.

    Look up quaternions if you get serious about this -- in 3-d, you can't go straight up because it maps 3-d into 2-d, and you lose a direction, so you use quaternions which map 3-d to 4-d so when you lose it you still have 3 directions (more or less -- you have to know vector spaces to follow this much farther)...

  15. #15
    Join Date
    Apr 2004
    Location
    Pennsylvania
    Posts
    72
    Oh, that's complicated. But I was reading through my friend's math book and I kinda got a general idea of sines. Since I'm working in 2d graphics right now, would the following work to calculate the vspeed and hspeed from the speed and dir?

    //dir2 is the other non-90* angle
    dir2 = (180 - direction) - 90;
    vspeed = sin(direction) * speed;
    hspeed = sin(dir2) * speed;

    and could I do something like this to detect quadrant?

    int quadrant;
    quadrant = direction/90;
    Last edited by Algorien; 04-06-2005 at 03:08 PM.
    Daniel Borgman
    Founder, MAD Programming( MADtek )
    www.MadProgramming.biz.ly
    www.MadProgramming.byethost2.com
    Founder, Old Baby Pictures Skate( BP )
    www.obpskate.byethost12.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center