Flappy mario exe6/3/2023 ![]() ![]() ![]() So they can read and modify the player's attributes, and theirs, in function of it. In your game class you create a Bird object, and then when you create the enemies and other objects, you pass them a reference to the Bird. If the bird is your game main character, I think it would be better that the other objects have a reference to it. Usually in my games, every enemy or animated object (such as blocks in Super Mario games) has a reference of the player (that is passed in its constructor) and so they are able to process both their atacks to the player and player's attacks to them. If an object needs to know some data of another object (that is very common), the only way (at least what my experience tells me) is to pass a reference of the 2nd to the 1st(*).
0 Comments
Leave a Reply. |