Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Oct 2012
Offline Last Active Nov 27 2012 09:01 AM

Topics I've Started

Not quite sure where to start when it comes to drawing an array of sprites.

26 November 2012 - 12:29 PM

So, I finished a pong game and upped the ante to a clone of the game Snake. Now I want the "food" to spawn at a random Vector 2 every 3 or so seconds (I'll flesh out the mechanics later). I've got two food classes, one for "good food" and one for "bad food." The random positioning works adequately, but I'm unsure how to draw more than one. I'm thinking something along the lines of (psuedo code):

if (counter <= 3)
n = rand.next (0, 100);
if (n <= 75)
counter = 0;

My food classes each have their own draw method that I call in the game1 class draw method to keep things from getting cluttered, so the draw would look like:

foreach (Food food in goodFoodList)

Am I on the right track? Is there anything I need to include in the food classes to get this working properly? Is there a better way of doing things?

Thanks in advance for the help. I really appreciate it.

Yet another pong question, this time about ball physics.

24 October 2012 - 07:01 AM

Alright, so I've got some nice collision detection going on and the ball's Y position is multiplied by -1 every time it hits a wall or a paddle, like so:

if (ballPosition.Y < 0 || ballPosition.Y > maxY)
ballSpeed.Y *= -1;

but i'm finding that it isn't enough. My ball keeps getting stuck going through the same movements. I don't even have to move my paddle when this happens and can just leave it hanging out in the corner while I go grab a beer.

Could someone help me out with this?