• 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.


  • Content count

  • Joined

  • Last visited

Community Reputation

145 Neutral

About ntwiles

  • Rank
  1. Ahh gotcha! So it looks like to me your value of outT is the same as my data.Ratio in this method:         public static CollisionData CircleVSLine(Vector2 position, float radius, VectorX displacement, LineSegment line)         {             CollisionData data = new CollisionData();               Vector2 line_to_circle;               VectorX line_vector = new VectorX(line.Size);             Vector2 n = line_vector.Normal;               //Shortest distance from circle's center to line - before vector is applied              line_to_circle = line.Position1 - position;             float d1 = Math.Abs(VectorX.DotProduct(line_to_circle, n));               //After vector is applied             line_to_circle = line.Position1 - position - displacement.Components;             float d2 = Math.Abs(VectorX.DotProduct(line_to_circle, n));               data.Ratio = (radius - d1) / (d2 - d1);               if (Math.Abs(d2) < radius)             {                 data.Collides = true;                 data.CollisionPoint = position + (displacement * data.Ratio);             }               return data;         }The math looks to be very much similar, but it looks to me like you're applying some sort of coefficient (I'm guessing Sign() returns either -1 or 1?) based on the sign of the distance, where I'm just storing the absolute value of the distance. Will I be safe continuing to do it that way?
  2. Thanks for the great replies! I0k0, your function is the only one doing a sweep test, which was my goal. I have a couple questions on some of your values.   d - Is this the diameter of the circle? outT - I have no idea what this is, can you explain? Saturate() - I've read that saturation arithmetic constrains the result of any mathematical operation to a range of values. Is this what you're doing? If so, what are you constraining the values to? 0-1?
  3. I think what he means is lines that vary in thickness along the course of the line. This is actually a side effect of the way these lines are drawn in the first place; with a pen tablet. Photoshop tools allow you to vary the thickness of the lines drawn depending on how hard you press down on the tablet (from what I understand, I've never used one).   That being said, you could probably fake this effect using the Pen tool in Photoshop if you wanted to badly enough.
  4. I'm trying to implement a method to check if a circle, given a certain displacement vector, will collide with a line segment. Though I don't follow some of the math, I've managed already to get a working method to determine if a circle will collide with an infinite line, defined by a line segment: public static CollisionData CircleVSLine(Vector2 position, float radius, VectorX displacement, LineSegment line) { CollisionData data = new CollisionData(); Vector2 line_to_circle; VectorX line_vector = new VectorX(line.Size); Vector2 n = line_vector.Normal; //Shortest distance from circle's center to line - before vector is applied line_to_circle = line.Position1 - position; float d1 = Math.Abs(VectorX.DotProduct(line_to_circle,n)); //After vector is applied line_to_circle = line.Position1 - position - displacement.Components; float d2 = Math.Abs(VectorX.DotProduct(line_to_circle, n)); float t = (radius - d1) / (d2 - d1); if (Math.Abs(d2) < radius) { data.Collides = true; data.CollisionPoint = position + (displacement * t); } return data; } And below is my attempt to check for collisions on line segments: public static CollisionData CircleVSLineSegment(Vector2 position, float radius, VectorX displacement, LineSegment line) { VectorX line_vector = new VectorX(line.Size); //First check if collision happened on entire length of line CollisionData data = CircleVSLine(position,radius,displacement,line); //Early out if (!data.Collides) { return data; } /* Next, get the vector form Position1 to data.CollisionPoint. If they are going in the same general direction, * they will have a positive Dot Product, if they aren't, then the collision point must be BEHIND line_vector * (I.E., not ON the vector, and not truly colliding.) * http://hub.tutsplus.com/tutorials/quick-tip-collision-detection-between-a-circle-and-a-line-segment--active-10632 */ VectorX start_to_circle = new VectorX(position - line.Position1); float dot_start = VectorX.DotProduct(line_vector.Components, start_to_circle.Components); //Early out if (dot_start < 0) { data.Collides = false; return data; } if (line.Position1.X == 48 + 16) { //Debugger.Break(); GameStatus.Pause(); } if (position.Y < line.Position1.Y && line.Position1.X == 48+16) Debugger.Break(); /* Next, we make sure the collision point doesn't happen after line_vector has ended. If it does, the projection * of start_to_circle onto line_vector will exceed the length of line_vector. */ float projection = start_to_circle.ScalarProjection(line_vector); if (projection > line_vector.Length) { data.Collides = false; } return data; } As you can see, I link to a tutorial which attempts to explain how the test is done. The algorithm treats the line segment as a vector (which I know is strange), and first tests to see if the circle is actually colliding with the line defined by our line segment BEFORE the start of said line segment.  It then tests in an entirely different way to see if the circle collides with the line at a point AFTER the vector ends. If it doesn't collide before the line segment, and it doesn't collide after the line segment, it collides on the line segment.    The logic of the first half of the test is that if two vectors (the vector defined by our line segment, and the vector from the start of that line segment to the starting position of our circle) have generally opposite directions, then the circle MUST be behind the start of our line segment vector, which makes sense to me.  The test to check if the two vectors ARE going in the same direction though, gives lots of false positives. This is my big issue. I haven't even got to the second half of the algorithm, which doesn't seem to be working either.   Can anyone help me wrap my mind around this? I'd like to repeat that I do have a working test for circles vs infinite lines, which I don't want to discard and which I feel will provide a lot of the data needed to make the more precise circle vs line segment test. Any input would be really appreciated.
  5. To be clear guys, the implementation I used above works, I'm just curious about how it works. Specifically the prep product. Are there any governing theorems that explain this property of prep products?
  6. Alright, so bear with me; I have a lot of knowledge gaps to fill in. Solving it algebraically like you set it up, I see there being two unknowns, t1 and t2, right? p1 = (2,5) p2 = (1,1) d1 = (4,-5) d2 = (6,1) p1 + t1 * d1 = p2 + t2 * d2   So, plugging in the x values only, and solving for t1:   4t1 + 2  = 6t2 + 1 4t1 = 6t2 -1 t1 = 3/2t2 - 1/4    I still need to get the value of either t1 or t2 to go any further, don't I?    
  7. My math is very shaky, and I'm trying to use the following tutorial to get a grasp on vectors and collision detection/response:   http://www.tonypa.pri.ee/vectors/tut05.html   I've made an example and I'll just go through the process then explain my questions.     After some research, I've learned that the t value he's using is a factor in the parametric equation of a line (x,y)=(1-t)(x1,y1)+t(x2,y2). So I need to find the ratio t of vector a at which it intersects b. Then I'll add that to the starting position of a to get the point at which the two vectors intersect.   First I find c, which is the vector between the starting points of a and b. c = (-1,-4). I can then (apparently) solve for t using the ratio of the Dot Products of the normals of my vectors (Perp Product).   t = (c * b) / (a * b).   c*b = (4*6) + (-1*1) = 24 -1 = 23 a*b = (5*6) + (4*1) = 30 + 4 = 34   t = 23/34   a*t is (46/17,-115/34). Adding that to the starting point of a, I get (80/17,-55/34) ? (4.7,1.6), which looks to be right.   I have all the steps down, but I'd like to get a better understanding of the math behind it. Specifically, there's a bit of a logical leap while solving for t. I don't understand how the Perp Product gets us the ratio we need to find the intersection point, or how the vector connecting the two starting points is involved. Any explanations on that or links to theorems explaining it would be really appreciated, as well as any corrections to my explanation. 
  8. I'm interested in creating a 2D sidescrolling game with map design based on convex vectors instead of tiles (See "Type #4" in this article). This will be a challenge for me, and I have a few questions.   My first issue is with level design. The way I see it I'll need to do the following:   1. Design each level as a series of convex shapes for collision, overlaid with an image. 2. Save each convex shape as an array of points.   This would be very tedious, are there any map editors available that already do something like this?    My second question has to do with moving the player up and down slopes:   Collision detection and response should be no problem, but I'm not 100% sure about how a player would move up and down a slope. Currently, I would do it like this:   1. Determine if player collides with a polygon. 2. Determine between which two points of the polygon the player is colliding. 3. Modify player's Y-value based on the slope of that line segment.   Am I on the right track, or is there a better way to do this?   Would love any insight or links to articles on the topic. Thanks guys!  
  9. I love the visual style, and the gameplay so far is really addicting. I love the mix of td/rts/rpg elements. I'll definitely be following this project.   I did have a couple issues during gameplay.   - The tutorial says that L and R keys rotate the camera, but only the arrow keys worked. - I had trouble figureing out how to move the camera while creating a building offscreen from its parent building (i.e. the first outpost)
  10. Hi guys, I'm taking an interesting approach with my next game development project. I've decided to make it entirely community designed. I've started with the simplest shell of a 2D side-perspective game engine I could develop, and put it up online for the world to play and decide what feature needs to be added next. Step by step, we'll make a game together.   Design My Game   I would love to get some input on the idea. Things like:   - Does this idea interest you? - Have you seen a project like this before? (If so, how did it work out?) - Would you submit ideas to a project like this?   Thanks!  
  11. Yeah I guess that would make more sense. Thanks for the help!
  12. So would the best way to do this be to hold all the possible loot outcomes in a collection that gets generated once when the enemy is instantiated, then just roll for which element of the collection to access?
  13. Thanks for the reply!   I avoided doing that because I use the remaining unused percent to decide when to drop nothing at all. Should I be making that a separate check? Like first roll to see if the enemy will drop an item, and after that roll to see what the item is?
  14. I'm trying to figure out the best way to implement a loot drop system for my roguelike. I need individual enemies to have lists of items they can drop, each with different odds of dropping. Here's how I'm doing it now:   public static Item checkDrop(List<LootChance> loot_list) { if (checkLootList(loot_list)) { float roll = (float)rand.NextDouble() * 100; float chance_count = 0; foreach (LootChance lc in loot_list) { if (roll <= lc.PercentChance) { return lc.Loot; } chance_count += lc.PercentChance; } } else { Log.add("Loot odds exceed 100%!"); } return null; }   This works for now, but it will stop me from ever having the total odds of all possible loot items to exceed 100. I could see there being other, possibly better ways of handling this. How is this kind of thing usually calculated? 
  15. In my 2d TDS I'm attempting to offset the location where the player's bullets originate from. This position will obviously need to rotate around the player's origin as the player rotates. My math is rusty but I figured the best way to do this would be to treat it as a triangle with one vertex at the player's position and one at the bullet origin's position. I'm trying to rotate it like so: [CODE] float x1 = shot_offset_x; //Move triangle to origin before rotation float y1 = shot_offset_y; float cos = (float)Math.Cos(p.getDirection()); //Based on player direction. float sin = (float)Math.Sin(p.getDirection()); x1 = x1 * cos + y1 * sin; //Rotating x1 and y1 about point 0,0? y1 = y1 * cos - x1 * sin; x1 += p.X; //Move triangle back to player position y1 += p.Y; [/CODE] The bullets created are always near the player but never in the correct position. They seem to be rotating around a point near the player but not at his origin. Can anyone show me where I went wrong? Edit: I seem to be getting closer here. I'm working with the following code now: [CODE] Vector2 point = new Vector2(shot_offset_x,shot_offset_y); point = MathTool.rotatePoint(point,p.getDirection()); point.X += p.X; point.Y += p.Y; [/CODE] [CODE] public static Vector2 rotatePoint(Vector2 point, float angle) { float cos = (float)Math.Cos(angle); float sin = (float)Math.Sin(angle); point.X = point.X * cos - point.Y * sin; point.Y = point.Y * cos + point.X * sin; return point; } [/CODE] This seems to want to work, but instead of the circle one would expect its making a figure eight shape. Is there still something I'm doing wrong?