Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4109632
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:49:26+00:00 2026-05-20T21:49:26+00:00

I have a question about a XNA game I’m making, but it is also

  • 0

I have a question about a XNA game I’m making, but it is also a generic question for future games. I’m making a Pong game and I don’t know exactly what to update where, so I’ll explain better what I mean. I have a class Game, Paddle and Ball and, for example, I want to verify the collisions between the ball with the screen limits or the paddles, but I come across 2 approaches to do this:

Higher Level Approach – Make paddle and ball properties public and on the Game.Update check for collisions?

Lower Level Approach– I supply every info I need (the screen limits and paddles info) to the ball class (by parameter, or in a Common public static class) and on the Ball.Update I check for collisions?

I guess my question in a more generic way is:

Does an object need to know how to update and draw itself, even having dependencies from higher levels that somehow are supplied to them?

or

Is better to process it at higher levels in Game.Update or Game.Draw or using Managers to simplify code?

I think this is a game logic model question that applies to every game. I don’t know if I made my question clear, if not, feel free to ask.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:49:27+00:00Added an answer on May 20, 2026 at 9:49 pm

    The difficult part of answering your question is that you’re asking both: “what should I do now, for Pong” and “what should I do later, on some generic game”.


    To make Pong you don’t even need Ball and Paddle classes, because they’re basically just positions. Just stick something like this in your Game class:

    Vector2 ballPosition, ballVelocity;
    float leftPaddlePosition, rightPaddlePosition;
    

    Then just update and draw them in whatever order suits you in your Game’s Update and Draw functions. Easy!


    But, say you want to create multiple balls, and balls have many properties (position, velocity, rotation, colour, etc): You might want to make a Ball class or struct that you can instance (same goes for the paddles). You could even move some functions into that class where they are self-contained (a Draw function is a good example).

    But keep the design concept the same – all of the object-to-object interaction handling (ie: the gameplay) happens in your Game class.

    This is all just fine if you have two or three different gameplay elements (or classes).


    However let’s postulate a more complicated game. Let’s take the basic pong game, add some pinball elements like mutli-ball and player-controlled flippers. Let’s add some elements from Snake, say we have an AI-controlled “snake” as well as some pickup objects that either the balls or the snake can hit. And for good measure let’s say the paddles can also shoot lasers like in Space Invaders and the laser bolts do different things depending on what they hit.

    Golly that is a huge mess of interaction! How are we going to cope with it? We can’t put it all in Game!

    Simple! We make an interface (or an abstract class or a virtual class) that each “thing” (or “actor”) in our game world will derive from. Here is an example:

    interface IActor
    {
        void LoadContent(ContentManager content);
        void UnloadContent();
    
        void Think(float seconds);
        void UpdatePhysics(float seconds);
    
        void Draw(SpriteBatch spriteBatch);
    
        void Touched(IActor by);
    
        Vector2 Position { get; }
        Rectangle BoundingBox { get; }
    }
    

    (This is only an example. There is not “one true actor interface” that will work for every game, you will need to design your own. This is why I don’t like DrawableGameComponent.)

    Having a common interface allows Game to just talk about Actors – instead of needing to know about every single type in your game. It is just left to do the things common to every type – collision detection, drawing, updating, loading, unloading, etc.

    Once you’re in the actor, you can start worrying about specific types of actor. For example, this might be a method in Paddle:

    void Touched(IActor by)
    {
        if(by is Ball)
             ((Ball)by).BounceOff(this.BoundingBox);
        if(by is Snake)
             ((Snake)by).Kill();
    }
    

    Now, I like to make the Ball bounced by the Paddle, but it is really a matter of taste. You could do it the other way around.

    In the end you should be able to stick all your actors in a big list that you can simply iterate through in Game.

    In practice you might end up having multiple lists of actors of different types for performance or code simplicity reasons. This is ok – but in general try to stick to the principle of Game only knowing about generic actors.

    Actors also may want to query what other actors exist for various reasons. So give each actor a reference to Game, and make the list of actors public on Game (there’s no need to be super-strict about public/private when you’re writing gameplay code and it’s your own internal code.)


    Now, you could even go a step further and have multiple interfaces. For example: one for rendering, one for scripting and AI, one for physics, etc. Then have multiple implementations that can be composed into objects.

    This is described in detail in this article. And I’ve got a simple example in this answer. This is an appropriate next step if you start finding that your single actor interface is starting to turn into more of a “tree” of abstract classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about this question . I posted a reply there but
I have a question about tables in MySQL. I'm currently making a website where
I am just starting out in XNA and have a question about rotation. When
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and
I have a question about using streams in .NET to load files from disk.
I have a question about best practices regarding how one should approach storing complex
I have a question about locking. This doesn't have to be only about record
I have a question about how to deploy WPF application into a PC without
I have a question about using os.execvp in Python. I have the following bit
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.