Thread: need help about converting

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    9

    need help about converting

    hi all,I'm a newbie and I need help about a game...

    I have a puzzle game working properly and I need to change it into a version that uses "glut.h" in order to add some graphical additions in a way that I could understand.because I cant understand the structure it is a little complicated for me..and I couldnt do it by myself because I didnt understand most of the code...

    I need it in a simple way that I could understand and make some improvements about it..like in a compiler screen..and this type;

    "#include "stdafx.h"
    #include <gl/glut.h>
    ........
    .......
    void main()
    .......
    ......
    void init
    ......
    .....
    functions...
    ..
    void keyboard
    .....
    "


    If you please help me I really appreciate it

    here is the code I have,I uploaded it ---> http://www.sendspace.com/file/j0pnyp

    I'm waiting for your replies..

    regards

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Most will not just upload your code without knowing you quite well.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    9
    why not? what can I do?

    If I could do it by myself I wouldnt ask for your help.and I dont know where to get some help I just wrote in google and found two forums that seem to be helpful..if you know another place please tell me

    regards

  4. #4
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    I have a puzzle game working properly and I need to change it into a version that uses "glut.h"
    I couldnt do it by myself because I didnt understand most of the code...
    You have a puzzle game and you don't understand the code? Did you write the puzzle game initially or did someone else? It seems strange to me that you would not understand your own code.

    I took a chance and downloaded your code (on a public computer). I can tell from the source files that this is a school assignment and that you are using C++Builder as your IDE.

    You need to give us more info. How much of a n00b are you? It seems strange to me that a teacher would give a new programmer an assignment to turn an already-created puzzle game (which he wrote) into something that works in OpenGL. That would be extremely difficult for a new programmer to do, and the fact that you are using C++Builder as your IDE would probably make it more complex.

    So you need to give us more info on what exactly your task is, and what you have to do. Remember: we will not do your homework or project for you, but give us specific questions and we can help to answer them.
    My Website

    "Circular logic is good because it is."

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    9
    Ok..

    Firstly of course I didnt write the code,I found it on the internet in order to help my project.I chose my project as I wish and needed help about it.Actually it is mostly about graphics.I mean the other parts is just to be but I gave the first reports and I cant change the game now..I didnt think it would be so difficult.and I had a lot of difficulties about the puzzle algorithm so I got help from the internet.

    all I want to is to convert this into a type that I could add graphics because I think I have enough knowledge about graphics for this project.and I dont need any extra features that the game already has like test or help parts,just a simple game.but there are a lot of commands that I dont know in this code.I did graphical things just in the compiler screen so far and most of them consist of a header file and a cpp..but this is very complicated for me.I tried to understand but I couldnt find where the things come from..

    by the way Im using visual studio 6.0..

    now, will you help me?
    Last edited by mensrea; 05-23-2008 at 04:37 PM.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    by the way Im using visual studio 6.0..
    First suggestion is to dump it and get 2008 Express.

    all I want to is to convert this into a type that I could add graphics because I think I have enough knowledge about graphics for this project.
    Just from what we've seen here I highly doubt graphics is where you need to be at the current time.

    Please explain a bit more what it is that you want to do.

  7. #7
    Registered User
    Join Date
    May 2008
    Posts
    9
    I'm tired telling you that converting is not my project...The name of the course is Computer Graphics and Visual Programming.You can understand what I mostly need.If I just make a puzzle game for this project I just get a zero.I will add graphical content.the more I add the more the grade will increase.therefore my part will be decisive.I didnt want you to add any graphics.

    If you dont want to help its ok,just say it.but stop blaming please...

    and I cant obtain 2008 at the moment but I'll try to get one.

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    How is your project grade our problem?

    We are telling you that just creating graphics for a game, new or existing, is not a small undertaking.

    I'm tired telling you that converting is not my project...
    I'm equally as bored with your insistence on telling us nothing. So what do you want us to do? If you cannot understand the existing code I cannot fathom how you are 'just' going to add graphics here and there.

    If you can't understand the existing non-graphical C or C++ then you will have major problems with Direct3D or OpenGL or any other API. I highly doubt that a teacher or prof would ever assign something like this knowing that your skills are just not up to the levels required for it.

    I have a puzzle game working properly and I need to change it into a version that uses "glut.h" in order to add some graphical additions in a way that I could understand....
    The way you will understand it is the same way we all have come to understand it. Read books on OpenGL and how to use it. 'Graphical additions' is very vague. Do you want 2D or 3D? Do you just want to add special effects. Does the existing code base have any Display() function? If it does I would start right there.

    Most games are going to follow this paradigm in one form or another:


    Setup/Initialization
    1. Assets are loaded and objects created
    2. Objects can either be loaded from disk into memory or a memory manager may be instantiated which handles this at run-time.

    Main game loop
    1. Update
    -- Control input
    -- Object update (speed, positions, rotations, collisions, etc)

    2. Render/Display
    -- Game is displayed to the user

    Shutdown/Cleanup
    -- Game assets are removed from memory and memory that was taken by them is freed
    -- Any devices that were initialized are cleaned up


    So if I were you I would look at the code and figure out how the logic flows. Once you understand how the information is displayed to the user you can then start to figure out how to implement graphical equivalents of what is already there.

    Other than that I would just have to do it for you.
    Last edited by VirtualAce; 05-24-2008 at 10:43 AM.

  9. #9
    Registered User
    Join Date
    May 2008
    Posts
    9
    First of all I just ask for help I didnt say anything like you said.

    And I really dont understand what do you want me to say.maybe because english is not my native language but I think I said all...

    The reason that I didnt understand the code is because there is no graphics in it and it uses commands which I have no idea about.In this course we have learned mostly 2D but recently we did a few 3D assignements.but I will make 2D moving and changing shapes and some little efects like gloom..

    there is not Display() function in this code so I couldnt start there.

    for example one of our assignments we do things like these;
    Code:
    #include "stdafx.h"
    #include <gl/glut.h>
    
    float angle=180;
    int direction;			
    
    //Functions-----------------------------------------------------------
    
        void init (void);
        void reshape (int width, int height);
        void drawxx(void);
        void keyboard (unsigned char key, int x, int y);
    
    //--------------------------------------------------------------------
    
    void main (int argc, char** argv)   
    {
        glutInit             (&argc, argv);
        init ();
        glutDisplayFunc	  (drawxx); 
        glutFullScreen ();
        glutKeyboardFunc	  (keyboard);
        glutReshapeFunc	  (reshape);
        glutIdleFunc	  (drawxx);
        glutMainLoop ( );        
    }
    
    //--------------------------------------------------------------------
    
    void init (void)
    {
        glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE);  
        glutCreateWindow    ("cxxxx"); 
        glClearDepth(1.0f);		
        glEnable(GL_DEPTH_TEST);	
        glDepthFunc(GL_LEQUAL);
        glShadeModel(GL_SMOOTH);					
        glEnable (GL_COLOR_MATERIAL);
        glEnable (GL_BLEND); 
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
        glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    }
    
    //--------------------------------------------------------------------
    
    void reshape (int width, int height)
    {
        if (height ==0)   
    	 {height = 1;}
        glViewport (0, 0, width, height);
        glMatrixMode (GL_PROJECTION);
        glLoadIdentity ();
        gluPerspective (45.0f, (GLfloat) width/(GLfloat)height, 0.1f, 100.0f);
        glMatrixMode (GL_MODELVIEW);
        glLoadIdentity ();
    }
    
    //--------------------------------------------------------------------
    
    void drawxx (void)   
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glPushMatrix();
    
    //Make the moon-------------------------------------------------------
    	 glLoadIdentity ();			
       glTranslatef (-2.0f, 1.5f, -7.0f);		//left side
       glColor3f (0.95, 0.95, 0.95);
       glRotatef (-30, 0.0f, 0.0f, 1.0f);				
       GLUquadricObj *disk1;			   
       disk1 = gluNewQuadric ();		
       gluQuadricDrawStyle (disk1, GLU_FILL);
       gluPartialDisk (disk1, 0, 0.4, 90, 9, 180, 180);  
    
       glTranslatef(0.0f, 0.0f, 0.0f);		//right side	
       glRotatef(angle, 0.0f, 1.0f, 0.0f);
    	  glTranslatef(0.0f, 0.0f, 0.0f); 
      glRotatef(angle, 0.0f, 1.0f, 0.0f);		
          if (angle > 90 && angle < 180)	
             {glColor3f (0.95, 0.95, 0.95);}
          else
             {glColor3f (0.0, 0.0, 0.0);}		
       GLUquadricObj *disk2;				
       disk2 = gluNewQuadric ();
       gluQuadricDrawStyle (disk2, GLU_FILL);
       gluPartialDisk (disk2, 0, 0.4, 90, 9, 180, 180); 
    
    
    
    //Make the sky--------------------------------------------------------
    
    
    //Sunrise&Sunset------------------------------------------------------
    	float alphasunset = (angle -60)/30;
    	glLoadIdentity ();		
    	glTranslatef (0.0f, 0.0f, -6.5f); 
    	glBegin (GL_QUAD_STRIP);
          glColor4f (.97, .33, .46, alphasunset);
            glVertex3f (-4.0f, -1.7f, 0.0f);
            glVertex3f (4.0f, -1.7f, 0.0f);
          glColor4f (.92, .92, .56, alphasunset);
            glVertex3f (-4.0f, -0.7f, 0.0f);   
            glVertex3f (4.0f, -0.7f, 0.0f);
          glColor4f (.79, .86, .95, alphasunset);
            glVertex3f (-4.0f, 0.5f, 0.0f);   
            glVertex3f (4.0f, 0.5f, 0.0f);
          glColor4f (.27, .42, .62, alphasunset);
            glVertex3f (-4.0f, 3.5f, 0.0f);   
            glVertex3f (4.0f, 3.5f, 0.0f);
       glEnd ();
    
    
    //Blue Sky------------------------------------------------------------
    	float alphablue = (angle - 100)/40;
    	glLoadIdentity ();
    	glTranslatef (0.0f, 0.0f, -6.4f);
    	glBegin (GL_QUADS);
        glColor4f (.46f, .65f, .92f, alphablue);
        glVertex3f (-4.0f, -2.5, 0.0f);
        glVertex3f (4.0f, -2.5f, 0.0f);  
        glVertex3f (4.0f, 3.5f, 0.0f);
        glVertex3f (-4.0f, 3.5f, 0.0f);  
    	glEnd ();
       
    
    //Ground--------------------------------------------------------------
    	glLoadIdentity ();
    	glTranslatef (0.0f, -2.0f, 0.0f);
    	glColor3f (.1, 0.6, 0.1);
    	glBegin (GL_QUADS);
    	glVertex3f (-4.0f, 0.0f, 0.0f);
    	glVertex3f (4.0f, 0.0f, 0.0f);
    	glVertex3f (4.0f, 0.4f, -6.3f);
    	glVertex3f (-4.0f, 0.4f, -6.3f);
    	glEnd ();
    
    
    //Sun-----------------------------------------------------------------
    float sunb;		
        if (angle > 110)
          {sunb = 0.3;}
       else
          {sunb = 0.3 + (110-angle)/40*0.3;}
    	
    float sunr = 1.0; 
    float sung = (angle - 70)/50;
    float sunx = 2.0;			
    float suny = -6 + (angle / 180 * 8);
    float sunz = -6.3;
    
    glColor3f (sunr, sung, sunb);
    	glLoadIdentity ();
    	glColor3f (sunr, sung, sunb);
    	glTranslatef (sunx, suny, sunz);
    	GLUquadricObj *disk3;
               disk3 = gluNewQuadric ();
    	gluQuadricDrawStyle (disk3, GLU_FILL);
    	gluDisk (disk3, 0, .45, 90, 90);
    	
    
    
       //if(night)
       //{
    	glTranslatef (0.0, 0.6, 0.0);
    	glColor3f (.90, .90, .90);
    	glutSolidSphere (0.5, 50.0, 50.0);
    
    	glLineWidth (5);				
    	glColor3f (0.7, 0.7, 0.7);
    	glRotatef (90, 1.0, 0.0, 0.0);
    	glutWireSphere (0.51, 16, 12);
    	glLineWidth (1);
    
    	glTranslatef (0.5, -0.9, .75);	//base
    	glColor3f (.93, 0.91, 0.85);
    	GLUquadricObj *cylinder1;				
    	cylinder1 = gluNewQuadric ();
    	gluCylinder(cylinder1, .10f, .20f,  .2f, 60, 60);
    
    	glTranslatef (0.0, 0.0, -1.2);
    	GLUquadricObj *cylinder2;		
    	cylinder2 = gluNewQuadric ();
    	gluCylinder(cylinder2, .10f, .10f,  1.2f, 60, 60);
    
    	glTranslatef (0.0, 0.0, -0.2);
    	GLUquadricObj *cylinder3;		 cylinder3 = gluNewQuadric ();
    	gluCylinder(cylinder3, .20f, .10f,  0.2f, 60, 60);
    
    	glTranslatef (0.0, 0.0, -0.2);
    	GLUquadricObj *cylinder5;	
    	cylinder5 = gluNewQuadric ();
    	gluCylinder(cylinder5, .20f, .20f,  0.2f, 60, 60);
    
    	glTranslatef (0.0, 0.0, -0.4);
    	GLUquadricObj *cylinder4; 		
    	cylinder4 = gluNewQuadric ();
    	gluCylinder(cylinder4, .10f, .10f,  0.6f, 60, 60);
    
    	glRotatef (180, 1.0, 0.0, 0.0);
    	glTranslatef (0.0, 0.0, -0.0);
    	glLineWidth (3);
    	glColor3f (0.7, 0.7, 0.7);
    	glutWireCone (.09, 0.6, 6, 1);
    	glLineWidth (1);
    
    float malpha;
       if (direction % 2 == 0 && (angle < 90 && angle > 40))
          {malpha = 0.6;}
       else
          {malpha = 0.0;}
    glColor4f (0.0, 1.0, 0.0, malpha);
    glutSolidCone (.08, 0.6, 6, 1);
    
       //}
    
    
    
    //Animation Counter---------------------------------------------------
    
       glPopMatrix();
      if (direction % 5)
         {angle +=.9;}
      else
         {angle -=1.5;}
      if (angle < 0.1)
         {direction += 1;}
      if (angle >179.9)
         {direction += 1;}
    
    
    
    
       glutSwapBuffers( );
    }
    
    
    void keyboard (unsigned char key, int x, int y)  // Create Keyboard Function
    {
       switch (key) {
          case 27:        			// Escape key terminates the program
             exit (0);   			
             break;        			
          default:       			
             break;
      }
    }
    Last edited by mensrea; 05-25-2008 at 11:38 AM.

  10. #10
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    A computer graphics course? You said yourself that you are a newbie, and I am surprised that any school would offer a computer graphics course to people new to programming. Graphics is not an easy concept to learn, and you need to already have the "programmer's mindset" before you dive into it.

    To us it sounds like you are coming here and saying, "Hey I need help but I can't understand this code can you do my project for me?" You really need to work on understand the existing codebase, or you should just start from scratch and do the entire thing yourself.
    My Website

    "Circular logic is good because it is."

  11. #11
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    I guess you'll have to start at square one:

    http://faq.cprogramming.com/cgi-bin/...&id=1043284376

  12. #12
    Registered User
    Join Date
    May 2008
    Posts
    9
    DavidP,I meant I'm newbie to game programming.we had c and c++ courses as programming courses..but this code is much than what we learned.Which part you didnt understand????You are insisting that this will be my project("Hey I need help but I can't understand this code can you do my project for me?" )..I said hundred times what the purpose of my project is and what should I do..and never expected sth about that part(graphics)from you...

    Graphics may not be easy to learn but the example code in my previous message shows what we do.You can check if you want and I dont think they are so hard.even if they are I can do those...

    and if you had an intention of helping,you would already say something to help me understand the existing code,not lecturing about the curriculum or what my project actually is!!!!so please dont send more messages..

    robwhit I guess I missed the joke sorry!

  13. #13
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'm lost.

    What do you want us to do?

  14. #14
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by mensrea View Post
    robwhit I guess I missed the joke sorry!
    void main is a common mistake among beginners to C.

  15. #15
    Registered User
    Join Date
    May 2008
    Posts
    9
    Bubba; if you could and want,it would be awesome that you convert it.I wouldnt lose more time with that...But if you cant or dont want to,at least you can explain it to me.maybe I can have a chance about doing it myself?

    robwhit, I have bigger problems than that but thanks anyway!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 32 bit binary IP to decimal IP (vice-versa)
    By Mankthetank19 in forum C Programming
    Replies: 15
    Last Post: 12-28-2009, 07:17 PM
  2. Tips for converting C prog. to C++?
    By eccles in forum C++ Programming
    Replies: 7
    Last Post: 01-15-2005, 07:38 AM
  3. Converting Sign Magnitude Integer Binary Files
    By Arthur Dent in forum C Programming
    Replies: 7
    Last Post: 09-13-2004, 10:07 AM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. converting string to float
    By twhubs in forum C Programming
    Replies: 1
    Last Post: 09-16-2001, 09:02 AM