Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3]

Author Topic: Faffing about with a roguelike  (Read 4590 times)

Reelya

  • Bay Watcher
    • View Profile
Re: Faffing about with a roguelike
« Reply #30 on: March 09, 2012, 10:02:38 am »

Looks like you want either multiple inheritance, which gives those features as compile-time features,
or the strategy pattern i mentioned in the last post, which would allow the run-time setting of sub-types.

Yeah, that stuff is easy to implement in c++, just make a pointer to the class which is the "component". and make the "self" object have a constructor which sets the pointer (with a default value of zero). the code will look quite similar to that python.

That's not really a specific language feature of python, all it's doing is declaring a pointer to another class within your main class, and having it default to zero for the pointer. What i outlined in my last post was a polymorphic version of the same idea, which is actually way cooler.

I've also dealt with the "AI object must know what object it comes from" in a couple of different ways, which make use of the "this" pointer in c++

tl;dr : do you want to implement the same thing as the link exactly?

(btw the "older but forgotten cousin composition" thing he writes is bunk. this guy seems to know nothing about design patterns)
« Last Edit: March 09, 2012, 10:27:09 am by Reelya »
Logged

Simmura McCrea

  • Bay Watcher
    • View Profile
    • My Steam profile
Re: Faffing about with a roguelike
« Reply #31 on: March 09, 2012, 02:21:24 pm »

Fair enough, I'll fiddle with that and see what I can do.
Logged
Pages: 1 2 [3]