![]() |
Not logged in, Join Here! or Log In Below:
|
|
I've written a game engine (somewhat based on the Enginuity tutorials, thanks superpig) that I'd like to make more OOP-proper. |
|
CHANGE THE PARAMETER IT TAKES. |
|
either you could have overloaded methods or maybe use a void* attribut: |
|
I can't see why you're passing the World* pointer to the task.
or similar? |
|
Ha something comes to my mind... =)
Hmm that looks nice, why didn't I implement this? ;) |
|
Mil_Gov:
-Alex |
|
MadHed:
Ok, I so I guess a better way to say what I want: I'd like to seperate a State from the code that acts upon it (or reacts to it)...and I'd like to make that State generic, so it might be a Game State (containing game objects with vect2d position, velocity, etc..) or a NeuralNetworkState (containing neurons with certain activations), or any other state. -Alex |
|
Could you elaborate a little more on what exactly the Task::Update() function needs to do? I dont see exactly why it needs to take an argument. Couldn't you just derrive every class from the Task class, and it contain a pure virtual Update function with no arguments? |
|
Ummm...sorry, I guess the code snippet is incomplete.
|
|
Here were the things I wanted for the game:
The only thing that bugs me about this...every Task needs to be initialized with the GameWorld it operates on...this seems redundant since every Task in the TaskManager will deal with the same GameWorld. -Alex |
|
ok, i think i get your point. In your mainpost you said that you would like to have it something like this:
that means you could have a structure like this, even if you didn't like the void* pointer i think this is safe enought...
do you think this would work for you? you never actually have to convert the void* pointer yourself because you are not going to create a Task instance only PhysicsTask and RenderTask instances... edit: bummer didn't see your new post further down...you got a hard one here... |
|
Hey Alex
Then you can do something like:
And the template TaskManager::TaskManager() constructor does something like... centerofmylife = new T; Is this what you want? |
|
Yeah the templated version could do the "trick".
Why is that in any way restricting the use of your Task class? You can still derive new classes from Task for whatever purpose they are needed. =) So when you need a statud Task you do: Task status = new StatusTask(); TaskManager.Add(status); when you need a RenderTask you do: Task render = new RenderTask(blablabla); TaskManager.Add(render); From the TaskManager's point of view both are just "Task"s. But your application is responsible for creating the tasks and can init them in any way. =) |
|
Oh! I think you misunderstood the concept of the TaskManager!!!!
However, I haven't implemented a taskmanager myself. It just seemed too overkill for my engine. It's using a good ol' Harcoded Mainloop. ---> http://madhed.ma.funpic.de |
|
Yo have, sort of, answered your own question, sort of... =)
|
|
Sorry...I guess I created some confusion. I'm working on two distinct programs...I just put the two taskmanagers in the code together to show that each task manager held a collection of tasks working with unique states (one set of tasks deals with a world state, the other with a neural network state). |
|
Why can't you just make the update method take no arguments and have the various tasks get the info they need at creation time? Seems simple enough. Oh, and it might make sense to pass in the update frequency since you might need compensate for this in code. Otherwise, updating the physics more often will cause things to go faster which isn't what you want. |
|
|
