Jump to content
  • Advertisement

wtfmates

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

109 Neutral

About wtfmates

  • Rank
    Newbie
  1. 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) goodFoodList.Add(food) else badFoodList.Add(badfood) 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) Food.draw(); 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.
  2. I was afraid of that, but I'm still attempting to shoehorn it into the code. I've found a solution that involves taking the location of the center of the ball and figuring out where it collides in relation to the center of the paddle and adjusting it's direction, speed, and position accordingly. If that doesn't work out I'll create three different collision boxes for each paddle. I know I shouldn't be, but I'm very lazy and attempting to shortcut writing completely new code as much as I can. Thank you for all of your help and suggestions though. When I work something out I'll post it here and hopefully you guys can look it over and let me know where I need improvement. I just noticed this reply from you. That's a pretty simple way of doing it. I'll give it a go and let you know how it turns out. Thanks for your help
  3. Advice taken and I added it to the code. It doesn't seem to have helped the predictability of my ball physics though. [/quote] Oh wait, you don't mean it's getting stuck in a corner, or at the top of the screen, you mean it keeps following the same pattern when bouncing around the screen. Why would the ball bounce different, if it hits the same angles every time, with no other forces on it? I think it's doing what it thinks it should. Now, you can make the ball have different angles coming off the padddle, based on where it hits on the paddle to provide some variation. That's what I'd do. [/quote] Yeah, that's what I meant. I'm sorry if I wasn't clear. That sounds like a good idea, but I'm unsure where to start. Will I need to create a separate bounding box for each 1/3rd of the paddle, or is there a simpler way to do it? Feel free to tell me to stop pestering you guys and go google it if you get annoyed with these questions. Found this on a website but I'm not clear on exactly what it's doing: public void BatHit(int block) { if (direction > Math.PI * 1.5f || direction < Math.PI * 0.5f) { switch (block) { case 1: direction = MathHelper.ToRadians(220); break; case 2: direction = MathHelper.ToRadians(215); break; case 3: direction = MathHelper.ToRadians(200); break; case 4: direction = MathHelper.ToRadians(195); break; case 5: direction = MathHelper.ToRadians(180); break; case 6: direction = MathHelper.ToRadians(180); break; case 7: direction = MathHelper.ToRadians(165); break; case 8: direction = MathHelper.ToRadians(130); break; case 9: direction = MathHelper.ToRadians(115); break; case 10: direction = MathHelper.ToRadians(110); break; } } else { switch (block) { case 1: direction = MathHelper.ToRadians(290); break; case 2: direction = MathHelper.ToRadians(295); break; case 3: direction = MathHelper.ToRadians(310); break; case 4: direction = MathHelper.ToRadians(345); break; case 5: direction = MathHelper.ToRadians(0); break; case 6: direction = MathHelper.ToRadians(0); break; case 7: direction = MathHelper.ToRadians(15); break; case 8: direction = MathHelper.ToRadians(50); break; case 9: direction = MathHelper.ToRadians(65); break; case 10: direction = MathHelper.ToRadians(70); break; } } }
  4. Advice taken and I added it to the code. It doesn't seem to have helped the predictability of my ball physics though.
  5. 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?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!