locked
OO Pong, very basic question, need design advice. RRS feed

  • Question

  • hi Folks.

    Been a loong time since I had to do any OO programming so letting myself back into it gently by trying to write an object oriented version of pong using C#.
    I have a Toy class. Ball and Paddle will be sub classes(inherit) the toy class.
    I need to implement a draw method. As a paddle is very different from a ball, im wondering if i should have the draw method in the Toy class at all.
    Should the draw method be specified in an interface, forcing the ball and paddle to implement their own draw methods?

     

    Apologies for the simplicity of this question, but Ive been involved in databases for so long that i have forgotten much of the OO concepts I learned in college.

    Friday, March 26, 2010 6:09 PM

All replies

  • Maybe draw is an action of a separate static class that takes an object and location as parameters.

    Friday, March 26, 2010 6:22 PM
  • If you are interesting in some general OOP info, here is a link to a set of posts on OOP basics:

    http://msmvps.com/blogs/deborahk/archive/2009/08/31/what-is-oo.aspx

    I also did a game using OO. It is Mastermind and it is here:

    http://msmvps.com/blogs/deborahk/archive/2009/07/06/applying-oop-to-simple-games-mastermind.aspx

    Hope this helps.


    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    Friday, March 26, 2010 7:39 PM
  • Thanks  guys, much appriciated.

     

    Andy,  I like your thoughts, makes sense, think thats the route il take. thanks.


    Deborah,had a look at the OO Basics link and i am familiar  with all the concepts, its just the actual implementation that i am having trouble with. Your game is quite interesting though and your explanation is very clear and I can see this being a good reference for me. thanks!

    Friday, March 26, 2010 11:30 PM
  • Thanks  guys, much appriciated.

     

    Andy,  I like your thoughts, makes sense, think thats the route il take. thanks.


    Deborah,had a look at the OO Basics link and i am familiar  with all the concepts, its just the actual implementation that i am having trouble with. Your game is quite interesting though and your explanation is very clear and I can see this being a good reference for me. thanks!

    Friday, March 26, 2010 11:30 PM
  • hi Folks.

    Been a loong time since I had to do any OO programming so letting myself back into it gently by trying to write an object oriented version of pong using C#.
    I have a Toy class. Ball and Paddle will be sub classes(inherit) the toy class.
    I need to implement a draw method. As a paddle is very different from a ball, im wondering if i should have the draw method in the Toy class at all.
    Should the draw method be specified in an interface, forcing the ball and paddle to implement their own draw methods?

     

    Apologies for the simplicity of this question, but Ive been involved in databases for so long that i have forgotten much of the OO concepts I learned in college.


    welcome winston,

    i like your idea that ball and paddle realize an interface that sports say a Draw () method. nothing wrong with that. remember, games are all about speed, so dont be too concerned with overly complex OO designs. you can still be OO (I recommend it) but just keep a balance between code layout and resulting performance.

    hey, have you heard of Microsoft XNA API? it's a managed API for making games for windows, xbox 360, zune (i think) and soon for the new windows 7 phones .

    you can read about XNA here

    ...or visit the community site where you'll find tons of tutorials, sample code and complete games!

    enjoy.

     


    MickyD | http://mickyd.wordpress.com/ Help others by voting my post as 'Helpful' if you think it is so.
    Sunday, March 28, 2010 1:19 AM