• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

wtfmates

Members
  • 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. [quote name='Bacterius' timestamp='1351090717' post='4993451'] You could consider your paddle as a rectangle with two half circles at the ends. Then find out what the ball hits and perform collision response accordingly (for the rectangle, reflect the velocity about the surface normal, for the half circles do the same but the normal depends on the location the ball hit - and this'll make the ball bounce off at different angles if it hits the edges of the paddle). Though this kind of design can't really be shoehorned in the typical "if ball position is less than zero do such and such" type of code - you'd need to start from scratch and define actual objects, run correct intersection loops, etc.. [/quote] 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. [quote name='BeerNutts' timestamp='1351088952' post='4993439'] There are multiple ways you could do this. I think the simplest would be to have it check each 1/3 of the paddle (as you suggest), and, do something like this: [code] if (PaddleHit()) { // This covers the middle part of paddle hit ballSpeed.Y *= -1; if (LeftSidePaddleHit()) { // increase Y speed, so it goes up at a tighter angle: ballSpeed.Y *= 2; } else if (LeftSidePaddleHit()) { // decrease Y speed, so it goes up at a wider angle: ballSpeed.Y /= 2; } // Ensure Y-Speed doesn't go above or below a minimum here } [/code] That code above is just a guess. You should really be keeping the velocity as a fraction, so you can perform these computations with greater accuracy. The other methods of doing this would involve some trigonometry, or some vector math. You're welcome to look up some solutions related to them if you would like. [/quote] 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. [quote name='BeerNutts' timestamp='1351085556' post='4993419'] [quote name='wtfmates' timestamp='1351084914' post='4993415'] [quote name='Bacterius' timestamp='1351084081' post='4993408'] You need to push the ball out of the wall/paddle, otherwise the ball's speed will repeatedly get multiplied by -1 and will jitter with zero net displacement. You can do this: if (ballPosition.Y < 0 || ballPosition.Y > maxY) { ballSpeed.Y *= -1; if (ballPosition.Y < 0) ballPosition = 0; if (ballPosition.Y > max) ballPosition.Y = max; } Or something like that. [/quote] 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: [CODE] 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; } } } [/CODE]
  4. [quote name='Bacterius' timestamp='1351084081' post='4993408'] You need to push the ball out of the wall/paddle, otherwise the ball's speed will repeatedly get multiplied by -1 and will jitter with zero net displacement. You can do this: if (ballPosition.Y < 0 || ballPosition.Y > maxY) { ballSpeed.Y *= -1; if (ballPosition.Y < 0) ballPosition = 0; if (ballPosition.Y > max) ballPosition.Y = max; } Or something like that. [/quote] 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?