Saturday, October 18, 2014

Geometric Obstacles, Fog of War, Collision Detection, etc.

I've been working my tail off on Sever.  Here's a screenshot.  Beware the ugly placeholder graphics!


There are a couple things to notice in this screenshot.  First off, the big ugly pink thing in the middle.  That is a geometric obstacle (geo for short).  It's called that because I'm unsure what else to call it.  I had geos in previous iterations of sever, but they were only for collision detection.  You couldn't actually see them.  Because of that, you had to attach them to sprites.  I didn't know how to display the shape itself at the time.  This time, however, I bit the bullet and researched how to do it.  Of course, they're going to look better than that because that's just a thrown-together shape with placeholder tiles over it.  Also, I'll probably add nice borders to them so they don't have those hard edges.

The reason why I didn't know how to do it before is because you can't draw them the usual way that MonoGame and XNA draw 2D graphics.  You actually have to draw it the same way you would 3D graphics, which I had never done.  This means you have to draw them in triangles.  As you can see, it's not a triangle, so I had to write code to take the shape and split it up in triangles just so I could display it.  It was difficult and buggy at first, but I did it and you can see it working in the screenshot.  I must say I'm proud of myself.

Next is the fog of war.  You can see two different shades at the moment.  The darker one will be black in the future, but since it's in development, I want to be able to see what's going on behind it.  Anyway, only nodes can see.  The route segments are blind.  The lighter fog you see is what a node I built earlier saw before I destroyed it.  So far, the fog is just cosmetic.  The game will still try to draw everything that's behind it.  I'll write that code soon.

Next, you'll notice the red circle.  This was in the last screenshot, but I don't know if I explained it before, but that's the currently selected node.  The red line and white circle leading from it are where my cursor is dragging a new node.

Lastly, you'll notice the dark circles around each of the nodes in the upper-left corner.  This is the required spacing between each node and every other node owned by the same player.  This way, players can't build them so close to each other.  However they can build them as close as they want to enemy nodes as long as they don't touch.

Oh, if you haven't figured it out yet, collision detection actually works now.

Anyway, that's my progress, or at least the interesting part.  I'll keep posting as it progresses.

Thanks for reading!

clevceo

No comments: