Member Avatar

Hey everyone, I have recently started in XNA and am trying to experiment with different things by using a Object Oriented approach. I am a bit confused about how I should deal with interactions between my objects, for example if I have a Platform object and a Player object and I want the Player to land on the Platform should I deal with interactions such as this within the Game1 class?

The Player class is inherited from a Sprite class and the Platform class is inherited from the Sprite class. I am unsure where to deal with interactions between the classes. This is the first time I have really started using inheritance, appologies if the question is a little vague, I was just wondering if you guys usually include interaction between the classes within the Game1 class or you create a class that deals with the interactions, or you use properties or something I am unfamiliar with. Any advice would be greatly appreciated. Thanks.

Your sprite class should have a position member.

In your game1 class you should have a method that deals with 'Game Logic'. In larger games this will be broken down into several methods.

This 'game logic' should keep track of all your positions. (HINT: Your platforms will be static.) It should also check on every loop if the players position coincides with that of the platforms position if so the players position is maintained at that height until the next action at least!

Now to awnser the last part of your post. Ultimatley its up to you if you want another class to deal with such logic. Personally I would keep it in your game class until your game gets larger. Then when you start making larger/more games make a seperate game logic class, this will be nesscary as the game logic will probably have a lot of memebers and methods.

You will probably find that alot of your logic will be the same for each game so having it in a sperate class that you can reuse will be benefical. Just create a new instance when you make a different game and wollah!! But I wouldnt rush into this, you will need to make a couple games to optimise and think about your implementation, after all you will be planning on using this over and over!!

[I like XNA development as well!]