lots of questions

This is a discussion on lots of questions within the C++ Programming forums, part of the General Programming Boards category; Question 1 - The following code is how I place a player onto the field, what if I wish to ...

  1. #1
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163

    lots of questions

    Question 1 -
    The following code is how I place a player onto the field, what if I wish to make them transperant of 50%? I have tried glColor4f(1.0f, 1.0f, 1.0f, 0.5f); but it isn't that simple.

    class player_graphics
    {

    glLoadIdentity();
    glTranslatef(x, y, z);
    glColor3f(1.0f, 1.0f, 1.0f);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-bl, 0.0f, 0.15f);
    glTexCoord2f(1.0f, 0.0f); glVertex3f(bl, 0.0f, 0.15f);
    glTexCoord2f(1.0f, 1.0f); glVertex3f(bl, (bh*2), 0.15f);
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-bl, (bh*2), 0.15f);
    glEnd();
    }

    Question 2 -
    Which is faster?
    ball[0]=1;
    ball[1]=1;
    ball[2]=1;
    OR
    ball[0]=ball[1]=ball[2]=1;
    Or doesn't it make any differance?

    Question 3 -
    How do I delete an array during the running of a program?

    Question 4 -
    When a class item is made I assume that the whole class item is put into memory, to free up memory is it possible to delete the class item if I no longer need it? How would I delete it?

    eg
    Class button
    {
    //Make button
    }

    //If the player is in the start screen
    new_game button(); //Make this button

    //If the player leaves the start screen and I no longer have any need for the new_game button
    delete new_game button? or is it ~new_game button?
    ///////////////////

    Question 5 -
    Is there any quickler way of doing this? Note that the second figure is increasing by 20;
    button hire0(600.0f, 150.0f, 250, 1.0f, 0.4f);
    button hire1(600.0f, 170.0f, 250, 1.0f, 0.4f);
    button hire2(600.0f, 190.0f, 250, 1.0f, 0.4f);
    button hire3(600.0f, 210.0f, 250, 1.0f, 0.4f);
    button hire4(600.0f, 230.0f, 250, 1.0f, 0.4f);
    //////////////////////
    My site to register for all my other websites!
    'Clifton Bazaar'

  2. #2
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    Question 1:
    The OpenGL code I can't help you with right now since I haven't done anything with GL.

    Question 2:
    The 2nd version ball[0]=ball[1]=ball[2]=1 might be a little faster than the other version but not sure. However, this 2nd version is cleaner and better looking in code and generally recommended over the other 1st version.

    Question 3 & 4:
    You need to create your Objects or instances of your classes with the new command.

    Btn = new button; // You must 'delete' all instances created with 'new' otherwise you will have a mem leak
    delete Btn;

    OR

    button (*Btn[6]) = new button[6];
    delete [] Btn;

    *Remember to delete the instances created by 'new' with the 'delete' operator

    Question 5:
    This depends on whether you'll be creating these with the 'new' operator, if so you could put them into a loop statement and create each instance by having it inherit from it's other already created instances and increment the said variable by 20 for each.

    *Inheriting is always good programming practice, no need to reinvent the wheel so borrow from what's already been created and change only the pieces that need to be changed.*
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  3. #3
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    Thanks for all that, now to go and try it all
    My site to register for all my other websites!
    'Clifton Bazaar'

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Really new & Really clueless (lots of different questions)
    By Tigerfeet in forum C++ Programming
    Replies: 7
    Last Post: 11-07-2008, 03:32 PM
  2. Two questions. (Sorry for lots of them =( )
    By ozumsafa in forum C Programming
    Replies: 10
    Last Post: 09-21-2007, 03:57 AM
  3. Lots of questions
    By belhifet in forum C# Programming
    Replies: 5
    Last Post: 12-20-2006, 06:39 PM
  4. Lots Of Bitmap Texture Questions:
    By Krak in forum Game Programming
    Replies: 7
    Last Post: 07-10-2003, 08:16 PM
  5. Lots of RPG questions...
    By Kyoto Oshiro in forum Game Programming
    Replies: 22
    Last Post: 07-21-2002, 10:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21