I am trying to finish my Pong Clone by Monday to start my personal journey in to the game programming. I have been slacking off but I realized I am only cheating myself if continue. My resolve to finish this project is strong and nothing is going to get in my way.

I have come to a design problem though. I have a Paddle Class for the player but I don't know how to make a automated paddle for the computer. Seeing as they will have very similar attributes but I thought of making the computer paddle a subclass of the player paddle (or inherit from the PlayerPaddle Class). I don't fully understand how to do that though. If I could get some help that would be very much appreciated.

While you're at this point, consider the following: A player isn't necessarily a paddle. Rather, a paddle is controlled by the player (or the AI).

Keeping that in mind, having the player inherit from the paddle class is probably not the most correct route to go as it indicates that your player is a paddle and not simply that your player can control a paddle. If you decide to still design your program in such a way, it's not going to explode in your face or anything and will definitely still work, but in more complicated projects it'll start making you scratch your head wondering what exactly is going on.

When thinking of the design in terms of 'the paddle can be controlled by either a player or the computer' it makes things a little simpler to work with.

You would have a single paddle class whose movement is determined by input received. You could then have a Player and NPC class which each can send input to the paddle they're associated with. The input for Player being created through keyboard button presses and the input for NPC being generated through some set of rules you've determined to affect their movement behavior.

Can someone help me out and walk me through Subclassing and Inheritance, I am having a lot of trouble learning how to make this work. I am sorry If i sound like a needy four year old, But I can't figure out the whole subclassing thing.

Correct the spelling of "Direction" in line 7 or elsewhere. See what happens. Also, you need to get into the habit of good commenting. Get back to us after you finished those tasks.

Clinton

Edited by 3Ddreamer, 11 October 2012 - 11:12 AM.

Personal life and your private thoughts always effect your career. Research is the intellectual backbone of game development and the first order. Version Control is crucial for full management of applications and software. The better the workflow pipeline, then the greater the potential output for a quality game. Completing projects is the last but finest order.

I actually Just solved my own problem. I feel like a big man right now. Thanks for your help everyone.

It would be even bigger of you to let the other newbies in the community know what pit fall to avoid and how you solved it!

Clinton

Personal life and your private thoughts always effect your career. Research is the intellectual backbone of game development and the first order. Version Control is crucial for full management of applications and software. The better the workflow pipeline, then the greater the potential output for a quality game. Completing projects is the last but finest order.

3Ddreamer I suppose you are right. My solution was create a constructor that in my Paddle class like so
[source lang="csharp"]//Consturotor for Player Paddle //it will have it's own texture and screenBounds so use This public PlayerPaddle(Texture2D texture, Rectangle screenBounds, Vector2 direction, Vector2 position) : base(texture, screenBounds, direction, position) { this.texture = texture; this.screenBounds = screenBounds; }[/source]

That was my main problem was that I was trying to create an instance of the abstract BasePaddle class rather than create the instance of the Player Paddle. So I fixed my problem. Thanks again for all your help fellow gamedev's.