microsoft / pxt-arcade

Arcade game editor based on Microsoft MakeCode
https://arcade.makecode.com
MIT License
484 stars 210 forks source link

Hard to pass multiplayer Player to function #5633

Open jwunderl opened 1 year ago

jwunderl commented 1 year ago

Describe the bug

There's no way to pass a 'player' to a function -- you have to either pass the player number or the associated sprite & then get the player from that.

To Reproduce Steps to reproduce the behavior:

  1. Go to blocks project
  2. create a function
  3. see that there's no way to pass in a player
  4. end up having to pass in a number, and then call the 'player [index]' whenever calling the function / 'player at [index]' inside the function

Expected behavior

Should be able to pass in a Player like we can pass in a Sprite (but only when multiplayer extension is present I guess?), or we should have a fallback 'Other' at the end that compiles to any (similar behavior to array)

for what it's worth this is the downside of making a full type vs just using number for player, but I don't think kids would have understood you could use number anyway / they'd both be places where people wouldn't know what to do.

alex-kulcsar commented 4 months ago

I've written code to deal with this when implementing War (the card game). It'd be easy enough for me to add this to my envisioned bundle of multiplayer extensions.

I should probably start documenting things to include in this bundle. 😆

https://forum.makecode.com/t/announcement-makecode-arcade-mini-game-jam-20-board-game-jam/29077/46