Physical Queries for the Math Challenged: Ray Casting
Hopefully, you’ve read my previous article on setting up the basic grid data structure and performing collision detection. If not quickly go read the section on the grid since we’ll be leveraging that data structure to perform ray casting. Ray casting is a powerful and reasonably simple technique which can be used to answer several questions about the environment.
Last time we covered collision detection, but collision detection is only one type of physical query. For Forte I needed to answer additional questions such as: “Can I fire and hit the target?”, “Is there a wall in front of me?”, and “How far can I go in this direction?”. Answering these questions was the basis for the tanks AI. As luck would have it all of these questions can be answered with ray casting, and if we fudge things a little no complex math is needed.
Game Artwork: City Tileset
After Forte I dreamt up another game — a RTS based in a city. Anyway, I’m still toying with the idea, but as things start to get busier I worry that I will never end up using the tileset I created for the game. That’s why I thought I’d share the tileset now in case someone else can use it. Each tile is 48×48 pixels. Each tile is some building or relevant piece of scenery. Also, each building contains a score — this can easily be modified via Photoshop or your favorite editor. Anyway, enough blather here’s the tileset:
Finding the Right 2D Game Engine
At the start of the summer I set out to program a few games. I was totally new to game programming so I wanted to find a framework to take care of some of the complicated (to me!) stuff related to timing, input, and drawing to a canvas. My search finally ended when I found the Slick framework, but along the way I managed to learn a fair deal about competing frameworks and that there is a paucity of information comparing them all. So, to help fill that void I’m going to chronicle some of my thoughts and comments on the various options I looked at.
Physical Queries for the Math Challenged: Collision Detection and Response
Following developing Forte I thought I would share some of the challenges I encountered and more importantly how I overcame them. I am what you might call a design nut more than a number wonk, so some aspects of game programming are more challenging for me. Specifically, I ran into trouble when I needed to implement collision detection and ray casting for my tile based game. If you find yourself needing a collision detection scheme to fit your game or just want a way to easily support ray casting then you’ve come to the right spot. In this post I’m going to cover the basics of implementing such a system without needing to delve into complex vector math or kinematics.







