Teen Programmers Unite  
 

 

Return to forum top

C++ , Objects in Classes ?

Posted by dacre [send private reply] at July 10, 2003, 07:23:28 AM

Hi , I dont know alot of the technical jargon behind programming so ill try explain my problem . Im using glut and openGL . I have a prototype function which draws a dot on the screen . Now i want to make an explosion effect , i get to a point though where i run into problems , where i need to allocate a group of say 20 of the dot functions into memory . I do this by going

class DotObj{
public:
Dot()
{
...
}
}

and then going :
DotObj bits[20]

now i have no idea what to do . am i on the right track . thanks for your help , i hope you will be able to help , thanks again

Posted by Psion [send private reply] at July 10, 2003, 09:39:54 AM

That creates 20 DotObj's. What is your question now?

Posted by Kruptos [send private reply] at July 10, 2003, 11:40:04 AM

Actually that creates a compile error...teehee...but really I don't understand the problem you're having. That code should work fine in creating 20 DotObjs (and therefore 20 DotObj::Dot() functions)... wasn't that your objective? In terms of making an "explosion effect", that's very vague, and could potentially be very easy or extremely complicated depending on how detailed you wish to make it. My suggestion is that if you want to make an explosion then you create a small video file of an explosion (or download it from some site) and use OpenGL to play it.

Posted by CViper [send private reply] at July 10, 2003, 02:00:31 PM

That creates a big error, because the constructor _must_ have the same name as the class, i.e.

class DotObj
{
    public:
        DotObj() { ... }
}
You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.