I'd think I'd have a separate class representing the map, and it would be in 
charge of keeping track of where each of the objects are in the playing field.

The action of an object moving would be a method on the map object, and it 
would return/throw an error when a collision occurs.

-A
 
On Sat, Dec 7, 2024, at 10:27, [email protected] wrote:
> 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

-- 
  Adam Herzog
  [email protected]

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

Reply via email to