Cripes 2.0: Basic Strategy support

Published February 26, 2009
Advertisement
I have a very rough and basic Strategy setup going now. I have an IStrategy template interface which defines a pure virtual Execute(T&). The templating means I'm able, if I so desire (and I rather don't), to create strategies for other objects besides an Entity. The T& is a reference to the object whose strategy it is.

I then created an IUpdateStrategy interface, same template as before, but with a non-virtual overloaded Execute(T&, DWORD frame_delta). It also has a protected DWORD field to store the passed-in frame delta in, allowing the Execute(T&), which all IStrategies require, access it.

Finally, I made a simple Collide strategy, which doesn't actually test for collision just yet. It requires a World& and a Keyboard& to use for strategic context, the latter mainly because I'm testing it with the player sprite and I need to be able to move it myself. Those two are passed in via the constructor.

I created a Collide strategy and passed it the player entity, and moved its update code from my Game::Update() function to the Collide::Execute() function. It works! But I feel bad design on the horizon, and I really need to just sit down and thing about how I can best use the Strategies.

~Jonathan

P.S. johnhattan's ConFusebox 2 is insanely addicting. [lol]
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement