I would like to write an educational board game that allows multiple players to participate in a single HTML session. The number of players would be between 2 and 8. Each player moves during their turn, and if they land on a square occupied by another player, one of the players may be conditionally sent elsewhere. Do I have to create 8 individual player objects, each with a full set of events and actions, or is there some way to have a “player” object and distinguish between them for turns?
Something akin to a “player” class, where each instance has a unique handle, but all instances are “player” objects. The documentation (at least in English) does not detail how this might be done.
Well, you know about OOP, so understand how GD works should be easy :
-Yes, you can make a “Player” object, this is a class or constructor. Then you create instances from it, every one named “Player”.
-In GD, you can’t assign an object in a variable, only numbers and strings, and recently more variables. GD select the object “Player” from anothers “Player” when they fills the conditions in the event: If you set “no conditions” and put an action “Delete object Player” GD will delete all “Player”. But if you set a condition “Player collide with Ground”, GD will delete each “Player” that collide with “Ground”.
-You could add a variable to the “Player” (in example: ID), set the variable different for each “Player”, then you can play with this variable (ID) number in your events (save the object variable in global variables to do something, set the variable number as a condition to affect only one object, etc.).
So, initially, you shouldn’t repeat every event for each player.