Say i have some objects moving around on a map.
Rock, paper, scissors.
The method to handling collisions() is sort of
connected to the classes, but doesnt really belong
in any single one of them.

How would you code this in perl?

Keep in mind that later on, someone wants to add
some new classes, lizard and spock.

I was thinking making a base class of "things"
And have some sort of resolver in there?

Multiple collision() functions with signatures
for each type of object that is colliding?
But can perl even do that?
Perl would need a way to resolve which sub to call
based On types passed in.
I used to do this in ada/vhdl
but never seen it in perl.

A hash of hashes where the indexes are the types, put that in the "things" base class, and have a "collision()" sub that crawls through the hadh?
New object classes populate their types into the hash?


I feel like this is probably a CS101 type concept
that they didnt teach us electrical engineers...





_______________________________________________
Boston-pm mailing list
[email protected]
https://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to