Jump to content

Dynamic object creation


Addictgamer
 Share

Recommended Posts

Addictgamer

Language: C++

Take a look at this scenario:

We have

class goomba

{

int wx, wy;

}

And we want to create a new instance of this class every few seconds.

How do we create a new instance?

I've looked into many methods already, just didn't manage to get something that works.

Anybody who has knowledge on this, please help me.

Link to comment
Share on other sites

python solution WOULD be:

import time


goombas = []

while True:

  goombas.append(goomba(x, y))

  time.sleep(1)

of course it's not python.

For the waiting, you can #include <time> though and use sleep(seconds).

For the adding, you'd probably use a vector (idk how).

Link to comment
Share on other sites

Addictgamer

ALready spent a whole year googlign this.

Anyway, I think if I did goomba *goombas[];

Well, I do that with my tile system and it works...

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.