Saturday, March 24, 2012

AI Target Seeking

Today I spent some time developing more of the backbone of my game. I made it so the "random level generator" made some walls that make a bit more sense rather than a mess of points, and I also worked out all the bugs so it's now impossible to pass through the walls no matter how you push against them or how fast you're going.

Once I completed this I used the same system to apply it to all objects like bullets and AI units. I found I could use the same math to do a line-of-sight check for AI as well, which indirectly led me to making my first AI class - a simple AI that chases you down.


So here's how to make sense of this image:
- The green square is the AI unit
- Red square is the player
- Yellow empty square is the last position the AI saw the player at
- Lines are walls
- Red cross is the mouse reticle

Basically the AI will continuously move towards the player until the player moves out of sight. When the player is out of sight the AI will continue to the last location it saw the player at and continue looking for the player from there. If the AI doesn't see the player again and reaches the last location it saw the player, it just idles until it sees the player again. There's definitely room for a lot more features for this guy and I'm pretty excited thinking about what I could put in.

The circles you see behind the player are "sound circles". It's a visualization of how much noise the player is making while moving or firing, and in the future I plan to let AI units "hear" things and guess a location to search. I also plan to put in fog of war so when the player can't see things, they can "hear" them.



So. The next features I plan to put in, in no particular order:
- Voronoi or another sort of tessellation for efficient collision checking
- Making the level generator make "zones" instead of just random points so the walls make more sense
- AI "Hearing" and response
- Projectile-Character collisions (and underlying systems allowing that. Basically hitboxes.)


Friday, March 23, 2012

Terrain Collisions

So I already tried two posts explaining my methods while creating my game - one for why I'm writing in Java, another for how I'm doing terrain collisions, but it just didn't really hold my attention. I figure because I half feel like I'm preaching to an empty room. haha.

In that case I feel like I'll just keep my posts short and say something about what I'm making (like terrain collision systems!) and put a screenshot or two. If you're interested in learning my techniques let me know and I'll make a tutorial or something.

Without further ado!


So what you're seeing here is a basic "random level generator" (just a bunch of connected points) that gives me a whole lot of walls. Basically this means I shouldn't be able to enter the center of that mass, but I haven't really worked out all the quirks yet. I'm detecting collisions against the walls and sliding the player (that red box) along the wall when he hits it according to how his velocity was before collision.

Right now there's a bug where he can squeeze into space he shouldn't be in by pushing against corners.

Anyway, that's how my progress is so far! I also wrote a backbone engine to render everything and sort objects, but I suppose that's less obvious.

I know there's probably math or game libraries I could use to make this but part of the point of this game is to practice creating an engine. I decided on 2D because I wanted to actually complete the game without spending years on it. More updates later!

Tuesday, March 13, 2012

Introduction

Here's the first post of the blog!

I decided to create this since it seemed a good idea to record what I'm doing on my projects. I suppose it should give me some motivation and a way to clear my thoughts. I'm also looking for a job and I heard companies like to see things like this.

So here we go!