Delight of delights, I finally have a modern laptop. I’ve already gone ahead and moved most of my stuff onto here, and I have already got my previous work compiling and running. Great! That’s how I like things; working. I like myself working too, so I’m happy to be back at the cafe with my IDEs open.
Last time I worked on my programming, I added in the Animals to my little sandbox. They don’t DO anything yet, but they’re there. Little blue triangles.
I’m going to use a state-based sort of AI. Each critter will have a bunch of different behaviors wrapped in functions, and depending on what state they’re in, they’ll use different functions. It depends on their needs. These first ones will focus on eating, so they’ll have a hungry state, and a rest state. I’ll probably throw in a play state later.
So first off, I’m making the hungry state. When an animal is hungry, it’ll start using its senses to search for food. To simulate senses in this 2D world, I’m going to have the animals generate invisible shapes and see if those shapes collide with things. There’ll be a sight shape, which will be sort of like a cut-pie in the direction the creature is looking, and a scent shape, which will be a big circle. These guys will be pretty dumb to start. If they see food, they’ll move straight at it. If they smell food, they’ll move in it’s general direction. If they don’t see or smell food, they’ll keep wandering untill they do.
Using shapes like this for collision testing might be a bad idea. It’s easiest to test collisions with a square. Using a complex shape makes things a lot more processor intensive.
Hmm… On further investigation, it looks like HaxePunk entities can only have rectangular collision areas. Shoot.
*loads up the Entity code* Hmm… the collision detection is surprisingly simple. I could probably extend it myself to make shaped collision detection. I’m not sure if that’s a terribly good idea or not though. The more I work with HaxePunk, the more it feels like I’m pushing beyond it’s intended purpose.
Maybe I should do some research on how other people have solved this problem before. Or maybe I shouldn’t. It’s a tough call. They say that you shouldn’t worry about optimization at first, just make something that works, and then refine it afterwards. I could make a shaped collision system. Of course, I could also do the senses by other means than colliding with objects.
Yeah I think I’ll do research for a bit, see if I can dig up any ideas.
Hmm… Well, one thing I’ve learned is that apparently there’s a pollitical blog named Collision Detection. How about that?
Another interesting thing is that when you google Collision Detection, you mostly get linked to articles from the turn of the century.
Oh, here’s one from last year. Looks interesting. The math involved may require me to do further research, though. I’m lucky I’m able to figure out advanced math like this, even though I didn’t learn it in school. I wish I had, though.
This article assumes the reader has a basic grasp of mathematics and geometry he says. Matricies are not basic! EVER!
Well, it seems like it’s a good article anyways. I’m not done with it, but I need a break. Learning makes my anxiety peak.