-
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);
//////////////////////
-
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.*
-
Thanks for all that, now to go and try it all :)